I'm trying to use maven-jar-plugin to produce both a war file and a jar file doing ./mvnw clean install
.
My pom.xml contains:
<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>
I also tried with <phase>compile</phase>
.
The jar-file is being created but is very small and does not even contain the application main class.
How can I achieve the same result as <packaging>jar</packaging>
? The war-file looks good it is bigger.
I did read Maven JAR Plugin 3.0.2 Error .. .
If you like to create a separate jar file of the code in your war module theconfiguration 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.