Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update lein-pkg.

  • Loading branch information...
commit 1e4180148f9f21f0a8ccb0ed562dc118f6006938 1 parent d736a52
Phil Hagelberg authored
Showing with 70 additions and 84 deletions.
  1. +69 −84 bin/lein-pkg
  2. +1 −0  src/leiningen/jar.clj
153 bin/lein-pkg
View
@@ -2,12 +2,9 @@
# This variant of the lein script is meant for downstream packagers.
# It has all the cross-platform stuff stripped out as well as the
-# logic for running from checkouts and self-upgrading.
+# logic for running from a source checkout and self-install/upgrading.
-# It has not yet been updated for lein2
-
-LEIN_VERSION="1.6.2"
-export LEIN_VERSION
+export LEIN_VERSION="2.0.0-SNAPSHOT"
if [ `whoami` = "root" ] && [ "$LEIN_ROOT" = "" ]; then
echo "WARNING: You're currently running as root; probably by accident."
@@ -31,102 +28,90 @@ done
JVM_OPTS=${JVM_OPTS:-"$JAVA_OPTS"}
JAVA_CMD=${JAVA_CMD:-"java"}
-if [ "$LEIN_HOME" = "" ]; then
- if [ -d "$PWD/.lein" ] && [ "$PWD" != "$HOME" ]; then
- echo "Leiningen is running in bundled mode."
- LEIN_HOME="$PWD/.lein"
- else
- LEIN_HOME="$HOME/.lein"
- fi
-fi
-
-DEV_PLUGINS="$(ls -1 lib/dev/*jar 2> /dev/null)"
-USER_PLUGINS="$(ls -1 "$LEIN_HOME"/plugins/*jar 2> /dev/null)"
+# User init
+export LEIN_HOME="${LEIN_HOME:-"$HOME/.lein"}"
-artifact_name () {
- echo "$1" | sed -e "s/.*\/\(.*\)/\1/" | \
- rev | sed -e "s/raj[-[:digit:].]*-\(.*\)/\1/" | rev
-}
+for f in "$LEIN_HOME/leinrc" ".leinrc"; do
+ if [ -e "$f" ]; then
+ source "$f"
+ fi
+done
-unique_user_plugins () {
- saveIFS="$IFS"
- IFS="$(printf '\n\t')"
+grep -E -q '^\s*:eval-in\s+:classloader\s*$' project.clj 2> /dev/null &&
+LEIN_JVM_OPTS="${LEIN_JVM_OPTS:-'-Xms64m -Xmx512m'}"
- plugins="$(echo "$DEV_PLUGINS"; echo "$USER_PLUGINS")"
- artifacts="$(for i in $plugins; do echo "$(artifact_name "$i")"; done)"
- duplicates="$(echo "$artifacts" | sort | uniq -d)"
+# If you're not using an uberjar you'll need to list each dependency
+# and add them individually to the classpath/bootclasspath as well.
- if [ -z "$duplicates" ]; then
- echo "$USER_PLUGINS"
- else
- for i in $USER_PLUGINS; do
- artifact="$(artifact_name "$i")"
- if ! echo "$duplicates" | grep -xq "$artifact"; then
- echo "$i"
- fi
- done
- fi
- IFS="$saveIFS"
-}
+LEIN_JAR=/usr/share/java/leiningen-$LEIN_VERSION-standalone.jar
-LEIN_PLUGIN_PATH="$(echo "$DEV_PLUGINS" | tr \\n :)"
-LEIN_USER_PLUGIN_PATH="$(echo "$(unique_user_plugins)" | tr \\n :)"
-CLASSPATH="$CLASSPATH:$LEIN_PLUGIN_PATH:$LEIN_USER_PLUGIN_PATH:test/:src/:resources/"
-CLOJURE_JAR="/usr/share/java/clojure-1.2.jar:/usr/share/java/asm3.jar:/usr/share/java/asm3-commons.jar"
-NULL_DEVICE=/dev/null
+# Do not use installed leiningen jar during self-compilation
+if ! { [ "$1" = "compile" ] &&
+ grep -qsE 'defproject leiningen[[:space:]]+"[[:digit:].]+"' \
+ project.clj ;}; then
+ CLASSPATH="$CLASSPATH":"$LEIN_JAR"
+ BOOTCLASSPATH="-Xbootclasspath/a:$LEIN_JAR"
+fi
# apply context specific CLASSPATH entries
if [ -f .lein-classpath ]; then
CLASSPATH="`cat .lein-classpath`:$CLASSPATH"
fi
-SHARE_JARS="ant ant-launcher classworlds clojure-1.2 clojure-contrib \
-lucene-memory maven-ant-tasks maven-artifact maven-artifact-manager \
-maven-error-diagnostics maven-model maven-settings maven-project maven-profile \
-maven-repository-metadata plexus-container-default-alpha plexus-interpolation \
-plexus-utils wagon-file wagon-http-lightweight wagon-http-shared wagon-provider-api \
-xml-apis lucene-core lucene-highlighter clucy robert-hooke lancet \
-backport-util-concurrent" # NFI why that last one is necessary
-for JAR in $SHARE_JARS; do
- CLASSPATH="$CLASSPATH":"/usr/share/java/$JAR.jar"
-done
-
-# Do not use installed leiningen jar during self-compilation
-if ! { [ "$1" = "compile" ] &&
- grep -qsE 'defproject leiningen[[:space:]]+"[[:digit:].]+"' \
- project.clj ;}; then
- CLASSPATH="$CLASSPATH":/usr/share/java/leiningen-$LEIN_VERSION.jar
+if [ $DEBUG ]; then
+ echo "Leiningen's classpath: $CLASSPATH"
fi
-if [ $DEBUG ]; then
- echo $CLASSPATH
- echo $CLOJURE_JAR
+# Which Java?
+
+export JAVA_CMD="${JAVA_CMD:-"java"}"
+export LEIN_JAVA_CMD="${LEIN_JAVA_CMD:-$JAVA_CMD}"
+
+if [[ "$(basename "$LEIN_JAVA_CMD")" == *drip* ]]; then
+ export DRIP_INIT="$(printf -- '-e\n(require (quote leiningen.repl))')"
fi
-# Use rlwrap if appropriate
-if ([ "$1" = "repl" ] || [ "$1" = "interactive" ] || [ "$1" = "int" ]) &&
- [ -z $INSIDE_EMACS ] && [ "$TERM" != "dumb" ]; then
- which rlwrap > /dev/null
- if [ $? -eq 0 ]; then
- RLWRAP="rlwrap -r -m -q '\"'" # custom quote chars
- fi
+# Support $JAVA_OPTS for backwards-compatibility.
+export JVM_OPTS="${JVM_OPTS:-"$JAVA_OPTS"}"
+
+if ([ "$LEIN_FAST_TRAMPOLINE" != "" ] || [ -r .lein-fast-trampoline ]) &&
+ [ -r project.clj ]; then
+ INPUTS="$@ $(cat project.clj) $(cat "$LEIN_HOME/profiles.clj")"
+ INPUT_CHECKSUM=$(echo $INPUTS | shasum - | cut -f 1 -d " ")
+ # Just don't change :target-path in project.clj, mkay?
+ TRAMPOLINE_FILE="target/trampolines/$INPUT_CHECKSUM"
+else
+ TRAMPOLINE_FILE="/tmp/lein-trampoline-$$"
+ trap "rm -f $TRAMPOLINE_FILE" EXIT
fi
-if [ "$1" = "trampoline" ]; then
- TRAMPOLINE_FILE="/tmp/lein-trampoline-$$"
- $JAVA_CMD -Xbootclasspath/a:"$CLOJURE_JAR" -client $LEIN_JVM_OPTS \
- -Dleiningen.original.pwd="$ORIGINAL_PWD" \
- -Dleiningen.trampoline-file=$TRAMPOLINE_FILE -cp "$CLASSPATH" \
- clojure.main -e "(use 'leiningen.core)(-main)" \
- $NULL_DEVICE "$@"
- if [ -r $TRAMPOLINE_FILE ]; then
- TRAMPOLINE="$(cat $TRAMPOLINE_FILE)"
+if [ "$INPUT_CHECKSUM" != "" ] && [ -r "$TRAMPOLINE_FILE" ]; then
+ if [ $DEBUG ]; then
+ echo "Fast trampoline with $TRAMPOLINE_FILE."
+ fi
+ exec sh -c "exec $(cat $TRAMPOLINE_FILE)"
+else
+ export TRAMPOLINE_FILE
+ "$LEIN_JAVA_CMD" \
+ -client -XX:+TieredCompilation \
+ "${BOOTCLASSPATH[@]}" \
+ $LEIN_JVM_OPTS \
+ -Dfile.encoding=UTF-8 \
+ -Dmaven.wagon.http.ssl.easy=false \
+ -Dleiningen.original.pwd="$ORIGINAL_PWD" \
+ -Dleiningen.script="$0" \
+ -classpath "$CLASSPATH" \
+ clojure.main -m leiningen.core.main "$@"
+
+ EXIT_CODE=$?
+
+ if [ -r "$TRAMPOLINE_FILE" ] && [ "$LEIN_TRAMPOLINE_WARMUP" = "" ]; then
+ TRAMPOLINE="$(cat $TRAMPOLINE_FILE)"
+ if [ "$INPUT_CHECKSUM" = "" ]; then
rm $TRAMPOLINE_FILE
- exec sh -c "$TRAMPOLINE"
fi
-else
- exec $RLWRAP $JAVA_CMD -Xbootclasspath/a:"$CLOJURE_JAR" -client \
- $LEIN_JVM_OPTS -Dleiningen.original.pwd="$ORIGINAL_PWD" \
- -cp "$CLASSPATH" clojure.main -m leiningen.main \
- $NULL_DEVICE "$@"
+ exec sh -c "exec $TRAMPOLINE"
+ else
+ exit $EXIT_CODE
+ fi
fi
1  src/leiningen/jar.clj
View
@@ -90,6 +90,7 @@
(JarOutputStream. (make-manifest project)))]
(reduce (partial copy-to-jar project jar-os) #{} filespecs)))
+;; TODO: change in 3.0; this is hideous
(defn- filespecs [project deps-fileset]
(concat [{:type :bytes
:path (format "META-INF/maven/%s/%s/pom.xml"
Please sign in to comment.
Something went wrong with that request. Please try again.