Maven将辅助文件部署到存储库 [英] Maven deploy secondary file to repository
问题描述
mvn deploy:deploy-file -DgroupId = $ {GROUP_ID} \
-DartifactId = $ ARTIFACT_ID \
-Dversion = $ VERSION \
-Dpackaging = xml \
-Dclassifier = metadata \
-Dfile = metadata.xml \
-DrepositoryId = releases \
-Durl = http:// localhost / nexus / content / repositories / releases \
-DgeneratePom = false
我想将xml文件从pom.xml中的属性填充,并将其与主要工件一起部署在一个简单的命令中,适用于所有内部项目。
是否可以配置部署插件来执行此操作(如何)?或者我需要下一些其他路线(可能是自定义maven插件)?
使用 build-helper-maven-plugin ,如下所示:
< plugin>
< groupId> org.codehaus.mojo< / groupId>
< artifactId> build-helper-maven-plugin< / artifactId>
< version> 1.8< / version>
<执行>
< execution>
< id> attach-artifacts< / id>
< phase> package< / phase>
< goals>
< goal> attach-artifact< / goal>
< / goals>
< configuration>
<工件>
< artifact>
< file> x1.xml< / file>
< type> xml< / type>
< classifier>可选< / classifier>
< / artifact>
...
< / artifacts>
< / configuration>
< / execution>
< / executions>
< / plugin>
使用这种类型的设置,您可以使用通常的 mvn deploy
它还将部署您可以附加到通常的构建工件的其他工件。
I'm looking to deploy alongside my jars, wars, etc. an XML file. I can do this manually with a classifier:
mvn deploy:deploy-file -DgroupId=${GROUP_ID} \
-DartifactId=$ARTIFACT_ID \
-Dversion=$VERSION \
-Dpackaging=xml \
-Dclassifier=metadata \
-Dfile=metadata.xml \
-DrepositoryId=releases \
-Durl=http://localhost/nexus/content/repositories/releases \
-DgeneratePom=false
I'd like to have the xml file populated from properties in the pom.xml and have it deployed alongside the main artifact in one simple command, something to apply to all our internal projects.
Is it possible to configure the deploy plugin to do this (and how)? Or do I need to go down some other route (custom maven plugin perhaps)?
The best solution for such purposes is simply using the build-helper-maven-plugin like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>x1.xml</file>
<type>xml</type>
<classifier>optional</classifier>
</artifact>
...
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
With such kind of setup you can use the usual mvn deploy
which will also deploy the additional artifacts which you can attach to your usual build artifacts.
这篇关于Maven将辅助文件部署到存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!