From fa2a0a0f47117dfd0c48e48047d481b8c58d671f Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 9 Nov 2010 22:20:22 -0800 Subject: [PATCH] Mention features for 1.4 in tutorial/plugin docs. --- NEWS | 1 + PLUGINS.md | 10 ++++------ TUTORIAL.md | 36 +++++++++++++++++++++++++++++++++--- todo.org | 2 ++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 26b8302f..88b04973 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ Leiningen NEWS -- history of user-visible changes * Merge javac task from lein-javac plugin. (Antonio Garrote) * Add init argument to eval-in-project to help with the Gilardi Scenario. + See http://technomancy.us/143 for details. * Fix bug involving repl I/O flushing. diff --git a/PLUGINS.md b/PLUGINS.md index ab0b63d8..cafb6e9c 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -5,12 +5,10 @@ namespace. So writing a Leiningen plugin is pretty straightforward; as 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 -"lein deps". Then you'll be able to invoke the tasks it provides with -"lein $TASK". If you want plugins to be available for all the projects -you use, you can place their jars in ~/.lein/plugins. - -TODO: explain plugin task +Plugins may be installed on a per-project or user-wide basis. To use a +plugin in a single project, add it to your project.clj +:dev-dependencies and run "lein deps". To install it for your user, +run "lein plugin install ARTIFACT-ID VERSION". ## Writing a Plugin diff --git a/TUTORIAL.md b/TUTORIAL.md index 70be2635..19ee8d73 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -200,6 +200,23 @@ just one or two namespaces at a time: Ran 2 tests containing 10 assertions. 0 failures, 0 errors. +Rather than running your whole suite or just a few namespaces at a +time, you can run a subset of your tests using test selectors. To do +this, you attach metadata to various deftests. + + (deftest ^{:integration true} network-heavy-test + (is (= [1 2 3] (:numbers (network-operation))))) + +Then add a :test-selectors map to project.clj: + + :test-selectors {:default (fn [v] (not (:integration v))) + :integration :integration + :all (fn [_] true)} + +Now if you run "lein test" it will only run deftests that don't have +:integration metadata, while "lein test :integration" will only run +the integration tests and "lein test :all" will run everything. + Because it starts a new JVM process, lein test is not a good solution for test-driven development. For that you would either need to look into better editor integration (see @@ -229,9 +246,19 @@ shouldn't have any code with side-effects in the top-level. If you have code that should run on startup, place it in a -main function as explained below under "Uberjar". -TODO: mention javac task +For projects that include some Java code, you can set the +:java-source-path key in project.clj to a directory +containing Java files. Then the javac compiler will run before your +Clojure code is AOT-compiled, or you can run it manually with the +javac task. -TODO: mention deletion of non-project .class files +There's [a problem in +Clojure](http://dev.clojure.org/jira/browse/CLJ-322) where +AOT-compiling a namespace will also AOT compile all the namespaces it +depends upon. This has often caused unrelated compilation artifacts to +be included in the jars, but Leiningen will now only keep class files +for which a directory exists in src/ corresponding to the class's +package. ## What to do with it @@ -300,7 +327,10 @@ You can run a regular (non-uber) jar with the java command-line tool, but that requires constructing the classpath yourself, so it's not a good solution for end-users. -TODO: mention run task +Invoking "lein run" will launch your project's -main function as if +from an uberjar, but without going through the packaging process. You +can also specify an alternate namespace in which to look for -main +with "lein run -m my.alternate.namespace ARG1 ARG2". ### Shell Wrappers diff --git a/todo.org b/todo.org index aead1e4d..7687a83d 100644 --- a/todo.org +++ b/todo.org @@ -51,6 +51,8 @@ See also http://github.com/technomancy/leiningen/issues the standard lucene index system that Maven repositories offer. This would also mean getting Clojars to produce those indices. * For 1.4 +** TODO test selectors need to support things like constantly, complement +** DONE detect missing level of nesting in project.clj's deps/dev-deps ** DONE clear out non-transitive .class files after AOT Luc Prefontaine has code for this. ** DONE plugin task for managing/upgrading plugins