我正在将一个蚂蚁项目转换为maven。我需要将创建的war文件复制到兄弟模块。我该怎么做?
编辑:我的问题不是很明确,所以我要扩展。我有一个包含2个子模块的多模块项目:A和B.模块A产生战争,模块B产生一个jar。我想将模块A产生的战争复制到模块B的目标目录。
答案 0 :(得分:1)
使用war作为依赖,意思是这样:
<dependency>
<groupId>xxxx</groupId>
<artifactId>theArtifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>war</type>
</dependency>
或者您可以使用maven-dependency-plugin to copy a dependency or an artifact:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
<destFileName>optional-new-name.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/wars</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>