Skip to content

Commit

Permalink
Documentation update.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Jul 18, 2010
1 parent cea853a commit dff976c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 43 deletions.
45 changes: 20 additions & 25 deletions PLUGINS.md
@@ -1,11 +1,13 @@
# Leiningen Plugins # Leiningen Plugins


Leiningen tasks are simply functions in a leiningen.task namespace. So Leiningen tasks are simply functions named $TASK in a leiningen.$TASK
writing a Leiningen plugin is pretty straightforward; as long as it's namespace. So writing a Leiningen plugin is pretty straightforward; as
available on the classpath, Leiningen will be able to use it. long as it's available on the classpath, Leiningen will be able to use
it.


To use a plugin, add it to your project.clj :dev-dependencies and run To use a plugin, add it to your project.clj :dev-dependencies and run
"lein deps". Then you'll be able to invoke it with "lein myplugin". "lein deps". Then you'll be able to invoke the tasks it provides with
"lein $TASK".


## Writing a Plugin ## Writing a Plugin


Expand All @@ -14,8 +16,8 @@ leiningen.myplugin namespace with a myplugin function. That function
should take at least one argument: the current project. The project is should take at least one argument: the current project. The project is
a map which is based on the project.clj file, but it also has :name, a map which is based on the project.clj file, but it also has :name,
:group, :version, and :root keys added in. If you want it to take :group, :version, and :root keys added in. If you want it to take
parameters from the command-line invocation, you can make it take more parameters from the command-line invocation, you can make the function
arguments. take more arguments.


Note that Leiningen is an implied dependency of all plugins; you don't Note that Leiningen is an implied dependency of all plugins; you don't
need to explicitly list it in the project.clj file. need to explicitly list it in the project.clj file.
Expand All @@ -24,6 +26,14 @@ The docstring from the plugin's namespace will be displayed by the
"lein help" task. The function's arglists will also be shown, so pick "lein help" task. The function's arglists will also be shown, so pick
argument names that are clear and descriptive. argument names that are clear and descriptive.


If your task returns an integer, it will be used as the exit code for
the process.

You can set up aliases for your task by conjing a pair of strings with
alias->task-name mappings on to the leiningen.core/aliases atom:

(swap! leiningen.core/aliases conj ["-v" "version"])

## Lancet ## Lancet


