Missing aar file in maven2 multi-project build

maven-2

I'm trying to use maven2 to build an axis2 project. My project is configured as a parent project with AAR, WAR, and EAR modules. When I run the parent project's package goal, the console shows a successful build and all of the files are created. However the AAR file generated by AAR project is not included in the generated WAR project. The AAR project is listed as a dependency of WAR project. When I explicitly run the WAR's package goal, the AAR file is then included in the WAR file.

Why would the parent's package goal not include the necessary dependency while running the child's package goal does?

I'm using the maven-war-plugin v2.1-alpha-2 in my war project.

Parent POM:

<parent>
    <groupId>companyId</groupId>
    <artifactId>build</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.nationwide.nf</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
    <module>ws-war</module>
    <module>ws-aar</module>
    <module>ws-ear</module>
</modules>

AAR POM:

<parent>
    <artifactId>parent</artifactId>
    <groupId>companyId</groupId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>companyId</groupId>
<artifactId>ws-aar</artifactId>
<version>1.0.0-SNAPSHOT</version>
<description/>
<packaging>aar</packaging>
<dependencies>...</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin> 

        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.4</version>
            <configuration>...</configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <id>axis2-gen-sources</id>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-aar-maven-plugin</artifactId>
            <version>1.4</version>
            <extensions>true</extensions>
            <configuration>...</configuration>
        </plugin>
    </plugins>
</build>

WAR POM:

<parent>
    <artifactId>parent</artifactId>
    <groupId>companyId</groupId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>companyId</groupId>
<artifactId>ws-war</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<description/>
<dependencies>
    <dependency>
        <groupId>companyId</groupId>
        <artifactId>ws-aar</artifactId>
        <type>aar</type>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>
    .
    .
    .
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-alpha-2</version>
            <configuration>
                <warName>appName</warName>
            </configuration>
        </plugin>
    </plugins>
</build>

Thanks,
Joe

Best Answer

I was able to get my maven build working correctly by adding the following plugin to the ws-war pom file:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                            ${project.build.directory}/${project.build.finalName}/WEB-INF/services
                        </outputDirectory>
                        <includeArtifactIds>
                            ws-aar
                        </includeArtifactIds>
                    </configuration>
                </execution>
            </executions>
        </plugin>