Reduce contrib usage. Obligatory grumbles about delete-file-recursively.
Not to mention to-byte-array being left out of clojure.java.io.
This commit is contained in:
parent
da5571ef60
commit
43331a9e72
5 changed files with 26 additions and 23 deletions
|
@ -1,7 +1,7 @@
|
|||
(ns leiningen.clean
|
||||
"Remove compiled files and dependencies from project."
|
||||
(:use [leiningen.jar :only [get-jar-filename get-default-uberjar-name]]
|
||||
[clojure.contrib.io :only [file delete-file delete-file-recursively]]))
|
||||
[leiningen.util.file :only [delete-file-recursively]]))
|
||||
|
||||
(defn clean
|
||||
"Remove compiled files and dependencies from project."
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
(:require [lancet])
|
||||
(:use [leiningen.core :only [repositories-for]]
|
||||
[leiningen.util.maven :only [make-dependency]]
|
||||
[clojure.contrib.io :only [file delete-file-recursively]])
|
||||
(:import [org.apache.maven.artifact.ant
|
||||
[leiningen.util.file :only [delete-file-recursively]])
|
||||
(:import [java.io File]
|
||||
[org.apache.maven.artifact.ant
|
||||
Authentication DependenciesTask RemoteRepository]
|
||||
[org.apache.maven.settings Server]
|
||||
[org.apache.tools.ant.util FlatFileNameMapper]))
|
||||
|
@ -40,7 +41,7 @@
|
|||
fileset)
|
||||
(doseq [f files]
|
||||
(symlink {:link destination
|
||||
:resource (.getCanonicalPath (file dir f))}))))
|
||||
:resource (.getCanonicalPath (File. dir f))}))))
|
||||
|
||||
(defn make-deps-task [project deps-set]
|
||||
(let [deps-task (DependenciesTask.)]
|
||||
|
@ -64,7 +65,7 @@ With an argument it will skip development dependencies."
|
|||
_ (.execute deps-task)
|
||||
fileset (.getReference lancet/ant-project
|
||||
(.getFilesetId deps-task))]
|
||||
(.mkdirs (file (:library-path project)))
|
||||
(.mkdirs (File. (:library-path project)))
|
||||
(copy-dependencies (:jar-behavior project)
|
||||
(:library-path project)
|
||||
true fileset)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
(ns leiningen.jar
|
||||
"Create a jar containing the compiled code and original source."
|
||||
(:require [leiningen.compile :as compile])
|
||||
(:require [leiningen.compile :as compile]
|
||||
[clojure.string :as string])
|
||||
(:use [leiningen.pom :only [make-pom make-pom-properties]]
|
||||
[leiningen.deps :only [deps]]
|
||||
[clojure.contrib.io :only [to-byte-array copy file slurp*]]
|
||||
[clojure.contrib.string :only [join replace-re split]])
|
||||
[clojure.java.io :only [copy file]]
|
||||
[clojure.contrib.string :only [join replace-re]])
|
||||
(:import [java.util.jar Manifest JarEntry JarOutputStream]
|
||||
[java.util.regex Pattern]
|
||||
[java.io BufferedOutputStream FileOutputStream
|
||||
|
@ -12,7 +13,7 @@
|
|||
|
||||
(def bin-template (-> (.getContextClassLoader (Thread/currentThread))
|
||||
(.getResourceAsStream "script-template")
|
||||
(slurp*)))
|
||||
(slurp)))
|
||||
|
||||
(defn local-repo-path
|
||||
([group name version]
|
||||
|
@ -22,7 +23,7 @@
|
|||
group name version name version)))
|
||||
|
||||
(defn- script-classpath-for [project deps-fileset]
|
||||
(join ":" (conj (for [dep (-> deps-fileset
|
||||
(string/join ":" (conj (for [dep (-> deps-fileset
|
||||
(.getDirectoryScanner lancet/ant-project)
|
||||
(.getIncludedFiles))]
|
||||
(format "$HOME/.m2/repository/%s" dep))
|
||||
|
@ -35,7 +36,7 @@
|
|||
(defn- shell-wrapper-contents [project bin-name main deps-fileset]
|
||||
(let [bin-file (file bin-name)]
|
||||
(format (if (.exists bin-file)
|
||||
(slurp* bin-file)
|
||||
(slurp bin-file)
|
||||
bin-template)
|
||||
(script-classpath-for project deps-fileset) main)))
|
||||
|
||||
|
@ -56,7 +57,7 @@
|
|||
(defn make-manifest [project & [extra-entries]]
|
||||
(Manifest.
|
||||
(ByteArrayInputStream.
|
||||
(to-byte-array
|
||||
(.getBytes
|
||||
(reduce (fn [manifest [k v]]
|
||||
(str manifest "\n" k ": " v))
|
||||
"Manifest-Version: 1.0"
|
||||
|
@ -81,7 +82,7 @@
|
|||
(defmulti copy-to-jar (fn [project jar-os spec] (:type spec)))
|
||||
|
||||
(defn- trim-leading-str [s to-trim]
|
||||
(replace-re (re-pattern (str "^" (Pattern/quote to-trim))) "" s))
|
||||
(.replaceAll s (str "^" (Pattern/quote to-trim)) ""))
|
||||
|
||||
(defmethod copy-to-jar :path [project jar-os spec]
|
||||
(let [root (str (unix-path (:root project)) \/)
|
||||
|
|
|
@ -5,7 +5,7 @@ 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.java.io :only [file]]
|
||||
[clojure.contrib.string :only [join]]))
|
||||
[clojure.string :only [join]]))
|
||||
|
||||
(defn write-project [project-dir project-name]
|
||||
(.mkdirs (file project-dir))
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
(ns leiningen.uberjar
|
||||
"Create a jar containing the compiled code, source, and all dependencies."
|
||||
(:require [clojure.xml :as xml])
|
||||
(:use [clojure.zip :only [xml-zip]]
|
||||
(:use [clojure.zip :only [xml-zip children]]
|
||||
[clojure.java.io :only [file copy]]
|
||||
[clojure.contrib.zip-filter.xml :only [xml-> tag=]]
|
||||
[leiningen.clean :only [clean]]
|
||||
[leiningen.jar :only [get-jar-filename get-default-uberjar-name jar]]
|
||||
[leiningen.deps :only [deps]])
|
||||
|
@ -12,9 +11,11 @@
|
|||
|
||||
(defn read-components [zipfile]
|
||||
(when-let [entry (.getEntry zipfile "META-INF/plexus/components.xml")]
|
||||
(-> (xml-> (xml-zip (xml/parse (.getInputStream zipfile entry)))
|
||||
(tag= :components))
|
||||
first first :content)))
|
||||
(->> (xml-zip (xml/parse (.getInputStream zipfile entry)))
|
||||
children
|
||||
(filter #(= (:tag %) :components))
|
||||
first
|
||||
:content)))
|
||||
|
||||
(defn copy-entries
|
||||
"Copies the entries of ZipFile in to the ZipOutputStream out, skipping
|
||||
|
|
Loading…
Reference in a new issue