shuniar
shuniar

Reputation: 2622

maven multi-module artifact deployment

I have a multi-module maven project where the parent builds all modules and the child pom aggregators handle config file deployments.

I am able to deploy the bundles via mvn clean deploy from the parent module; however, this fails to attach the config-files specified in the build-helper plugin section of the child module.

This requires me to run a mvn -f <child-module> clean deploy for each child pom that has configuration artifacts. This is also true for artifacts such as features.

Here is an example of what my POM files look like:

Parent

<project>
    <groupId>com.sample</groupId>
    <artifactId>parent</artifactId>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>child</module>
    </modules>
</project>

Child

<project>
    <parent>
        <groupId>com.sample</groupId>
        <artifactId>parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>child</artifactId>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-config-file</id>
                        <phase>install</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
                            <artifacts>
                                <artifact>
                                    <file>properties.cfg</file>
                                    <type>cfg</type>
                                    <classifier>properties</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

What I would like is for the attach-artifact goal to be executed on each child module without having to write a custom batch script to execute these individually. I am deploying to an archiva repository.

EDIT

Parent build output (target server redacted):

C:\Temp>mvn clean deploy -DskipTests
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] child
[INFO] features
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building parent 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ parent ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ parent ---
[INFO] Installing C:\Temp\pom.xml to C:\Users\u14053\.m2\repository\com\sample\parent\1.0-SNAPSHOT\parent-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ parent ---
Downloading: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/maven-metadata.xml (589 B at 7.4 KB/sec)

Uploading: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/parent-1.0-20150511.162118-2.pom
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/parent-1.0-20150511.162118-2.pom (4 KB at
31.6 KB/sec)
Downloading: http://<server>/archiva/repository/snapshots/com/sample/parent/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/parent/maven-metadata.xml (274 B at 5.4 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/maven-metadata.xml (589 B at 2.6 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/parent/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/parent/maven-metadata.xml (274 B at 2.5 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building child 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ child ---
[INFO] Deleting C:\Temp\child\target
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (filter) @ child ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ child ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ child ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Temp\child\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ child ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ child ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ child ---
[INFO] Building jar: C:\Temp\child\target\child-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ child ---
[INFO] Installing C:\Temp\child\target\child-1.0-SNAPSHOT.jar to C:\Users\u14053\.m2\repository\com\sample\child\1.0-SNAPSHOT\child-1.0-SNAP
SHOT.jar
[INFO] Installing C:\Temp\child\pom.xml to C:\Users\u14053\.m2\repository\com\sample\child\1.0-SNAPSHOT\child-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:attach-artifact (attach-config-file) @ child ---
[INFO] Skip attaching artifacts in this project because it's not the Execution Root
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ child ---
Downloading: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/maven-metadata.xml (759 B at 30.9 KB/sec)

Uploading: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/child-1.0-20150511.162120-2.jar
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/child-1.0-20150511.162120-2.jar (2 KB at 21
.1 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/child-1.0-20150511.162120-2.pom
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/child-1.0-20150511.162120-2.pom (2 KB at 6.
1 KB/sec)
Downloading: http://<server>/archiva/repository/snapshots/com/sample/child/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/child/maven-metadata.xml (273 B at 9.2 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/maven-metadata.xml (759 B at 33.7 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/child/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/child/maven-metadata.xml (273 B at 10.7 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building features 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ features ---
[INFO] Deleting C:\Temp\features\target
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (filter) @ features ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ features ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ features ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ features ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Temp\features\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ features ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ features ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ features ---
[INFO] Building jar: C:\Temp\features\target\features-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ features ---
[INFO] Installing C:\Temp\features\target\features-1.0-SNAPSHOT.jar to C:\Users\u14053\.m2\repository\com\sample\features\1.0-SNAPSHOT\featu
res-1.0-SNAPSHOT.jar
[INFO] Installing C:\Temp\features\pom.xml to C:\Users\u14053\.m2\repository\com\sample\features\1.0-SNAPSHOT\features-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ features ---
Downloading: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/maven-metadata.xml (762 B at 27.6 KB/s
ec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/features-1.0-20150511.162120-2.jar
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/features-1.0-20150511.162120-2.jar (2 KB
 at 24.0 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/features-1.0-20150511.162120-2.pom
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/features-1.0-20150511.162120-2.pom (2 KB
 at 7.9 KB/sec)
Downloading: http://<server>/archiva/repository/snapshots/com/sample/features/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/features/maven-metadata.xml (276 B at 5.1 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/maven-metadata.xml (762 B at 7.4 KB/sec)

Uploading: http://<server>/archiva/repository/snapshots/com/sample/features/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/features/maven-metadata.xml (276 B at 12.8 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................. SUCCESS [  1.011 s]
[INFO] child .............................................. SUCCESS [  1.183 s]
[INFO] features ........................................... SUCCESS [  0.563 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.853 s
[INFO] Finished at: 2015-05-11T12:21:21-04:00
[INFO] Final Memory: 11M/244M
[INFO] ------------------------------------------------------------------------

Upvotes: 2

Views: 6349

Answers (1)

Jorge Martinez
Jorge Martinez

Reputation: 1231

Remove or change to false runOnlyAtExecutionRoot property.

If it is set to true then: "This will cause the execution to be run only at the top of a given module tree. That is, run in the project contained in the same folder where the mvn execution was launched."

Probably it is not finding the cfgs files.

Upvotes: 1

Related Questions