Hello,
My POMs have two parents: The one in the parent directory and the one
which supplies them with the build defaults.
Out of necessity, they can't be the same POM. The ../pom.xml just
specifies the build order. The POM specified with the <parent> element
supplies the build config (for example for webapps or for code
libraries).
Usually, a web project in our company contains a code and a web part,
so I need two <parent> POMs (one for libraries and one for webapps)
and I need a POM which says "build the library, then build the webapp".
This means, I'm fighting with the limitations of Maven's parent POM
model. Some plugins like the site plugin are confused how to build the
aggregated site structure.
I see three ways to improve the situation:
- Support <xi:include>.
Pro: It's a W3C standard (some will say that's a drawback :-)
Con: It doesn't really fit into the XML inheritance model of Maven.
When will variables be resolved? Before or after the includes? Or
somewhere inbetween? How can we debug this?
- Allow multiple <parent> elements
Pro: People are already used to the parent element
Con: Humans have more than one parent (father and mother) and we all
know how confusing it is when they can't agree about something. So
this would call for a smart conflict resolution strategy which a
developer can understand without help.
The current element will probably have to be extended with new attributes.
- A new <mixin> element
The element refers to a POM artifact like the <parent> element but I
would also like it to be able to select deeper in XML tree of a POM:
* "I'd like to copy the configuration for the maven-deploy-plugin but
overwrite the version element"
* "Copy the report config and merge it with the definitions in the
current POM"
* "Copy the config for the cobertura plugin except for the include
element in the configuration"
Pro: New element allows new semantic
Con: This will be a pretty complex element, especially if it can copy
conditionally. The syntax should be simple enough so people don't
swamp the Maven lists with questions but powerful enough to actually
solve the limitations of the current inheritance system.
We might be tempted to support a copy operator based on XPath. I think
this is a bad idea because the XPath syntax is really very complex and
can be quite confusing.
- Allow to include "macro POMs". A macro POM defines common building
blocks which can be extended as we're used to or configured via
paramaters:
<macros>
<include>
<groupId>...</groupId>
<artefactId>...</artefactId>
<version>...</version>
</include>
<include>
<file>....</file>
</include>
<macro>
<id>compile</id>
<parameter><name>version</name><default>2.0.2</default></parameter>
<parameter><name>source</name><default>1.4</default></parameter>
<parameter><name>target</name><default>@{source}</default></parameter>
<body>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>@{version}</version>
<configuration>
<source>@{source}</source>
<target>@{target}</target>
</configuration>
</plugin>
</body>
</macro>
</macros>
<build>
<plugins>
<macro-ref>
<id>compile</id>
<parameter><name>version</name><value>2.1</value></parameter>
<body>
<plugin>
<configuration>
<clean />
<source>1.5</source>
</configuration>
</plugin>
</body>
</macro-ref>
</plugins>
</build>
Some comments:
- The "<clean />" element deletes anything inherited below the current
parent element. In the example, there is no target element in the
effective POM anymore.
- Includes overwrite in the order in which they are specified. So the
macros defined in the artefact are overwritten by those in the file
and any "compile" macro will be overwritten with the local definition.
Maybe inheritance merge should be supported here, too.
Comments?
--
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://www.philmann-dark.de/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]