I know this has been asked before. I tried the solutions here and here but they didn't produce the desired behavior.
I am making a Spigot plugin and I want all of the plugin's dependencies to be contained in one jar file. Currently, the only external library I'm using beyond the Spigot API is the org.json library. To do this, I'm using maven-shade-plugin to create a shaded jar that contains the dependency. For my testing, I build the jar directly in my server's plugins folder so that I can easily reload it when I make changes. However, the shade plugin creates two jar files, an original and a shaded one. This causes conflicts with the server as it does not always load the correct one. I was wondering if there's a way to automatically delete or replace the original plugin with the shaded one.
So far, I've tried using the outputFile
configuration option in my pom.xml, but that still creates two jar files. Here's my pom.xml so far:
<?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>
Any help would be much appreciated.