Skip to content

Commit

Permalink
Merge branch 'master' into search-task-improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
MenschNestor committed May 12, 2012
2 parents 191da39 + 93bb6a1 commit 052c2d0
Show file tree
Hide file tree
Showing 27 changed files with 274 additions and 194 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,3 +17,4 @@ docs
/leiningen-core/.lein-plugins/checksum
/wiki
TAGS
/leiningen-core/dev-resources/target
19 changes: 19 additions & 0 deletions NEWS.md
@@ -1,5 +1,24 @@
# Leiningen News -- history of user-visible changes

## 2.0.0-preview4 / 2012-05-11

* Checkout dependencies are not applied with production profile.
* Move pom.xml back to the project root.
* Add -U alias for forcing updates of snapshots.
* Support setting :update and :checksum profiles at top level of project.
* Blink matching parens in repl. (Colin Jones)
* Fix a bug where repl would interfere with project agents. (Chas Emerick)
* Show repl output that is emitted after return value. (Colin Jones)
* Make it easier for plugins to undo profile merging. (David Santiago)
* Add -o alias for activating offline profile.
* Ignore $CLASSPATH environment variable.
* Fix bug where repl task couldn't be trampolined. (Colin Jones)
* Allow jar manifest entries to be dynamically calculated.
* Support map-style :javac-opts like Leiningen 1.x used. (Michael Klishin)
* Allow group-id to be specified when creating new projects. (Michael Klishin)
* Fix a bug where :dev dependencies would be exposed in pom.
* Use Clojure 1.4.0 internally; plugins have access to new Clojure features.

## 2.0.0-preview3 / 2012-04-12

