Skip to content

Commit

Permalink
Merge branch 'master' into testsUnderWindows1
Browse files Browse the repository at this point in the history
  • Loading branch information
AtKaaZ committed May 14, 2013
2 parents 208036f + 7b32caf commit 6c34ce7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion leiningen-core/src/leiningen/core/classpath.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(let [project (.getAbsolutePath project-file)]
;; TODO: core.project and core.classpath currently rely upon each other *uk*
(require 'leiningen.core.project)
(try ((resolve 'leiningen.core.project/read) project [])
(try ((resolve 'leiningen.core.project/read) project [:default])
(catch Exception e
(throw (Exception. (format "Problem loading %s" project) e)))))
(println
Expand Down
17 changes: 15 additions & 2 deletions leiningen-core/src/leiningen/core/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(:require [clojure.walk :as walk]
[clojure.java.io :as io]
[clojure.set :as set]
[clojure.string :as s]
[cemerick.pomegranate :as pomegranate]
[cemerick.pomegranate.aether :as aether]
[leiningen.core.utils :as utils]
Expand Down Expand Up @@ -149,7 +150,7 @@
:test-paths ["test"]
:native-path "target/native"
:compile-path "target/classes"
:target-path "target"
:target-path "target/%s"
:prep-tasks ["javac" "compile"]
:jar-exclusions [#"^\."]
:certificates ["clojars.pem"]
Expand Down Expand Up @@ -312,6 +313,16 @@
(defn absolutize-paths [project]
(reduce absolutize-path project (keys project)))

(defn- sha1 [content]
(.toString (BigInteger. 1 (-> (java.security.MessageDigest/getInstance "SHA1")
(.digest (.getBytes content)))) 16))

(defn profile-scope-target-path [project profiles]
(let [n #(if (map? %) (subs (sha1 (pr-str %)) 0 8) (name %))]
(if (:target-path project)
(update-in project [:target-path] format (s/join "+" (map n profiles)))
project)))

;; # Profiles: basic merge logic

(def ^:private hooke-injection
Expand All @@ -336,6 +347,7 @@
:jvm-opts tiered-jvm-opts
:test-selectors {:default (with-meta '(constantly true)
{:displace true})}
:target-path "target"
:dependencies '[[org.clojure/tools.nrepl "0.2.3"]
[clojure-complete "0.2.3"]]
:checkout-deps-shares [:source-paths
Expand All @@ -346,6 +358,7 @@
:test-selectors {:default (with-meta
'(constantly true)
{:displace true})}}
:uberjar {:aot :all}
:update {:update :always}
:offline {:offline? true}
:debug {:debug true}}))
Expand Down Expand Up @@ -543,7 +556,6 @@
(load-hooks)))

(defn project-with-profiles-meta [project profiles]

;;; should this dissoc :default?
;; (vary-meta project assoc :profiles (dissoc profiles :default))
(vary-meta project assoc
Expand All @@ -566,6 +578,7 @@
(-> project
(apply-profiles normalized-profiles)
(absolutize-paths)
(profile-scope-target-path include-profiles)
(add-global-exclusions)
(vary-meta merge {:without-profiles project
:included-profiles include-profiles
Expand Down
8 changes: 3 additions & 5 deletions src/leiningen/deploy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@
[id (assoc settings :username username :password password)]))))

(defn repo-for [project name]
(let [[settings] (for [[id settings] (concat (:deploy-repositories project)
(:repositories project)
[[name {:url name}]])
:when (= id name)] settings)]
(-> [name settings]
(let [settings (merge (get (into {} (:repositories project)) name)
(get (into {} (:deploy-repositories project)) name))]
(-> [name (or settings {:url name})]
(classpath/add-repo-auth)
(add-auth-from-url)
(add-auth-interactively))))
Expand Down
7 changes: 4 additions & 3 deletions src/leiningen/uberjar.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ With an argument, the uberjar will be built with an alternate main.
The namespace you choose as main should have :gen-class in its ns form
as well as defining a -main function."
([project main]
(let [project (update-in project [:jar-inclusions]
(let [project (project/merge-profiles project [:uberjar])
project (update-in project [:jar-inclusions]
concat (:uberjar-inclusions project))]
(try (jar/jar project main)
(catch Exception e
Expand All @@ -88,8 +89,8 @@ as well as defining a -main function."
(FileOutputStream.)
(ZipOutputStream.))]
(let [whitelisted (select-keys project jar/whitelist-keys)
project (merge (project/unmerge-profiles project [:default])
whitelisted)
project (-> (project/unmerge-profiles project [:default])
(merge whitelisted))
deps (->> (classpath/resolve-dependencies :dependencies project)
(filter #(.endsWith (.getName %) ".jar")))
jars (cons (io/file (jar/get-jar-filename project)) deps)]
Expand Down
2 changes: 1 addition & 1 deletion test/leiningen/test/pom.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
(map #(first-in % [:testResource :directory])
(deep-content xml [:project :build :testResources])))
"test resource directories use :dev :default and :test profiles")
(is (= "target" (first-in xml [:project :build :directory]))
(is (= "target/" (first-in xml [:project :build :directory]))
"target directory is included")
(is (= nil (first-in xml [:project :build :extensions]))
"no extensions")
Expand Down

0 comments on commit 6c34ce7

Please sign in to comment.