Axel23 :
Good afternoon, I want to use the Maven Shade plugin
to package the jar
-file. But each build creates 2 jar
-files.
Why? And how to make 1 jar
-file packed?
my pom.xml
:
<groupId>test</groupId>
<artifactId>task2_maven</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>test.run.Runner</Main-Class>
<Build-Number>1</Build-Number>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
my output:
Please help and let me know what am doing wrong.
jirka.pinkas :
Why does this bother you?
- During package phase, Maven will create target/artifact-version.jar
- Shade plugin will run and it will rename that jar to target/original-artifact-version.jar and give the shaded JAR the name target/artifact-version.jar
So just ignore target/original-artifact-version.jar which just contains result of (1.)
Edit: Add this plugin and run mvn clean install
But as I was trying to say, I don't see a point in deleting the file
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete>
<fileset dir="${project.build.directory}" includes="original-*.jar" />
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=358264&siteId=1