Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow maven plugins to be specified for export to pom #454

Closed
wants to merge 1 commit into from

4 participants

@hugoduncan

Add the zi plugin to the generated plugin, so maven can build the project
based on the generated pom.

This is not ready for merging, but I wanted to see if there was any interest in having this in lein. The changes still need testing against projects with multiple source paths, java, etc.

One use case for this is to enable builds using maven in Jenkins

@hugoduncan hugoduncan Enable project build using maven based on generated pom
Add the zi plugin to the generated plugin, so maven can build the project
based on the generated pom
5add708
@technomancy
Owner

Yeah, I think it would be a good idea to support specifying Maven plugins for the pom from project.clj.

@xeqi
Collaborator

It looks like the pom task in lein 1.x originally was just for dependency resolution, but has expanded over time (#474, #36, etc). Seems like users are expecting a pom that can be built. I think it would be a good idea to make one that can be built with mvn. (Should the pom file move back to the project-root then?)

Some things, like :offline, will require some research to see if there are equivalents. Eventually this might expand to needing a pom generation hook for things like lein-scalac, but that can be a ways off.

Letting users specify maven plugins in the project.clj sounds ugly. They'll have to specify configuration as well. We'd have to merge those and the normal pom output together, though perhaps this is just a subset of a plugin pom hook system.

@technomancy
Owner

Seems like for plugin config you could just dump the s-expressions into project.clj that could be piped directly into the standard xml-emitting functions, right? It might look ugly in project.clj, but I don't think the implementation would be particularly gnarly. Basically the moral equivalent of just placing a bunch of XML in there.

@xeqi
Collaborator

User specified plugins does sound easier then I first thought, and just dropping xml-as-clojure data into the right pom elements could work.

http://maven.apache.org/guides/mini/guide-configuring-plugins.html
Looks like we have 3 places in the pom that could be changed, build/plugins, reporting/plugins and pluginRepositories.

@technomancy
Owner

Would be great to get a patch for this for 2.0.0 final.

@technomancy
Owner

I think #712 covers this.

@technomancy technomancy closed this
@tobiasbayer

I'm not sure if this is covered by #712.

When adding something like

:pom-addition [:build [:plugins [:plugin [:groupId "org.mortbay.jetty"]
                                       [:artifactId "maven-jetty-plugin"]
                                       [:version "6.1.10"]]]]

to the project.clj this results in two build-sections in the generated pom.xml.
How can I add a plugin to the build section?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 15, 2012
  1. @hugoduncan

    Enable project build using maven based on generated pom

    hugoduncan authored
    Add the zi plugin to the generated plugin, so maven can build the project
    based on the generated pom
This page is out of date. Refresh to see the latest.
Showing with 44 additions and 3 deletions.
  1. +44 −3 src/leiningen/pom.clj
View
47 src/leiningen/pom.clj
@@ -7,6 +7,9 @@
[clojure.data.xml :as xml]
[useful.string :as useful]))
+(def ^:private sonatype-url
+ "http://oss.sonatype.org/content/repositories/releases")
+
;; git scm
(defn- read-git-ref
@@ -91,7 +94,7 @@
(-> tag name (s/replace #"ies$" "y") keyword))
values)]))
-(doseq [c [::dependencies ::repositories]]
+(doseq [c [::dependencies ::repositories ::pluginRepositories]]
(derive c ::list))
(defmethod xml-tags ::exclusions
@@ -121,6 +124,10 @@
([_ [id opts]]
[:repository [:id id] [:url (:url opts)]]))
+(defmethod xml-tags ::pluginRepository
+ ([_ [id opts]]
+ [:pluginRepository [:id id] [:url (:url opts)]]))
+
(defmethod xml-tags ::license
([_ opts]
[:licenses
@@ -132,7 +139,8 @@
([_ project]
(let [dev-project (project/merge-profiles project [:dev])
[src & extra-src] (:source-paths project)
- [test & extra-test] (:test-paths dev-project)]
+ [test & extra-test] (:test-paths dev-project)
+ aot (:aot project)]
[:build
[:sourceDirectory src]
[:testSourceDirectory test]
@@ -175,7 +183,39 @@
[:goals [:goal "add-test-source"]]
[:configuration
(vec (concat [:sources]
- (map (fn [x] [:source x]) extra-test)))]])]]])])))
+ (map (fn [x] [:source x]) extra-test)))]])]]
+ [:plugin
+ [:groupId "org.cloudhoist.plugin"]
+ [:artifactId "zi"]
+ [:version "0.4.5"]
+ [:executions
+ (when-not (:omit-source project)
+ [:execution
+ [:id "default-resources"]
+ [:phase "process-resources"]
+ [:goals [:goal "resources"]]])
+ [:execution
+ [:id "default-test-resources"]
+ [:phase "process-test-resources"]
+ [:goals [:goal "testResources"]]]
+ [:execution
+ [:id "default-test"]
+ [:phase "test"]
+ [:goals [:goal "test"]]]
+ (when-not (empty? aot)
+ [:execution
+ [:id "default-compile"]
+ [:phase "compile"]
+ [:goals [:goal "compile"]]
+ (when-not (= aot :all)
+ [:configuration
+ (vec
+ (concat
+ [:includes]
+ (map
+ (fn [x]
+ [:include (-> x (s/replace "-" "_") (s/replace "." "/"))])
+ aot)))])])]]])])))
(defmethod xml-tags ::parent
([_ [dep version & opts]]
@@ -227,6 +267,7 @@
(make-git-scm (io/file (:root project) ".git"))
(xml-tags :build project)
(xml-tags :repositories (:repositories project))
+ (xml-tags :pluginRepositories {"sonatype" {:url sonatype-url}})
(xml-tags :dependencies (map (partial add-exclusions (:exclusions project))
;; TODO: include :dependencies
;; from :dev profile as test-scoped.
Something went wrong with that request. Please try again.