Maven 将构建的 war 文件复制到兄弟模块
Maven copy built war file to sibling module
我正在将 ant 项目转换为 maven。我需要将创建的 war 文件复制到兄弟模块。我该怎么做?
编辑:我的问题不是很清楚,所以我要展开。我有一个包含 2 个子模块的多模块项目:A 和 B。模块 A 生成一个 war,模块 B 生成一个 jar。我想将模块A产生的war复制到模块B的目标目录中。
使用 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>
我正在将 ant 项目转换为 maven。我需要将创建的 war 文件复制到兄弟模块。我该怎么做?
编辑:我的问题不是很清楚,所以我要展开。我有一个包含 2 个子模块的多模块项目:A 和 B。模块 A 生成一个 war,模块 B 生成一个 jar。我想将模块A产生的war复制到模块B的目标目录中。
使用 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>