Infer classifier when deploying adhoc files

This commit is contained in:
Raymond Huang 2016-11-02 22:26:36 -07:00
parent 78c069822d
commit bf7e029d73
2 changed files with 21 additions and 2 deletions

View file

@ -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")))
@ -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]

View file

@ -68,3 +68,11 @@
(is (thrown? clojure.lang.ExceptionInfo (deploy nil))))
(testing "Fail if project data is missing"
(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"))