PageRenderTime 92ms CodeModel.GetById 37ms RepoModel.GetById 1ms app.codeStats 0ms

/README.md

https://github.com/fukamachi/leiningen
Markdown | 211 lines | 160 code | 51 blank | 0 comment | 0 complexity | 4f4f7f72a6c3c43f6a784f91c7d7ebe6 MD5 | raw file
Possible License(s): EPL-1.0
  1. # Leiningen
  2. > "Leiningen!" he shouted. "You're insane! They're not creatures you can
  3. > fight--they're an elemental--an 'act of God!' Ten miles long, two
  4. > miles wide--ants, nothing but ants! And every single one of them a
  5. > fiend from hell..."
  6. > -- from Leiningen Versus the Ants by Carl Stephenson
  7. Leiningen is a build tool for Clojure designed to not set your hair on fire.
  8. <img src="http://github.com/downloads/technomancy/leiningen/leiningen-banner.png" alt="Leiningen logo" title="The man himself" align="right" />
  9. Building Clojure projects with tools designed for Java can be an
  10. exercise in frustration. If you use Ant, you end up copying around a
  11. lot of the same tasks between XML files on all your projects;
  12. there's a lot of repetition. Maven avoids repetition, but provides
  13. very little transparency into what's really going on behind the scenes
  14. and forces you to become a Maven expert to script a nontrivial
  15. build. Either way you must write far more XML than is decent.
  16. With Leiningen, you describe your build with Clojure.
  17. ## Installation
  18. Leiningen bootstraps itself using the <tt>lein</tt> shell script;
  19. there is no separate 'install script'. It installs its dependencies in
  20. $HOME/.m2/repository.
  21. 1. [Download the script](http://github.com/technomancy/leiningen/raw/stable/bin/lein).
  22. 2. Place it on your path and chmod it to be executable.
  23. 3. Run: <tt>lein self-install</tt>
  24. For development versions you may use [the master version of the lein
  25. script](http://github.com/technomancy/leiningen/raw/master/bin/lein) instead.
  26. On Windows you can download
  27. [lein.bat](http://github.com/technomancy/leiningen/raw/master/bin/lein.bat),
  28. instead, though support on that platform is still experimental.
  29. ## Usage
  30. The
  31. [tutorial](http://github.com/technomancy/leiningen/blob/master/TUTORIAL.md)
  32. has a detailed walk-through of the steps involved in creating a new
  33. project, but here are the commonly-used tasks:
  34. $ lein new NAME # generate a new project skeleton
  35. $ lein deps # install dependencies in lib/
  36. $ lein test [TESTS] # run the tests in the TESTS namespaces, or all tests
  37. $ lein repl # launch an interactive REPL session
  38. $ lein jar # package up the whole project as a .jar file
  39. $ lein install [NAME VERSION] # install a project
  40. Use <tt>lein help</tt> to see a complete list. <tt>lein help
  41. $TASK</tt> shows the usage for a specific one.
  42. You can also chain tasks together in a single command by using commas:
  43. $ lein clean, test foo.test-core, jar
  44. Most tasks need to be run from somewhere inside a project directory to
  45. work, but some (<tt>new</tt>, <tt>help</tt>, <tt>version</tt> and the
  46. two-argument version of <tt>install</tt>) may run from anywhere.
  47. The install task places shell scripts in the <tt>~/.lein/bin</tt>
  48. directory for projects that include them, so if you want to take
  49. advantage of this, you should put it on your $PATH.
  50. ## Configuration
  51. Place a project.clj file in the project root like this:
  52. (defproject leiningen "0.5.0-SNAPSHOT"
  53. :description "A build tool designed not to set your hair on fire."
  54. :url "http://github.com/technomancy/leiningen"
  55. :dependencies [[org.clojure/clojure "1.1.0"]
  56. [org.clojure/clojure-contrib "1.1.0"]
  57. [ant/ant-launcher "1.6.2"]
  58. [org.apache.maven/maven-ant-tasks "2.0.10"]]
  59. :dev-dependencies [[swank-clojure "1.2.1"]])
  60. The <tt>lein new</tt> task generates a project skeleton with an
  61. appropriate starting point from which you can work. See the
  62. [sample.project.clj](http://github.com/technomancy/leiningen/blob/master/sample.project.clj)
  63. file for a detailed listing of configuration options.
  64. You can also have user-level configuration that applies for all
  65. projects. The ~/.lein/init.clj file will be loaded every time
  66. Leiningen launches; any arbitrary code may go there. Place jars
  67. containing plugins in ~/.lein/plugins to have them available globally
  68. for the current user.
  69. ## FAQ
  70. **Q:** How do you pronounce Leiningen?
  71. **A:** It's LINE-ing-en. I think.
  72. **Q:** What does this offer over [Lancet](http://github.com/stuarthalloway/lancet)?
  73. **A:** Lancet is more of a library than a build tool. It doesn't predefine
  74. any tasks apart from what Ant itself offers, so there is nothing
  75. Clojure-specific in it. Leiningen builds on Lancet, but takes
  76. things further. In addition, it includes some Maven functionality
  77. for dependencies.
  78. **Q:** But Maven is terrifying!
  79. **A:** That's not a question. Anyway, Leiningen only uses the dependency
  80. resolution parts of Maven, which are quite tame. For the actual
  81. task execution cycles it uses Ant under the covers via Lancet.
  82. **Q:** But Ant is terrifying!
  83. **A:** That's [true](http://www.defmacro.org/ramblings/lisp.html). Ant is
  84. an interpreter for a [procedural language with a regrettable
  85. syntax](http://blogs.tedneward.com/2005/08/22/When+Do+You+Use+XML+Again.aspx).
  86. But if you treat it as a standard library of build-related
  87. functions and are able to write it with a more pleasing syntax, it's
  88. not bad.
  89. **Q:** What's a group ID? How do snapshots work?
  90. **A:** See the
  91. [tutorial](http://github.com/technomancy/leiningen/blob/master/TUTORIAL.md)
  92. for background.
  93. **Q:** How should I pick my version numbers?
  94. **A:** Use [semantic versioning](http://semver.org).
  95. **Q:** What if my project depends on jars that aren't in any repository?
  96. **A:** Open-source jars can be uploaded to Clojars (see "Publishing"
  97. in the tutorial), though be sure to use the group-id of
  98. "org.clojars.$USERNAME" in order to avoid conflicts and to allow the
  99. original authors to claim it in the future once they get around to
  100. uploading. Alternatively you can do a one-off install into your
  101. local repository in ~/.m2 with Maven. Add a dependency to
  102. project.clj that doesn't exist in any remote repository and run
  103. <tt>lein deps</tt>. It won't succeed, but the output will include
  104. the <tt>mvn</tt> invocation to do this. It's _much_ better to get
  105. the dependency in a remote repository for repeatability reasons
  106. though. For teams working on private projects
  107. [Hudson](http://hudson-ci.org/) works well.
  108. **Q:** How do I write my own tasks?
  109. **A:** If it's a task that may be useful to more than just your
  110. project, you should make it into a
  111. [plugin](http://github.com/technomancy/leiningen/blob/master/PLUGINS.md).
  112. You can also include one-off tasks in your src/leiningen/ directory
  113. if they're not worth spinning off; the plugin guide shows how.
  114. **Q:** I want to hack two projects in parallel, but it's annoying to switch between them.
  115. **A:** Use a feature called _checkout dependencies_. If you create
  116. a directory called <tt>checkouts</tt> in your project root and
  117. symlink some other projects into it, Leiningen will allow you to
  118. hack on them in parallel. That means changes in the dependency will
  119. be visible in the main project without having to go through the
  120. whole install/switch-projects/deps/restart-swank cycle.
  121. **Q:** Is it possible to exclude indirect dependencies?
  122. **A:** Yes. Some libraries, such as log4j, depend on projects that are
  123. not included in public repositories and unnecessary for basic
  124. functionality. Projects listed as :dependencies may exclude
  125. any of their dependencies by using the :exclusions key. See
  126. sample.project.clj for details.
  127. **Q:** It says a required artifact is missing for "super-pom". What's that?
  128. **A:** The Maven API that Leiningen uses refers to your project as
  129. "super-pom". It's just a quirk of the API. It probably means there
  130. is a typo in your :dependency declaration in project.clj.
  131. **Q:** What does java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V mean?
  132. **A:** It means you have some code that was AOT (ahead-of-time)
  133. compiled with a different version of Clojure than the one you're
  134. currently using. If it persists after running <tt>lein clean</tt> then it
  135. is a problem with your dependencies. If you depend on contrib, make
  136. sure the contrib version matches the Clojure version. Also note for
  137. your own project that AOT compilation in Clojure is much less
  138. important than it is in other languages. There are a few
  139. language-level features that must be AOT-compiled to work, generally
  140. for Java interop. If you are not using any of these features, you
  141. should not AOT-compile your project if other projects may depend
  142. upon it.
  143. ## Building
  144. Generally a "lein self-install" will get you what you need.
  145. Occasionally this will fail for very new SNAPSHOT versions since the
  146. standalone jar will not have been uploaded yet.
  147. If you have a copy of an older Leiningen version around (installed as
  148. lein-stable, for example), then you can run "lein-stable deps" in your
  149. checkout.
  150. Otherwise you can use Maven:
  151. $ mvn dependency:copy-dependencies
  152. $ mv target/dependency lib
  153. See the file HACKING.md for instructions on contributing.
  154. ## License
  155. Copyright (C) 2009-2010 Phil Hagelberg, Alex Osborne, Dan Larkin, and
  156. contributors.
  157. Thanks to Stuart Halloway for Lancet and Tim Dysinger for convincing
  158. me that good builds are important.
  159. Distributed under the Eclipse Public License, the same as Clojure
  160. uses. See the file COPYING.