If your plugins need to do a fair amount of filesystem-y things, you If your plugins need to do a fair amount of filesystem-y things, you
Expand All @@ -41,28 +51,13 @@ tasks](http://www.jajakarta.org/ant/ant-1.6.1/docs/en/manual/api/org/apache/tool
to find an appropriate task. See the <tt>deps</tt> task for an example to find an appropriate task. See the <tt>deps</tt> task for an example
of how to call a task from Clojure. of how to call a task from Clojure.


## Leiningen 1.2

The rest of this document only applies to Leiningen version 1.2+. It
is subject to breaking change until 1.2.0 sees a stable release.

If your task returns an integer, it will be used as the exit code for
the process.

You can set up aliases for your task by conjing a pair of strings with
alias->task-name mappings on to the leiningen.core/aliases atom:

(swap! leiningen.core/aliases conj ["-v" "version"])

## Hooks ## Hooks


You can modify the behaviour of built-in tasks to a degree using You can modify the behaviour of built-in tasks to a degree using
hooks. Hook functionality is provided by [Robert hooks. Hook functionality is provided by the [Robert
Hooke](http://github.com/technomancy/robert-hooke), a separate Hooke](http://github.com/technomancy/robert-hooke) library. This is an
library. Your plugin will have to declare it as a dependency in implied dependency; as long as Leiningen 1.2 or higher is used it will
project.clj if you want to use hooks: be available.

:dev-dependencies [[robert/hooke "1.0.1"]]


Inspired by clojure.test's fixtures functionality, hooks are functions Inspired by clojure.test's fixtures functionality, hooks are functions
which wrap tasks and may alter their behaviour by using binding, which wrap tasks and may alter their behaviour by using binding,
Expand Down
36 changes: 18 additions & 18 deletions README.md
Expand Up @@ -8,6 +8,8 @@
Leiningen is a build tool for Clojure designed to not set your hair on fire. Leiningen is a build tool for Clojure designed to not set your hair on fire.


<img src="http://github.com/technomancy/leiningen/raw/master/resources/leiningen.png" alt="Leiningen logo" title="The man himself" align="right" />

Building Clojure projects with tools designed for Java can be an Building Clojure projects with tools designed for Java can be an
exercise in frustration. If you use Ant, you end up copying around a exercise in frustration. If you use Ant, you end up copying around a
lot of the same tasks between XML files on all your projects; lot of the same tasks between XML files on all your projects;
Expand All @@ -18,10 +20,11 @@ build. Either way you must write far more XML than is decent.


With Leiningen, you describe your build with Clojure. Any code you With Leiningen, you describe your build with Clojure. Any code you
need goes in your project.clj file; the only requirement is calling need goes in your project.clj file; the only requirement is calling
defproject. You can define your own tasks in there if you need to, but defproject. You can define your own tasks in your project if you need
most projects get by on the tasks provided with Leiningen. If you do to, but most projects get by on the tasks provided with Leiningen. If
find a common task that you need to add, you can implement it as a you do find a common task that you need to add, you can implement it
plugin rather than copying and pasting among each of your projects. as a plugin rather than copying and pasting among each of your
projects.


## Installation ## Installation


Expand Down Expand Up @@ -53,7 +56,7 @@ project, but here are the commonly-used tasks:


$ lein test [TESTS] # run the tests in the TESTS namespaces, or all tests $ lein test [TESTS] # run the tests in the TESTS namespaces, or all tests


$ lein repl # launch a REPL session $ lein repl # launch an interactive REPL session


$ lein jar # package up the whole project as a .jar file $ lein jar # package up the whole project as a .jar file


Expand Down Expand Up @@ -119,10 +122,11 @@ file for a detailed listing of configuration options.
uploading. Alternatively you can do a one-off install into your uploading. Alternatively you can do a one-off install into your
local repository in ~/.m2 with Maven. Add a dependency to local repository in ~/.m2 with Maven. Add a dependency to
project.clj that doesn't exist in any remote repository and run project.clj that doesn't exist in any remote repository and run
<tt>lein deps</tt>, and the output will include the <tt>mvn</tt> <tt>lein deps</tt>. It won't succeed, but the output will include
invocation to do this. It's _much_ better to get the dependency in a the <tt>mvn</tt> invocation to do this. It's _much_ better to get
remote repository for repeatability reasons though. For teams the dependency in a remote repository for repeatability reasons
working on private projects [Hudson](http://hudson-ci.org/) works well. though. For teams working on private projects
[Hudson](http://hudson-ci.org/) works well.


**Q:** How do I write my own tasks? **Q:** How do I write my own tasks?
**A:** If it's a task that may be useful to more than just your **A:** If it's a task that may be useful to more than just your
Expand All @@ -132,7 +136,7 @@ file for a detailed listing of configuration options.
if they're not worth spinning off; the plugin guide shows how. if they're not worth spinning off; the plugin guide shows how.


**Q:** I want to hack two projects in parallel, but it's annoying to switch between them. **Q:** I want to hack two projects in parallel, but it's annoying to switch between them.
**A:** Use a new feature called _checkout dependencies_. If you create **A:** Use a feature called _checkout dependencies_. If you create
a directory called <tt>checkouts</tt> in your project root and a directory called <tt>checkouts</tt> in your project root and
symlink some other projects into it, Leiningen will allow you to symlink some other projects into it, Leiningen will allow you to
hack on them in parallel. That means changes in the dependency will hack on them in parallel. That means changes in the dependency will
Expand Down Expand Up @@ -172,16 +176,16 @@ Clojure; you could probably read through the whole project in an hour.
When you launch Leiningen, it must start an instance of Clojure to When you launch Leiningen, it must start an instance of Clojure to
load itself. But this instance must not effect the project that you're load itself. But this instance must not effect the project that you're
building. It may use a different version of Clojure from Leiningen, building. It may use a different version of Clojure from Leiningen,
and the project should be in a totally fresh JVM. Leiningen uses ant's and the project should be in a fresh JVM. Leiningen uses ant's
<tt>java</tt> task to fork off a separate process for this <tt>java</tt> task to fork off a separate process for this
purpose. The <tt>leiningen.compile</tt> namespace implements this; purpose. The <tt>leiningen.compile</tt> namespace implements this;
specifically the <tt>eval-in-project</tt> function. Any code that must specifically the <tt>eval-in-project</tt> function. Any code that must
execute within the context of the project (AOT compilation, test runs) execute within the context of the project (AOT compilation, test runs)
needs to go through this function. needs to go through this function.


Leiningen tasks are simply Clojure functions that take the current Leiningen is extensible; you can define new tasks in plugins. Add your
project as their first argument followed by any further arguments that plugin as a dev-dependency of your project, and you'll be able to call
were given on the command-line. <tt>lein $YOUR_COMMAND</tt>. See the [plugins guide](http://github.com/technomancy/leiningen/blob/master/PLUGINS.md) for details.


The [mailing list](http://groups.google.com/group/leiningen) and the The [mailing list](http://groups.google.com/group/leiningen) and the
leiningen or clojure channels on Freenode are the best places to leiningen or clojure channels on Freenode are the best places to
Expand All @@ -201,10 +205,6 @@ time on your hands, reading this [style
guide](http://mumble.net/~campbell/scheme/style.txt) wouldn't hurt guide](http://mumble.net/~campbell/scheme/style.txt) wouldn't hurt
either. either.


Leiningen is extensible; you can define new tasks in plugins. Add your
plugin as a dev-dependency of your project, and you'll be able to call
<tt>lein $YOUR_COMMAND</tt>. See the [plugins guide](http://github.com/technomancy/leiningen/blob/master/PLUGINS.md) for details.

See the [complete list of known issues](http://github.com/technomancy/leiningen/issues). See the [complete list of known issues](http://github.com/technomancy/leiningen/issues).


## License ## License
Expand Down

0 comments on commit dff976c

Please sign in to comment.