Java maven多模块工件部署
我有一个多模块maven项目,父级构建所有模块,子级pom聚合器处理配置文件部署 我能够从父模块通过Java maven多模块工件部署,java,maven,deployment,configuration,Java,Maven,Deployment,Configuration,我有一个多模块maven项目,父级构建所有模块,子级pom聚合器处理配置文件部署 我能够从父模块通过mvn clean deploy部署捆绑包;但是,这无法附加在子模块的buildhelper插件部分中指定的配置文件 这需要我为每个具有配置工件的子pom运行mvn-f clean deploy。对于特征等工件也是如此 下面是我的POM文件的示例: 家长 <project> <groupId>com.sample</groupId> <ar
mvn clean deploy
部署捆绑包;但是,这无法附加在子模块的buildhelper插件部分中指定的配置文件
这需要我为每个具有配置工件的子pom运行mvn-f clean deploy
。对于特征等工件也是如此
下面是我的POM文件的示例:
家长
<project>
<groupId>com.sample</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>child</module>
</modules>
</project>
删除或更改为false
runnlyatExecutionRoot
属性
如果设置为true
,则:“这将导致执行仅在给定模块树的顶部运行。也就是说,在启动mvn执行的同一文件夹中包含的项目中运行。”
可能找不到cfgs文件。是否有任何错误消息或类似信息?你的maven输出是什么?@AdamArold构建成功;CFG位于目标目录中,但如果没有子模块的额外部署,则不会复制到archiva。您可以发布生成的输出吗?不是“构建成功”,而是整个日志。不幸的是,在真实的交易场景中,子模块是一个pom,位于没有cfg文件的其他子模块之上。删除
runOnlyAtExecutionRoot
会导致生成失败,因为下面没有可附加的内容。在您发送的日志中,它跳过工件,因为它不是“根”:[INFO][INFO]--生成帮助器maven插件:1.8:附加工件(附加配置文件)@child---[INFO]跳过在此项目中附加工件,因为它不是执行根[INFO]
我建议您在没有cfg工件要上载的子模块中使用属性:skipAttach
,然后删除runOnlyAtExecutionRoot
。谢谢。在删除runOnlyAtExecutionRoot
时,我会尝试将skipAttach
添加到子模块中。
<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>
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] ------------------------------------------------------------------------