每次我运行maven包以生成更新的jar时,它会创建一个“原始”jar文件,以及更新的jar文件。
这对我来说尤其是一个问题,因为我正在自动运行已编译的jar,而且他们都在尝试启动。
我想要创建的是生成的$ {project.artifactId} - $ {project.version} -shaded.jar文件,而不是“原始”文件。有没有办法让它只是覆盖而不进行备份(我假设它正在做什么)?
我该如何解决这个问题?
这是我的pom:
<groupId>com.spiromarshes</groupId>
<artifactId>LiveDebugTest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>LiveDebugTest</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<version>3.6.1</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<outputDirectory>${dir}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
答案 0 :(得分:4)
使用maven-shade-plugin的配置部分下的<outputFile>${dir}\${project.artifactId}.jar</outputFile>
解决。