Skip to content

Commit

Permalink
The executable jar, cljr.jar, that is installed in ~/.cljr now initia…
Browse files Browse the repository at this point in the history
…lizes its own classpath when run directly (i.e. java -jar cljr.jar repl) and can be used as an alternative to the cljr scripts in the bin directory.
  • Loading branch information
liebke committed Jul 10, 2010
1 parent ee7c257 commit 57cab91
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 24 deletions.
8 changes: 6 additions & 2 deletions README.textile
Expand Up @@ -30,6 +30,10 @@ h2. Quick start
# Run @cljr repl@ or @cljr swingrepl@ to launch a REPL configured for all the installed packages.


You can also use the executable jar, cljr.jar, installed in ~/.cljr to run commands:
* @java -jar ~/.cljr/cljr.jar list@
* @java -jar ~/.cljr/cljr.jar repl@


h2. Documentation

Expand Down Expand Up @@ -98,9 +102,9 @@ and either double-click on the jar file to run it from the command line:
*Alternative installation directories*
You can provide alternative CLJR_HOME and USER_HOME directories by passing them as properties to the above java command.

For instance, the following command creates the @.cljr@ and Maven @.m2@ directories under @C:\@ on a Windows box (something I had to do since Windows had problems with my shared home under VMWare, \\vmware-host\...).
For instance, the following command creates the @.cljr@ and Maven @.m2@ directories under @C:@ on a Windows box (something I had to do since Windows had problems with my shared home under VMWare, \\vmware-host\...).

@java -Duser.home=C:\ -jar cljr-installer.jar@
@java -Duser.home=C: -jar cljr-installer.jar@


*cljr scripts*
Expand Down
2 changes: 1 addition & 1 deletion installer/project.clj
Expand Up @@ -3,4 +3,4 @@
:dependencies [[cljr "1.0.0-SNAPSHOT"]]
; :jar-name "cljr-only.jar" ; name of the jar produced by 'lein jar'
; :uberjar-name "cljr-installer.jar" ; as above for uberjar
:main cljr.installer)
:main cljr.repl)
@@ -1,4 +1,4 @@
(ns cljr.installer
(ns cljr.repl
(:require cljr.main)
(:gen-class))

Expand Down
4 changes: 2 additions & 2 deletions script/install
Expand Up @@ -5,6 +5,6 @@ mvn install
cd installer
lein clean && lein deps && lein uberjar
# for new version of lein
#java -jar cljr-installer-1.0.0-SNAPSHOT-standalone.jar
java -jar cljr-installer-1.0.0-SNAPSHOT-standalone.jar
# for old version of lein
java -jar cljr-installer-standalone.jar
#java -jar cljr-installer-standalone.jar
11 changes: 8 additions & 3 deletions src/main/resources/cljr/core.clj
Expand Up @@ -143,12 +143,17 @@
(seq (.listFiles (file clojure-home)))))))


(defn include-cljr-repo-jars? []
(not= "false" (System/getProperty "include.cljr.repo.jars")))


(defn full-classpath []
(let [cljr-repo (file (get-cljr-home) "lib")
additional-paths (get-classpath-urls (get-classpath-vector))
clojure-home-jars (get-clojure-home-jars)
jar-files nil ;;(seq (.listFiles cljr-repo))
]
clojure-home-jars (when (include-cljr-repo-jars?)
(get-clojure-home-jars))
jar-files (when (include-cljr-repo-jars?)
(seq (.listFiles cljr-repo)))]
(filter identity (flatten (conj clojure-home-jars jar-files additional-paths)))))


Expand Down
31 changes: 16 additions & 15 deletions src/main/resources/cljr/scripts.clj
Expand Up @@ -14,33 +14,34 @@
"CLJR_HOME=\"" (get-cljr-home) "\"\n"
"CLASSPATH=src" (cygwin-safe-path-sep) "test" (cygwin-safe-path-sep) ".\n\n"

" if [ ! -n \"$JVM_OPTS\" ]; then\n\n"
" if [ ! -n \"$JVM_OPTS\" ]; then\n"
" JVM_OPTS=\"-Xmx1G\"\n"
" fi\n\n"

