我们使用maven作为我们的大型产品.我们的所有工件都使用maven部署目标部署到共享archiva存储库.我现在正在整合具有ant build的第三方产品.我知道如何使用antrun插件从maven调用ant目标,但我不确定如何在这个实例中设置pom.我不希望maven实际生成工件,但我确实希望它在运行maven部署目标时拉出由ant构建的工件.
我打算让pom与build.xml相邻.pom将使用包目标中的antrun插件在适当的时候调用ant目标来构建.war工件.
问题:
a)我正在创建一个.war文件,但它是通过ant而不是Maven创建的,所以在pom中使用war包装类型没有意义.我的包装类型应该是什么?
b)如何让maven从我的ant输出目录中提取工件以实现部署目标?
c)如果对A和B没有好的答案,那么是否有ant任务复制maven部署功能以将我的.war工件放入共享存储库?
Ric*_*ler 52
您可以使用maven-antrun-plugin来调用ant构建.然后使用build-helper-maven-plugin将ant生成的jar附加到项目中.附加的工件将与pom一起安装/部署.
如果您使用打包指定项目pom
,Maven将不会与ant构建冲突.
在下面的示例中,假定ant build.xml位于src/main/ant中,有一个compile
目标,并输出到ant-output.jar
.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<ant antfile="src/main/ant/build.xml" target="compile"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>add-jar</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/ant-output.jar</file>
<type>jar</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
29469 次 |
最近记录: |