我正在尝试使用maven-jar-plugin生成./mvnw clean install
的war文件和jar文件。
我的pom.xml包含:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-services-provided</id>
<phase>test</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<packaging>jar</packaging>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>${project.build.directory}\${project.artifactId}-${project.version}.jar</file>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
我也尝试过<phase>compile</phase>
。
正在创建jar文件,但是它很小,甚至不包含应用程序主类。
如何获得与<packaging>jar</packaging>
相同的结果?战争档案看起来不错,而且更大。
答案 0 :(得分:0)
如果您想在war模块中创建代码的单独jar文件,则configuration should look like this:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archiveClasses>true</archiveClasses>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
</plugins>
</build>
...
</project>