" if [ \"$DISABLE_JLINE\" = \"true\" ]; then\n\n"
" if [ \"$DISABLE_JLINE\" = \"true\" ]; then\n"
" JLINE=\"\"\n"
" else\n"
" JLINE=\"jline.ConsoleRunner\"\n"
" fi\n\n"

"if [ \"$1\" = \"repl\" -o \"$1\" = \"swingrepl\" -o \"$1\" = \"swank\" -o \"$1\" = \"run\" ]; then\n\n"
" if [ -n \"$CLOJURE_HOME\" ]; then\n\n"
"if [ \"$1\" = \"repl\" -o \"$1\" = \"swingrepl\" -o \"$1\" = \"swank\" -o \"$1\" = \"run\" ]; then\n"
" if [ -n \"$CLOJURE_HOME\" ]; then\n"
" for f in \"$CLOJURE_HOME\"/*.jar; do\n"
" CLASSPATH=\"$CLASSPATH\"" (cygwin-safe-path-sep) "$f\n\n"
" done\n\n"
" fi\n\n"
" CLASSPATH=\"$CLASSPATH\"" (cygwin-safe-path-sep) "$f\n"
" done\n"
" fi\n"
" for f in \"$CLJR_HOME\"/lib/*.jar; do\n"
" CLASSPATH=\"$CLASSPATH\"" (cygwin-safe-path-sep) "$f\n"
" done\n\n"
"else\n\n"
" CLASSPATH=\"$CLASSPATH\"" (cygwin-safe-path-sep) "\"$CLJR_HOME\"/cljr.jar\n\n"
"fi\n\n"

"if [ \"$1\" = \"repl\" ]; then\n"
" java $JVM_OPTS -Duser.home=\"$USER_HOME\" -Dclojure.home=\"$CLOJURE_HOME\" -Dcljr.home=\"$CLJR_HOME\" -cp \"$CLASSPATH\" $JLINE clojure.main -e \"(require 'cljr.main) (cljr.main/initialize-classpath)\" -r\n\n"
"else\n\n"
" java $JVM_OPTS -Duser.home=\"$USER_HOME\" -Dclojure.home=\"$CLOJURE_HOME\" -Dcljr.home=\"$CLJR_HOME\" -cp \"$CLASSPATH\" cljr.App $*\n\n"
" if [ \"$1\" = \"repl\" ]; then\n"
" java $JVM_OPTS -Dinclude.cljr.repo.jars=false -Duser.home=\"$USER_HOME\" -Dclojure.home=\"$CLOJURE_HOME\" -Dcljr.home=\"$CLJR_HOME\" -cp \"$CLASSPATH\" $JLINE clojure.main -e \"(require 'cljr.main) (cljr.main/initialize-classpath)\" -r\n"
" else\n"
" java $JVM_OPTS -Dinclude.cljr.repo.jars=false -Duser.home=\"$USER_HOME\" -Dclojure.home=\"$CLOJURE_HOME\" -Dcljr.home=\"$CLJR_HOME\" -cp \"$CLASSPATH\" cljr.App $*\n"
" fi\n"
"else\n"
" CLASSPATH=\"$CLASSPATH\"" (cygwin-safe-path-sep) "\"$CLJR_HOME\"/cljr.jar\n"
" java $JVM_OPTS -Duser.home=\"$USER_HOME\" -Dclojure.home=\"$CLOJURE_HOME\" -Dcljr.home=\"$CLJR_HOME\" -cp \"$CLASSPATH\" cljr.App $*\n"
"fi\n\n")))


Expand Down Expand Up @@ -88,7 +89,7 @@
"goto EOF\r\n\r\n"

":LAUNCH\r\n"
" java %JVM_OPTS% -Dcljr.home=" (get-cljr-home) " -Duser.home=" (get-user-home) " -Dclojure.home=%CLOJURE_HOME% -cp \"%CLASSPATH%\" cljr.App %*\r\n"
" java %JVM_OPTS% -Dinclude.cljr.repo.jars=false -Dcljr.home=" (get-cljr-home) " -Duser.home=" (get-user-home) " -Dclojure.home=%CLOJURE_HOME% -cp \"%CLASSPATH%\" cljr.App %*\r\n"
"goto EOF\r\n\r\n"

":EOF\r\n")))

0 comments on commit 57cab91

Please sign in to comment.