Quantcast
Channel: Maven 2 inheritance (parent -> child project) - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Maven 2 inheritance (parent -> child project)

$
0
0

(also posted on maven-users)

Wondering if anyone can shed some light on inheritance of the elements in pom.xml as relates to resource processing and the WAR plugin.

The documentation for the pom [1] has resources listed under "Elements in the POM that are merged". Some experimentation on my local poms against maven 2.2.1 don't appear to exhibit that behavior. What I see is it looks like is inherited by child projects (in a multi-module build), but that if any of those projects have their own block it replaces the parent, not merged. Is that correct?

Example:

parent-pom.xml
|
|-> child-pom.xml

The following works as I'd expect, with files in dev not included in a final WAR.

parent-pom.xml

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <excludes>
            <exclude>${dev-config.path}</exclude>
        </excludes>
    </resource>
</resources>

child-pom.xml

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <excludes>
            <exclude>${dev-config.path}</exclude>
        </excludes>
    </resource>
    <resource>
        <directory>src/main/rules</directory>
    </resource>
    <resource>
        <directory>src/test/rules</directory>
    </resource>
</resources>

The following change to the child (removing any declaration for src/main/resources) appears to result in src/main/resource not being considered during process-resources, not inheriting from the parent as I'd expected.

child-pom.xml

<resources>
    <resource>
        <directory>src/main/rules</directory>
    </resource>
    <resource>
        <directory>src/test/rules</directory>
    </resource>
</resources>

[1] http://maven.apache.org/guides/introduction/introduction-to-the-pom.html s


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images