I have dozens of similar but not identical plugin execution configurations. I’d like to re-use parts of them.
The part that I’d like to re-use might look like this:
<reuseMe> <lotsOfXML/> </reuseMe>
Now, some plugin configurations might not contain the above:
<configuration> <simpleStuff/> </configuration>
But other plugin configurations might:
<configuration> <simpleStuff/> <complexStuff> <reuseMe> <lotsOfXML/> </reuseMe> </complexStuff> </configuration>
Instead of copy pasting that fragment, which is always the same, I’d like some mechanism where I can declare reusable XML fragments, and then just “import” them:
<configuration> <simpleStuff/> <complexStuff> <reuseMe import="whatever"/> </complexStuff> </configuration>
Short of XSL transforming my pom.xml
files in a preprocessing step, is there any out-of-the-box way this can be done with vanilla Maven? Using <pluginManagement/>
doesn’t seem to work because that would define the <reuseMe/>
content for all plugin executions as a default, not just for those that need this.
Advertisement
Answer
There is a JIRA for what you’re requesting: https://issues.apache.org/jira/browse/MNG-5102
Opened almost 10 years ago, still not solved.
As far as I know, the only out-of-the-box Maven approach involves plugin executions.
Otherwise, it’s roll your own.
P.S. Not a Maven committer; maybe one of them will see this and we’ll both learn something today.