Skip to content

Commit

Permalink
Upgrade to Clojure 1.2.0-master-SNAPSHOT.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Apr 17, 2010
1 parent d3b479d commit e886afb
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 54 deletions.
2 changes: 1 addition & 1 deletion bin/lein
Expand Up @@ -4,7 +4,7 @@ VERSION="1.2.0-SNAPSHOT"

CLASSPATH=src/:"$(find lib/ -follow -mindepth 1 -maxdepth 1 -print0 2> /dev/null | tr \\0 \:)":$CLASSPATH
LEIN_JAR="$HOME/.m2/repository/leiningen/leiningen/$VERSION/leiningen-$VERSION-standalone.jar"
CLOJURE_JAR="$HOME/.m2/repository/org/clojure/clojure/1.1.0/clojure-1.1.0.jar"
CLOJURE_JAR="$HOME/.m2/repository/org/clojure/clojure/1.2.0-master-SNAPSHOT/clojure-1.2.0-master-SNAPSHOT.jar"

# normalize $0 on certain BSDs
if [ "$(dirname $0)" = "." ]; then
Expand Down
6 changes: 3 additions & 3 deletions project.clj
Expand Up @@ -5,9 +5,9 @@
(defproject leiningen "1.2.0-SNAPSHOT"
:description "A build tool designed not to set your hair on fire."
:url "http://github.com/technomancy/leiningen"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]
[ant/ant "1.7.0"]
:dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]
[org.apache.ant/ant "1.7.0"]
[jline "0.9.94"]
[org.apache.maven/maven-ant-tasks "2.1.0"]]
:dev-dependencies [[leiningen/lein-swank "1.1.0"]
Expand Down
14 changes: 5 additions & 9 deletions src/lancet.clj
@@ -1,8 +1,5 @@
(ns lancet
(:gen-class)
(:use [clojure.contrib.except :only (throw-if)]
clojure.contrib.shell-out
[clojure.contrib.str-utils :only (re-split)])
(:import (java.beans Introspector) (java.util.concurrent CountDownLatch)))

(defmulti coerce (fn [dest-class src-inst] [dest-class (class src-inst)]))
Expand All @@ -17,10 +14,7 @@
(System/getenv (name val)))