* Add HTTP nREPL support for repl task via :connect option. (Chas Emerick,
Expand Down
63 changes: 35 additions & 28 deletions README.md
Expand Up @@ -4,10 +4,10 @@
alt="Leiningen logo" title="The man himself" align="right" />

> "Leiningen!" he shouted. "You're insane! They're not creatures you can
> fight--they're an elemental--an 'act of God!' Ten miles long, two
> miles wide--ants, nothing but ants! And every single one of them a
> fight—they're an elemental—an 'act of God!' Ten miles long, two
> miles wide—ants, nothing but ants! And every single one of them a
> fiend from hell..."
> -- from Leiningen Versus the Ants by Carl Stephenson
> - from Leiningen Versus the Ants by Carl Stephenson
Leiningen is for automating Clojure projects without setting your hair on fire.

Expand All @@ -26,7 +26,7 @@ upon the first run on unix, so the first run will take longer.
2. Place it on your `$PATH`. (I like to use `~/bin`)
3. Set it to be executable. (`chmod 755 ~/bin/lein`)

The instructions above will install the stable release. The Leiningen 2
The link above will get you the stable release. The Leiningen 2
[preview release](https://raw.github.com/technomancy/leiningen/preview/bin/lein)
has some great new features, but not all projects and plugins have
been upgraded to work with it yet. Please see the
Expand Down Expand Up @@ -56,7 +56,7 @@ project, but here are the commonly-used tasks:

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

$ lein install # install a project
$ lein install # install a project into the local repository

$ lein search [TERM] # find jars for your project.clj dependencies

Expand All @@ -83,19 +83,14 @@ The `project.clj` file in the project root should look like this:
:plugins [[lein-ring "0.4.5"]])
```

To find specific versions of a dependency, use `lein search`.
To find specific versions of a dependency, use `lein search`, though
note that this can be extremely slow the first time you use it.

The `lein new` task generates a project skeleton with an
appropriate starting point from which you can work. See the
The `lein new` task generates a project skeleton with an appropriate
starting point from which you can work. See the
[sample.project.clj](https://github.com/technomancy/leiningen/blob/preview/sample.project.clj)
file for a detailed listing of configuration options.

You can also have user-level configuration that applies for all
projects. The `~/.lein/init.clj` file will be loaded every time
Leiningen launches; any arbitrary code may go there. This code is
executed inside Leiningen itself, not in your project. Set the
`:init-ns` key in `:repl-options` in project.clj to point to a
namespace if you want code executed inside your project in the repl.
file (also available via `lein help sample`) for a detailed listing of
configuration options.

### Profiles

Expand All @@ -107,9 +102,11 @@ Clojure available in every project you hack on without modifying every
single project.clj you use.

By default the `:dev`, `:user`, and `:default` profiles are activated
for each task. Each profile is defined as a map which gets merged into
your project map. To add resources directories during development, add
a `:profiles` key to project.clj like so:
for each task, but the settings they provide are not propagated
downstream to projects that depend upon yours. Each profile is defined
as a map which gets merged into your project map. To add resources
directories during development, add a `:profiles` key to project.clj
like so:

```clj
(defproject myproject "0.5.0-SNAPSHOT"
Expand Down Expand Up @@ -230,6 +227,15 @@ explains how to write plugins.
any of their dependencies by using the `:exclusions` key. See
`lein help sample` for details.

**Q:** Why doesn't `deps` task populate the `lib` directory in version 2?
**A:** The only reason version 1 copied the jars around in the first
place was to support existing tooling that needed a cheap way to
calculate a project's classpath. Now that Leiningen has a mature
plugin ecosystem, this is no longer needed; jars can be referenced
directly out of the `~/.m2/repository` directory. If you need to see
a listing of all the dependencies that will be used and their
versions, use `lein deps :tree`.

**Q:** What does `java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V` mean?
**A:** It means you have some code that was AOT (ahead-of-time)
compiled with a different version of Clojure than the one you're
Expand All @@ -251,7 +257,7 @@ explains how to write plugins.
**Q:** What can be done to speed up launch?
**A:** The main delay involved in Leiningen comes from starting the
JVM. Most people use a development cycle that involves keeping a
single process running for as long as you're working on that
single REPL process running for as long as you're working on that
project. Depending on your editor you may be able to do this via its
Clojure integration. (See
[swank-clojure](http://github.com/technomancy/swank-clojure) or
Expand All @@ -267,10 +273,10 @@ explains how to write plugins.
**Q:** Why is Leiningen 2 still in a preview release?
**A:** As of the preview3 release, Leiningen 2 is very stable and
recommended for general use. The main thing keeping it from a final
release is the fact that the Clojars repository
release is the fact that the current Clojars repository
[mingles snapshots with releases](https://github.com/ato/clojars-web/issues/24),
which is undesirable. Since switching the default repositories to a
releases-only Clojars (which hasn't been implemented yet) would be a
releases-only Clojars (which is still in development) would be a
breaking change, a series of previews is being released in the mean time.

**Q:** I don't have access to stdin inside my project.
Expand All @@ -284,15 +290,16 @@ explains how to write plugins.
## Contributing

Please report issues on the
[Github issue tracker](https://github.com/technomancy/leiningen/issues)
[GitHub issue tracker](https://github.com/technomancy/leiningen/issues)
or the [mailing list](http://groups.google.com/group/leiningen).
Personal email addresses are **not** appropriate for bug reports. See
the readme for the `leiningen-core` library and `doc/PLUGINS.md` for
more details on how Leiningen's codebase is structured. Design
discussions also occur in the
the
[readme for the leiningen-core library](https://github.com/technomancy/leiningen/blob/master/leiningen-core/README.md)
and `doc/PLUGINS.md` for more details on how Leiningen's codebase is
structured. Design discussions also occur in the
[#leiningen channel on Freenode](irc://chat.freenode.net#leiningen).

Patches are preferred as Github pull requests, though patches from
Patches are preferred as GitHub pull requests, though patches from
`git format-patch` are also welcome on the mailing list. Please use
topic branches when sending pull requests rather than committing
directly to master in order to minimize unnecessary merge commit
Expand All @@ -306,7 +313,7 @@ merging if you ask on IRC or the mailing list.

Contributors are also welcome to request a free
[Leiningen sticker](http://twitpic.com/2e33r1) by asking on the
mailing list and mailing a SASE.
mailing list and mailing a self-addressed, stamped envelope.

## Building

Expand Down
6 changes: 2 additions & 4 deletions bash_completion.bash
Expand Up @@ -20,14 +20,12 @@ _lein_completion() {
;;
test | retest )
# list project's test namespaces:
local namespaces=$(find test/ -type f -name "*.clj" -exec grep -E \
'^\(ns[[:space:]]+\w+' '{}' ';' | sed -n 's/(ns[ ]*//p')
local namespaces=$(find test/ -type f -name "*.clj" -exec sed -n 's/^(ns[ ]*//p' '{}' '+')
COMPREPLY=( $(compgen -W "${namespaces}" -- ${cur}) )
;;
run | compile)
# list project's src namespaces:
local namespaces=$(find src/ -type f -name "*.clj" -exec grep -E \
'^\(ns[[:space:]]+\w+' '{}' ';' | sed -n 's/(ns[ ]*//p')
local namespaces=$(find src/ -type f -name "*.clj" -exec sed -n 's/^(ns[ ]*//p' '{}' '+')
COMPREPLY=( $(compgen -W "${namespaces}" -- ${cur}) )
;;
lein)
Expand Down
13 changes: 9 additions & 4 deletions bin/lein
Expand Up @@ -27,12 +27,13 @@ do
done

export LEIN_HOME=${LEIN_HOME:-"$HOME/.lein"}
LEIN_JAR="$LEIN_HOME/self-installs/leiningen-$LEIN_VERSION-standalone.jar"

if [ "$OSTYPE" = "cygwin" ]; then
LEIN_HOME=`cygpath -w $LEIN_HOME`
export LEIN_HOME=`cygpath -w $LEIN_HOME`
fi

LEIN_JAR="$LEIN_HOME/self-installs/leiningen-$LEIN_VERSION-standalone.jar"

# normalize $0 on certain BSDs
if [ "$(dirname "$0")" = "." ]; then
SCRIPT="$(which $(basename "$0"))"
Expand Down Expand Up @@ -80,8 +81,9 @@ if [ -r "$BIN_DIR/../src/leiningen/version.clj" ]; then
ORIG_PWD="$PWD"
cd "$LEIN_DIR"

$0 classpath .lein-classpath
sum $LEIN_DIR/project.clj $LEIN_DIR/leiningen-core/project.clj > .lein-project-checksum
$0 classpath .lein-classpath
sum $LEIN_DIR/project.clj $LEIN_DIR/leiningen-core/project.clj > \
.lein-project-checksum
cd "$ORIG_PWD"
fi

Expand All @@ -92,6 +94,9 @@ if [ -r "$BIN_DIR/../src/leiningen/version.clj" ]; then
CLASSPATH="$CLASSPATH:$LEIN_DIR/leiningen-core/lib/*"
CLASSPATH="$CLASSPATH:$LEIN_DIR/test:$LEIN_DIR/target/classes"
CLASSPATH="$CLASSPATH:$LEIN_DIR/src:$LEIN_DIR/resources:$LEIN_JAR"
if [ -f .lein-classpath ]; then
CLASSPATH="`cat .lein-classpath`:$CLASSPATH"
fi
else # Not running from a checkout
# apply context specific CLASSPATH entries
if [ -f .lein-classpath ]; then
Expand Down
47 changes: 26 additions & 21 deletions bin/lein.bat 100644 → 100755
@@ -1,6 +1,6 @@
@echo off

set LEIN_VERSION=2.0.0-preview3
set LEIN_VERSION=2.0.0-SNAPSHOT

setLocal EnableExtensions EnableDelayedExpansion

Expand All @@ -24,34 +24,38 @@ if "x%LEIN_HOME%" == "x" (
set LEIN_HOME=%USERPROFILE%\.lein
)

if "x%LEIN_JAR%" == "x" set LEIN_JAR="!LEIN_HOME!\self-installs\leiningen-!LEIN_VERSION!-standalone.jar"
if "x%LEIN_JAR%" == "x" set LEIN_JAR=!LEIN_HOME!\self-installs\leiningen-!LEIN_VERSION!-standalone.jar

if "%1" == "self-install" goto SELF_INSTALL
if "%1" == "upgrade" goto NO_UPGRADE

:: Apply context specific CLASSPATH entries
set CONTEXT_CP=
if exist ".lein-classpath" set /P CONTEXT_CP=<.lein-classpath
if NOT "%CONTEXT_CP%"=="" set CLASSPATH="%CONTEXT_CP%";%CLASSPATH%

if exist "%~f0\..\..\src\leiningen\core.clj" (
if exist "%~dp0..\src\leiningen" (
:: Running from source checkout.
call :SET_LEIN_ROOT "%~f0\..\.."
call :SET_LEIN_ROOT "%~dp0.."

set LEIN_LIBS=
for %%j in ("!LEIN_ROOT!\leiningen-core\lib\*") do set LEIN_LIBS=!LEIN_LIBS!%%~fj;
set LEIN_LIBS=!LEIN_LIBS!

if "x!LEIN_LIBS!" == "x" goto NO_DEPENDENCIES

set LEIN_LIBS="
for %%j in ("!LEIN_ROOT!\lib\*") do set LEIN_LIBS=!LEIN_LIBS!;%%~fj
set LEIN_LIBS=!LEIN_LIBS!"
set CLASSPATH=!LEIN_LIBS!!LEIN_ROOT!\leiningen-core\src;!LEIN_ROOT!\leiningen-core\test;!LEIN_ROOT!\src;!LEIN_ROOT!\resources

if "x!LEIN_LIBS!" == "x" if not exist %LEIN_JAR% goto NO_DEPENDENCIES
:: Apply context specific CLASSPATH entries
if exist %~dp0..\.lein-classpath (
set /P CONTEXT_CP=< %~dp0..\.lein-classpath

set CLASSPATH=%CONTEXT_CP%;!LEIN_LIBS!;"!LEIN_ROOT!\src";"!LEIN_ROOT!\resources";%LEIN_JAR%
if NOT "x!CONTEXT_CP!"=="x" (
set CLASSPATH=!CONTEXT_CP!;!CLASSPATH!
)
)
) else (
:: Not running from a checkout.
if not exist %LEIN_JAR% goto NO_LEIN_JAR
set CLASSPATH=%CONTEXT_CP%;%LEIN_JAR%
if not exist "%LEIN_JAR%" goto NO_LEIN_JAR
set CLASSPATH=%LEIN_JAR%
)

if not "x%DEBUG%" == "x" echo CLASSPATH=%CLASSPATH%
if not "x%DEBUG%" == "x" echo CLASSPATH=!CLASSPATH!
:: ##################################################


Expand All @@ -77,11 +81,12 @@ echo.
goto EOF

:SELF_INSTALL
if exist %LEIN_JAR% (
if exist "%LEIN_JAR%" (
echo %LEIN_JAR% already exists. Delete and retry.
goto EOF
)
for %%f in (%LEIN_JAR%) do set LEIN_INSTALL_DIR="%%~dpf"

for %%f in ("%LEIN_JAR%") do set LEIN_INSTALL_DIR="%%~dpf"
if not exist %LEIN_INSTALL_DIR% mkdir %LEIN_INSTALL_DIR%

echo Downloading Leiningen now...
Expand All @@ -95,7 +100,7 @@ if ERRORLEVEL 9009 (
)
:: set LEIN_JAR_URL=https://github.com/downloads/technomancy/leiningen/leiningen-%LEIN_VERSION%-standalone.jar
set LEIN_JAR_URL=https://cloud.github.com/downloads/technomancy/leiningen/leiningen-%LEIN_VERSION%-standalone.jar
%HTTP_CLIENT% %LEIN_JAR% %LEIN_JAR_URL%
%HTTP_CLIENT% "%LEIN_JAR%" %LEIN_JAR_URL%
if ERRORLEVEL 1 (
del %LEIN_JAR%>nul 2>&1
goto DOWNLOAD_FAILED
Expand Down Expand Up @@ -184,7 +189,7 @@ del "%TRAMPOLINE_FILE%"
goto EOF

:RUN_NORMAL
%JAVA_CMD% -client %LEIN_JVM_OPTS% -Xbootclasspath/a:"%CLOJURE_JAR%" ^
%JAVA_CMD% -client %LEIN_JVM_OPTS% ^
-Dleiningen.original.pwd="%ORIGINAL_PWD%" ^
-cp "%CLASSPATH%" clojure.main -m leiningen.core.main %*

Expand Down
31 changes: 18 additions & 13 deletions leiningen-core/README.md
@@ -1,13 +1,12 @@
# Leiningen Core

This library provides the core functionality of Leiningen. This
consists of the task execution implementation and helper functions
without any of the tasks or launcher scripts.
consists of the task execution implementation, project configuration,
and helper functions. The built-in tasks and the launcher scripts are
kept in the main `leiningen` project.

More [copious documentation is available](http://technomancy.github.com/leiningen/).

The tasks that get run come from Leiningen itself as well as any
Leiningen plugins that may be active.
More detailed [API reference](http://leiningen.org/reference.html) is
available.

## Namespaces

Expand All @@ -23,8 +22,6 @@ Leiningen plugins that may be active.
implements the isolation of project code from Leiningen's own code.
* **leiningen.core.user** just has a handful of functions which handle
user-level configuration.
* **leiningen.core.ns** contains helper functions for finding
namespaces on the classpath.

## Running Tasks

Expand All @@ -51,11 +48,19 @@ visible to the project's functions.
Leiningen currently implements this by launching a sub-process using
`leiningen.core.eval/eval-in-project`. Any code that must execute
within the context of the project (AOT compilation, test runs, repls)
needs to go through this function. This sub-process (referred to as
the "project JVM") is an entirely new invocation of the `java` command
with its own classpath calculated from functions in the
`leiningen.core.classpath` namespace. It can only communicate with
Leiningen's process via the file system, sockets, and its exit code.
needs to go through this function. Before the process is launched, the
project must be "prepped", which consists of running all the tasks
named in the project's `:prep-tasks` key. This defaults to `javac` and
`compile`, but `defproject` or profiles may add additional tasks as
necessary. All prep tasks must be cheap to call if nothing has changed
since their last invocation.

The sub-process (referred to as the "project JVM") is an entirely new
invocation of the `java` command with its own classpath calculated
from functions in the `leiningen.core.classpath` namespace. It can
even use a different version of the JVM from Leiningen if the
`:java-cmd` key is provided. It can only communicate with Leiningen's
process via the file system, sockets, and its exit code.

The exception to this rule is when `:eval-in-leiningen` in
`project.clj` is true, as is commonly used for Leiningen plugins.
Expand Down

0 comments on commit 052c2d0

Please sign in to comment.