Skip to content

Commit

Permalink
Infer classifier when deploying adhoc files
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Huang committed Nov 3, 2016
1 parent 78c0698 commit bf7e029
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/leiningen/deploy.clj
Expand Up @@ -155,6 +155,16 @@
"pom"
(last (.split f "\\.")))))

(defn classifier
"The classifier is be located between the version and extension name of the artifact.
See http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html "
[version f]
(let [pattern (re-pattern (format "%s-(.*)\\.%s" version (extension f)))
[_ classifier-of] (re-find pattern f)]
(when-not (empty? classifier-of)
classifier-of)))

(defn- fail-on-empty-project [project]
(when-not (:root project)
(main/abort "Couldn't find project.clj, which is needed for deploy task")))
Expand Down Expand Up @@ -213,7 +223,8 @@ be able to depend on jars that are deployed without a pom."
group-id (namespace identifier)
repo (repo-for project repository)
artifacts (for [f files]
[[:extension (extension f)] f])]
[[:extension (extension f)
:classifier (classifier version f)] f])]
(main/debug "Deploying" files "to" repo)
(aether/deploy
:coordinates [(symbol group-id artifact-id) version]
Expand Down
10 changes: 9 additions & 1 deletion test/leiningen/test/deploy.clj
Expand Up @@ -67,4 +67,12 @@
(testing "Fail if project data is missing"
(is (thrown? clojure.lang.ExceptionInfo (deploy nil))))
(testing "Fail if project data is missing"
(is (thrown? clojure.lang.ExceptionInfo (deploy nil "snapshots")))))
(is (thrown? clojure.lang.ExceptionInfo (deploy nil "snapshots")))))

(deftest classifiying
(are [expected version file] (= expected (classifier version file))
"fat" "1.2.3" "some-project-1.2.3-fat.jar"
"fat" "1.2.3-alpha6" "some-project-1.2.3-alpha6-fat.jar"
"fat" "1.2.3-SNAPSHOT" "some-project-1.2.3-SNAPSHOT-fat.jar"
nil "1.2.3" "some-project-1.2.3-.jar"
nil "1.2.3" "some-project-1.2.3.jar"))

0 comments on commit bf7e029

Please sign in to comment.