我现有两个 Maven 项目,我想在构建后将它们合并为一个项目。 我还没有创建这些项目模块,这两个项目是单独的 Maven 项目。 下面是现有项目中的 POM xml 代码部分。
项目一 pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-reg</artifactId>
<version>1.0</version>
<packaging>war</packaging>
项目二 pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-qba</artifactId>
<version>1.0</version>
<packaging>war</packaging>
合并项目 pom.xml
<groupId>com.olex</groupId>
<artifactId>olex-war</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
我想将这些项目合并成一个像olex-war
这样的完整项目。
构建后,我希望将所有代码复制到此 olex-war 项目中。
如果有人知道这种情况,请建议/提供提示。
提前致谢。
最佳答案
您可以从这样的 pom 开始,将旧的 war 文件的所有内容提取到内容目录中。然后,您可以将该目录中的所有内容(web.xml 和其他元数据除外)打包到您的新 war 中。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.olex</groupId>
<artifactId>olex-war</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>olex-war Maven Webapp</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>olex-war</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.olex</groupId>
<artifactId>olex-qba</artifactId>
<version>${project.version}</version>
<packaging>war</packaging>
</artifactItem>
<artifactItem>
<groupId>com.olex</groupId>
<artifactId>olex-reg</artifactId>
<version>${project.version}</version>
<packaging>war</packaging>
</artifactItem>
</artifactItems>
<excludes>WEB-INF/web.xml</excludes>
<includes>**/*.class, **/*.jar, **/*.properties</includes>
<outputDirectory>${project.build.directory}/content</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
关于java - 从现有项目创建父 Maven 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24163101/