Dependencies not shading with Maven shade

20 Views Asked by At

I'm making a minecraft plugin for use with a server. I have tried to get jackson-databind to work so many times, however (with the use of jar tf) I find that jackson is never included and this then causes an error when my plugin loads. Either way, here's my 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>

  <groupId>online.phudge.code</groupId>
  <artifactId>WS8</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>WS8</name>

  <properties>
    <java.version>17</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
            <release>17</release>

          </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.2.4</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          <!--<configuration>
              <relocations>
                  <relocation>
                      <pattern>com.fasterxml.jackson</pattern>
                      <shadedPattern>online.phudge.code.jackson</shadedPattern>
                  </relocation>
              </relocations>
          </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/repositories/snapshots/</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.20.4-R0.1-SNAPSHOT</version>
          <scope>provided</scope>
      </dependency>
      <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
          <version>2.17.0</version> <!-- Use the latest version available -->
          <scope>system</scope>
          <systemPath>${project.basedir}/src/main/java/online/phudge/code/ws8/lib/jackson-databind-2.17.0.jar</systemPath>
      </dependency>
  </dependencies>
</project>

How can I make it so that jackson is actually in the compiled jar? (If it's of any use, I'm using Intellij IDEA to do all of this, including the maven stuff)

I have tried changing downloading the jar files for jackson-core and databind and using the system scope to get them into the pom.xml and changing the JDK version various times. I have also tried mvn clean and mvn package to see what happens.

0

There are 0 best solutions below