问题描述
我知道以前有人问过这个问题。我尝试了解决方案 here 和 here,但它们没有产生预期的行为。
我正在制作一个 Spigot 插件,我希望插件的所有依赖项都包含在一个 jar 文件中。目前,我在 Spigot API 之外使用的唯一外部库是 org.json 库。为此,我使用 maven-shade-plugin 创建一个包含依赖项的着色 jar。对于我的测试,我直接在服务器的插件文件夹中构建 jar,以便在进行更改时可以轻松地重新加载它。但是,shade 插件会创建两个 jar 文件,一个原始文件和一个阴影文件。这会导致与服务器发生冲突,因为它并不总是加载正确的。我想知道是否有一种方法可以自动删除或用阴影插件替换原始插件。
到目前为止,我已经尝试在我的 pom.xml 中使用 outputFile
配置选项,但这仍然会创建两个 jar 文件。到目前为止,这是我的 pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<groupId>net.group</groupId>
<artifactId>Artifact</artifactId>
<version>0.1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${project.build.directory}\${project.artifactId}.jar</outputFile>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>meta-inf/*.MF</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<directory>D:\minecraft Server\Test Server\plugins</directory>
</build>
<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20201115</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
任何帮助将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)