Skip to content
Browse files

Update install task

  • Loading branch information...
1 parent d7c335c commit 7ff1e2ed43a9d8f7bd03d75ec2db25592a60c3a4 @xeqi xeqi committed
Showing with 48 additions and 72 deletions.
  1. +16 −40 src/leiningen/install.clj
  2. +0 −1 src/leiningen/jar.clj
  3. +30 −29 test/leiningen/test/install.clj
  4. +2 −2 todo.org
View
56 src/leiningen/install.clj
@@ -1,18 +1,13 @@
(ns leiningen.install
"Install the current project or download the project specified."
- (:use [leiningen.core :only [default-repos read-project]]
- [leiningen.jar :only [jar manifest-map local-repo-path]]
- [leiningen.deps :only [deps]]
+ (:require [cemerick.pomegranate.aether :as aether]
+ [leiningen.core.project :as project])
+ (:use [leiningen.jar :only [jar]]
[leiningen.pom :only [pom]]
[clojure.java.io :only [file copy]])
(:import (java.util.jar JarFile)
(java.util UUID)))
-(declare container make-model make-remote-artifact
- make-remote-repo make-local-repo
- make-artifact add-metadata tmp-dir
- get-os leiningen-home)
-
;; (defn bin-path []
;; (doto (file (leiningen-home) "bin") .mkdirs))
@@ -30,11 +25,6 @@
;; (copy (.getInputStream jarfile zip-entry) bin-file)
;; (.setExecutable bin-file true)))))))
-;; (defn standalone-download [name group version]
-;; (.resolveAlways (.lookup container ArtifactResolver/ROLE)
-;; (make-remote-artifact name group version)
-;; (map make-remote-repo default-repos)
-;; (make-local-repo)))
(defn install
"Install current project or download specified project.
@@ -45,36 +35,22 @@ downloads and installs a project from a remote repository. Places
shell wrappers in ~/.lein/bin when provided."
([project]
(let [jarfile (jar project)
- model (make-model project)
- artifact (make-artifact model)
- installer nil
- local-repo (make-local-repo)]
- ;; for packaging other than "pom" there should be "pom.xml"
- ;; generated and installed in local repo
- (when (not= "pom" (.getPackaging model))
- (add-metadata artifact (file (pom project))))
+ pomfile (pom project)]
(if (number? jarfile)
;; if we failed to create the jar, return the status code for exit
jarfile
(do ;; (install-shell-wrappers (JarFile. jarfile))
- (.install installer (file jarfile) artifact local-repo)
+ (aether/install :coordinates [(symbol (:group project)
+ (:name project))
+ (:version project)]
+ :jar-file (file jarfile)
+ :pom-file (file pomfile))
0))))
- ([project-name version]
+ ([_ project-name version]
(let [[name group] ((juxt name namespace) (symbol project-name))
- ;; _ (standalone-download name (or group name) version)
- temp-project (format "%s/lein-%s" tmp-dir (UUID/randomUUID))
- jarfile (local-repo-path (or group name) name version)]
- ;; (install-shell-wrappers (JarFile. jarfile))
- ;; TODO: reach in and pull out project.clj rather than
- ;; extracting it all
- ;; (try (extract-jar (file jarfile) temp-project)
- ;; (when-let [p (read-project (str temp-project "/project.clj"))]
- ;; (deps (dissoc p :dev-dependencies :native-dependencies)))
- ;; (finally
- ;; (delete-file-recursively temp-project :silently)))
- )))
-
-;; (defn get-jar-entry [jar-file entry-name]
-;; (let [jar (JarFile. jar-file true)
-;; entry (.getJarEntry jar entry-name)]
-;; (.getInputStream jar entry)))
+ temp-project (format "%s/lein-%s" (System/getProperty "java.io.tmpdir") (UUID/randomUUID))
+ jarfile (first (aether/resolve-dependencies
+ :coordinates [[(symbol project-name) version]]
+ :repositories (:repositories project/defaults)))]
+ ;; (install-shell-wrappers (JarFile. jarfile))
+ )))
View
1 src/leiningen/jar.clj
@@ -12,7 +12,6 @@
(java.io BufferedOutputStream FileOutputStream
ByteArrayInputStream)))
-(declare local-repo-path) ; placate install.clj for now
;; (declare make-local-repo)
View
59 test/leiningen/test/install.clj
@@ -1,55 +1,56 @@
(ns leiningen.test.install
(:require [leiningen.core.user :as user])
(:use [clojure.test]
- [leiningen.install :exclude [tmp-dir]]
+ [leiningen.install]
[leiningen.test.helper]
[clojure.java.io :only [file]]))
-(def unix-shell-wrapper (file (user/leiningen-home) "bin" "nom"))
-(def windows-shell-wrapper (file (user/leiningen-home) "bin" "nom.bat"))
+;; (def unix-shell-wrapper (file (user/leiningen-home) "bin" "nom"))
+;; (def windows-shell-wrapper (file (user/leiningen-home) "bin" "nom.bat"))
-(defn delete-shell-wrappers []
- (.delete unix-shell-wrapper)
- (.delete windows-shell-wrapper))
+;; (defn delete-shell-wrappers []
+;; (.delete unix-shell-wrapper)
+;; (.delete windows-shell-wrapper))
(deftest test-install
(delete-file-recursively (m2-dir "nomnomnom" "0.5.0-SNAPSHOT") true)
- (delete-shell-wrappers)
+ ;; (delete-shell-wrappers)
(is (zero? (install sample-project)))
(is (not (empty? (.listFiles (m2-dir "nomnomnom" "0.5.0-SNAPSHOT")))))
- (is (.exists unix-shell-wrapper))
- (if (= :windows (get-os))
- (is (.exists windows-shell-wrapper))
- (is (not (.exists windows-shell-wrapper)))))
+ ;; (is (.exists unix-shell-wrapper))
+ ;; (if (= :windows (get-os))
+ ;; (is (.exists windows-shell-wrapper))
+ ;; (is (not (.exists windows-shell-wrapper))))
+ )
(def jdom-dir (file local-repo "jdom" "jdom" "1.0"))
(deftest test-standalone-install
(delete-file-recursively jdom-dir true)
- (delete-shell-wrappers)
- (install "nomnomnom" "0.5.0-SNAPSHOT")
+ ;; (delete-shell-wrappers)
+ (install nil "nomnomnom" "0.5.0-SNAPSHOT")
(is (not (empty? (.listFiles jdom-dir))))
- (is (.exists unix-shell-wrapper)))
+;; (is (.exists unix-shell-wrapper))
+ )
(def tricky-m2-dir (file local-repo "org" "domain" "tricky-name" "1.0"))
-(def tricky-unix-shell-wrapper (file (user/leiningen-home)
- "bin" "tricky-name"))
-(def tricky-windows-shell-wrapper (file (user/leiningen-home)
- "bin" "tricky-name.bat"))
+;; (def tricky-unix-shell-wrapper (file (user/leiningen-home)
+;; "bin" "tricky-name"))
+;; (def tricky-windows-shell-wrapper (file (user/leiningen-home)
+;; "bin" "tricky-name.bat"))
-(defn delete-tricky-shell-wrappers []
- (.delete tricky-unix-shell-wrapper)
- (.delete tricky-windows-shell-wrapper))
+;; (defn delete-tricky-shell-wrappers []
+;; (.delete tricky-unix-shell-wrapper)
+;; (.delete tricky-windows-shell-wrapper))
(deftest test-tricky-name-install
(delete-file-recursively tricky-m2-dir true)
- (delete-shell-wrappers)
+ ;; (delete-shell-wrappers)
(install tricky-name-project)
- (install "org.domain/tricky-name" "1.0")
+ (install nil "org.domain/tricky-name" "1.0")
(is (not (empty? (.listFiles tricky-m2-dir))))
- (is (.exists tricky-unix-shell-wrapper))
- (if (= :windows (get-os))
- (is (.exists tricky-windows-shell-wrapper))
- (is (not (.exists tricky-windows-shell-wrapper)))))
-
-(doseq [[_ var] (ns-publics *ns*)] (alter-meta! var assoc :busted true))
+ ;; (is (.exists tricky-unix-shell-wrapper))
+ ;; (if (= :windows (get-os))
+ ;; (is (.exists tricky-windows-shell-wrapper))
+ ;; (is (not (.exists tricky-windows-shell-wrapper))))
+ )
View
4 todo.org
@@ -28,7 +28,7 @@ See also https://github.com/technomancy/leiningen/issues
** Other stuff
- [ ] Rework prep function to ensure that AOT/javac happens when needed
- [ ] Allow tasks to add in their own injections
- - [ ] Accept more flexible :repositories args for pomegranate 0.0.2
+ - [-] Accept more flexible :repositories args for pomegranate 0.0.4
- [ ] Add :dynamic metadata to clucy (bablien has patches for this)
- [X] Move pom generation to pomegranate or leiningen
- [ ] Non-transitive AOT
@@ -51,7 +51,7 @@ See also https://github.com/technomancy/leiningen/issues
- [X] help (needs tests)
- [X] search
- [X] pom (steal from depot)
- - [ ] install (minus shell wrappers)
+ - [X] install (minus shell wrappers)
- [X] uberjar
- [ ] repl (figure out nrepl integration)
*** Tasks for full release (currently tagged :busted)

0 comments on commit 7ff1e2e

Please sign in to comment.
Something went wrong with that request. Please try again.