(defn- build-sh-args [args]
(concat (re-split #"\s+" (first args)) (rest args)))

(defn system [& args]
(println (apply sh (build-sh-args args))))
(concat (.split (first args) " +") (rest args)))

(def
#^{:doc "Dummy ant project to keep Ant tasks happy"}
Expand All @@ -46,7 +40,8 @@

(defn set-property! [inst prop value]
(let [pd (property-descriptor inst prop)]
(throw-if (nil? pd) (str "No such property " prop))
(when-not pd
(throw (Exception. (format "No such property %s." prop))))
(let [write-method (.getWriteMethod pd)
dest-class (get-property-class write-method)]
(.invoke write-method inst (into-array [(coerce dest-class value)])))))
Expand All @@ -56,7 +51,8 @@

(defn instantiate-task [project name props & filesets]
(let [task (.createTask project name)]
(throw-if (nil? task) (str "No task named " name))
(when-not task
(throw (Exception. (format "No task named %s." name))))
(doto task
(.init)
(.setProject project)
Expand Down
2 changes: 1 addition & 1 deletion src/leiningen/checkout_deps.clj
@@ -1,6 +1,6 @@
(ns leiningen.checkout-deps
(:use [leiningen.core :only [read-project]]
[clojure.contrib.java-utils :only [file]]))
[clojure.contrib.io :only [file]]))

(defn checkout-deps-paths [project]
(apply concat (for [dep (.listFiles (file (:root project) "checkouts"))]
Expand Down
8 changes: 4 additions & 4 deletions src/leiningen/classpath.clj
@@ -1,7 +1,7 @@
(ns leiningen.classpath
(:use (clojure.contrib [java-utils :only (file)]
[seq-utils :only (flatten)]
[str-utils :only (str-join)]))
(:use (clojure.contrib [io :only (file)]
[seq :only (flatten)]
[string :only (join)]))
(:import org.apache.tools.ant.types.Path))

(defn find-lib-jars
Expand Down Expand Up @@ -31,4 +31,4 @@
"Print out the classpath in which the project operates, within the
current directory, in a format suitable for the -classpath option."
[project]
(println (str-join java.io.File/pathSeparatorChar (get-classpath project))))
(println (join java.io.File/pathSeparatorChar (get-classpath project))))
3 changes: 1 addition & 2 deletions src/leiningen/clean.clj
@@ -1,7 +1,6 @@
(ns leiningen.clean
"Remove compiled files and dependencies from project."
(:use [clojure.contrib.java-utils :only [file delete-file
delete-file-recursively]]))
(:use [clojure.contrib.io :only [file delete-file delete-file-recursively]]))

(defn empty-directory
"Recursively delete all the files in f, but not f itself.
Expand Down
2 changes: 1 addition & 1 deletion src/leiningen/compile.clj
Expand Up @@ -5,7 +5,7 @@
[leiningen.checkout-deps :only [checkout-deps-paths]]
[leiningen.core :only [ns->path]]
[leiningen.classpath :only [make-path find-lib-jars get-classpath]]
[clojure.contrib.java-utils :only [file]]
[clojure.contrib.io :only [file]]
[clojure.contrib.find-namespaces :only [find-namespaces-in-dir]])
(:refer-clojure :exclude [compile])
(:import org.apache.tools.ant.taskdefs.Java
Expand Down
7 changes: 5 additions & 2 deletions src/leiningen/deps.clj
Expand Up @@ -2,7 +2,7 @@
"Install jars for all dependencies in lib."
(:require [lancet])
(:use [leiningen.pom :only [default-repos make-dependency]]
[clojure.contrib.java-utils :only [file]])
[clojure.contrib.io :only [file]])
(:import [org.apache.maven.artifact.ant DependenciesTask RemoteRepository]
[org.apache.tools.ant.util FlatFileNameMapper]))

Expand Down Expand Up @@ -70,10 +70,13 @@ dependencies with the following:
(when-not skip-dev
(doseq [dep (:dev-dependencies project)]
(.addDependency deps-task (make-dependency dep))))
;; TODO: this is starting a rogue thread keeping the JVM from exiting
(.execute deps-task)
(.mkdirs (file (:library-path project)))
(copy-dependencies (:jar-behavior project)
(:library-path project) true
(.getReference lancet/ant-project
(.getFilesetId deps-task)))))
(.getFilesetId deps-task)))
(println (format "Copied dependencies into %s."
(:library-path project)))))
([project] (deps project false)))
2 changes: 1 addition & 1 deletion src/leiningen/install.clj
Expand Up @@ -2,7 +2,7 @@
"Install the project and its dependencies in your local repository."
(:use [leiningen.jar :only [jar]]
[leiningen.pom :only [pom make-model]]
[clojure.contrib.java-utils :only [file]])
[clojure.contrib.io :only [file]])
(:import [org.apache.maven.artifact.installer ArtifactInstaller]
[org.apache.maven.project.artifact ProjectArtifactMetadata]
[org.apache.maven.settings MavenSettingsBuilder]
Expand Down
21 changes: 10 additions & 11 deletions src/leiningen/jar.clj
Expand Up @@ -2,9 +2,8 @@
"Create a jar containing the compiled code and original source."
(:require [leiningen.compile :as compile])
(:use [leiningen.pom :only [make-pom make-pom-properties]]
[clojure.contrib.duck-streams :only [to-byte-array copy]]
[clojure.contrib.str-utils :only [str-join re-sub]]
[clojure.contrib.java-utils :only [file]])
[clojure.contrib.io :only [to-byte-array copy file]]
[clojure.contrib.string :only [join replace-re]])
(:import [java.util.jar Manifest JarEntry JarOutputStream]
[java.util.regex Pattern]
[java.io BufferedOutputStream FileOutputStream
Expand All @@ -14,13 +13,13 @@
(Manifest.
(ByteArrayInputStream.
(to-byte-array
(str (str-join "\n"
["Manifest-Version: 1.0" ; DO NOT REMOVE!
"Created-By: Leiningen"
(str "Built-By: " (System/getProperty "user.name"))
(str "Build-Jdk: " (System/getProperty "java.version"))
(when-let [main (:main project)]
(str "Main-Class: " (.replaceAll (str main) "-" "_")))])
(str (join "\n"
["Manifest-Version: 1.0" ; DO NOT REMOVE!
"Created-By: Leiningen"
(str "Built-By: " (System/getProperty "user.name"))
(str "Build-Jdk: " (System/getProperty "java.version"))
(when-let [main (:main project)]
(str "Main-Class: " (.replaceAll (str main) "-" "_")))])
"\n")))))

(defn unix-path [path]
Expand All @@ -34,7 +33,7 @@
(defmulti copy-to-jar (fn [project jar-os spec] (:type spec)))

(defn- trim-leading-str [s to-trim]
(re-sub (re-pattern (str "^" (Pattern/quote to-trim))) "" s))
(replace-re (re-pattern (str "^" (Pattern/quote to-trim))) "" s))

(defmethod copy-to-jar :path [project jar-os spec]
(let [root (str (unix-path (:root project)) \/)
Expand Down
9 changes: 4 additions & 5 deletions src/leiningen/new.clj
Expand Up @@ -4,9 +4,8 @@ lein new [group-id/]artifact-id [project-dir]
Group-id is optional. Project-dir defaults to artifact-id if not given.
Neither group-id nor artifact-id may contain slashes."
(:use [leiningen.core :only [ns->path]]
[clojure.contrib.duck-streams :only [spit]]
[clojure.contrib.java-utils :only [file]]
[clojure.contrib.str-utils :only [str-join]]))
[clojure.contrib.io :only [spit file]]
[clojure.contrib.string :only [join]]))

(defn new
([project-name project-dir]
Expand All @@ -33,9 +32,9 @@ Neither group-id nor artifact-id may contain slashes."
"\n (:use [clojure.test]))\n\n"
"(deftest replace-me ;; FIXME: write\n (is false))\n"))
(spit (file project-dir ".gitignore")
(str-join "\n" ["pom.xml" "*jar" "lib" "classes"]))
(join "\n" ["pom.xml" "*jar" "lib" "classes"]))
(spit (file project-dir "README")
(str-join "\n\n" [(str "# " artifact-id)
(join "\n\n" [(str "# " artifact-id)
"FIXME: write description"
"## Usage" "FIXME: write"
"## Installation" "FIXME: write"
Expand Down
4 changes: 2 additions & 2 deletions src/leiningen/pom.clj
@@ -1,7 +1,7 @@
(ns leiningen.pom
"Write a pom.xml file to disk for Maven interop."
(:use [clojure.contrib.duck-streams :only [reader copy]]
[clojure.contrib.java-utils :only [file as-properties]])
(:use [clojure.contrib.io :only [reader copy file]]
[clojure.contrib.properties :only [as-properties]])
(:import [java.io StringWriter ByteArrayOutputStream]
[org.apache.maven.model Build Model Parent Dependency
Exclusion Repository Scm]
Expand Down
2 changes: 1 addition & 1 deletion src/leiningen/test.clj
@@ -1,7 +1,7 @@
(ns leiningen.test
"Run the project's tests."
(:refer-clojure :exclude [test])
(:use [clojure.contrib.java-utils :only [file]]
(:use [clojure.contrib.io :only [file]]
[clojure.contrib.find-namespaces :only [find-namespaces-in-dir]]
[leiningen.compile :only [eval-in-project]]))

Expand Down
3 changes: 1 addition & 2 deletions src/leiningen/uberjar.clj
Expand Up @@ -2,8 +2,7 @@
"Create a jar containing the compiled code, source, and all dependencies."
(:require [clojure.xml :as xml])
(:use [clojure.zip :only [xml-zip]]
[clojure.contrib.java-utils :only [file]]
[clojure.contrib.duck-streams :only [copy]]
[clojure.contrib.io :only [file copy]]
[clojure.contrib.zip-filter.xml :only [xml-> tag=]]
[leiningen.jar :only [jar]])
(:import [java.util.zip ZipFile ZipOutputStream ZipEntry]
Expand Down
4 changes: 2 additions & 2 deletions test/test_compile.clj
@@ -1,7 +1,7 @@
(ns test-compile
(:use [clojure.test]
[clojure.contrib.java-utils :only [delete-file-recursively file]]
[clojure.contrib.shell-out :only [with-sh-dir sh]]))
[clojure.contrib.io :only [delete-file-recursively file]]
[clojure.contrib.shell :only [with-sh-dir sh]]))

(deftest test-compile
(delete-file-recursively (file "sample" "classes" "nom") true)
Expand Down
2 changes: 1 addition & 1 deletion test/test_deps.clj
Expand Up @@ -3,7 +3,7 @@
[leiningen.deps :only [deps]] :reload-all)
(:use [clojure.test]
[clojure.contrib.set]
[clojure.contrib.java-utils :only [file delete-file-recursively]]))
[clojure.contrib.io :only [file delete-file-recursively]]))

(def test-project (read-project "sample/project.clj"))

Expand Down
4 changes: 2 additions & 2 deletions test/test_install.clj
Expand Up @@ -2,8 +2,8 @@
(:use [leiningen.core :only [read-project defproject]]
[leiningen.install] :reload-all)
(:use [clojure.test]
[clojure.contrib.java-utils :only [delete-file-recursively file]]
[clojure.contrib.shell-out :only [with-sh-dir sh]]))
[clojure.contrib.io :only [delete-file-recursively file]]
[clojure.contrib.shell :only [with-sh-dir sh]]))

(def m2-dir (file (System/getProperty "user.home") ".m2" "repository"
"nomnomnom" "nomnomnom" "0.5.0-SNAPSHOT"))
Expand Down
6 changes: 3 additions & 3 deletions test/test_new.clj
@@ -1,9 +1,9 @@
(ns test-new
(:use [clojure.test]
[clojure.contrib.java-utils :only [delete-file-recursively file]]
[clojure.contrib.shell-out :only [with-sh-dir sh]]))
[clojure.contrib.io :only [delete-file-recursively file]]
[clojure.contrib.shell :only [with-sh-dir sh]]))

(deftest test-new
(sh "lein" "new" "a.b/test-new-proj")
(is (.exists (file "test-new-proj" "src" "a" "b" "test_new_proj" "core.clj")))
(delete-file-recursively (file "test-new-proj") false))
(delete-file-recursively (file "test-new-proj") false))
2 changes: 1 addition & 1 deletion test/test_pom.clj
Expand Up @@ -2,7 +2,7 @@
(:use [leiningen.core :only [read-project defproject]]
[leiningen.pom :only [pom make-model]])
(:use [clojure.test]
[clojure.contrib.java-utils :only [file delete-file]]))
[clojure.contrib.io :only [file delete-file]]))

(def test-project (read-project "sample/project.clj"))

Expand Down

0 comments on commit e886afb

Please sign in to comment.