1.17.x Trouble shading TaskChain into project

Discussion in 'Spigot Plugin Development' started by Snicko, Jun 27, 2021.

  1. Hi there! I am having some trouble shading the TaskChain project into my own project using maven.

    I have relocated TaskChain into my own project with

    Code (Text):
                    <configuration>
                        <relocations>
                            <relocation>
                                <pattern>co.aikar.taskchain</pattern>
                                <shadedPattern>com.deadmc.DeadAPImaven.external.co.aikar.taskchain</shadedPattern>
                            </relocation>
                        </relocations>
                    </configuration>
    And I get a successful build with what looks like TaskChain included
    ([INFO] Including co.aikar:taskchain-bukkit:jar:3.7.2 in the shaded jar.
    [INFO] Including co.aikar:taskchain-core:jar:3.7.2 in the shaded jar.)

    Although I can't resolve any methods from TaskChain.
    [​IMG]

    I am using Java 16 and the 3.3.0-snapshot for maven shade.
    I'm pretty new to maven so any help would be appreciated!
     
  2. You forgot add
    Code (Text):
    <dependencies>
            <dependency>
                <groupId>your project</groupId>
                <artifactId>your project</artifactId>
                <version>your project version</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </project>
    If there is no maven, you need to proceed with local maven.
     
  3. I don't think you are supposed to add your own project as a dependency?
    Btw that is not my entire pom file. My entire pom is:

    Code (Text):
    <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>com.deadmc</groupId>
        <artifactId>DeadAPImaven</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>

        <name>DeadAPImaven</name>
        <url>http://maven.apache.org</url>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>

        <!--for maven shade to work with snapshots-->
        <pluginRepositories>
            <pluginRepository>
                <id>maven-snapshots</id>
                <url>https://repository.apache.org/content/repositories/snapshots/</url>
            </pluginRepository>
        </pluginRepositories>
     
        <dependencies>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot</artifactId>
                <version>1.16.5-R0.1-SNAPSHOT</version> <!-- can use [1.17,] -->
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>net.raidstone</groupId>
                <artifactId>WorldGuardEvents</artifactId>
                <version>1.16.4</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>net.wesjd</groupId>
                <artifactId>anvilgui</artifactId>
                <version>1.5.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.sk89q.worldguard</groupId>
                <artifactId>worldguard-bukkit</artifactId>
                <version>7.0.5</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.gmail.filoghost.holographicdisplays</groupId>
                <artifactId>holographicdisplays-api</artifactId>
                <version>2.4.6</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.sk89q.worldedit</groupId>
                <artifactId>worldedit-bukkit</artifactId>
                <version>7.2.5</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                   <groupId>LibsDisguises</groupId>
                   <artifactId>LibsDisguises</artifactId>
                   <version>10.0.25</version>
                   <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>io.papermc</groupId>
                <artifactId>paperlib</artifactId>
                <version>1.0.6</version>
                <scope>compile</scope>
             </dependency>
             <dependency>
                <groupId>me.clip</groupId>
                  <artifactId>placeholderapi</artifactId>
                  <version>2.10.9</version>
                 <scope>provided</scope>
             </dependency>
            <dependency>
                <groupId>com.github.ConnorLinfoot</groupId>
                <artifactId>TitleAPI</artifactId>
                <version>a9d9117fe37333613614f357903a96138e4c9a7c</version>
            </dependency>
            <dependency>
                <groupId>com.comphenix.protocol</groupId>
                <artifactId>ProtocolLib</artifactId>
                <version>4.6.0</version>
              </dependency>
            <dependency>
                <groupId>net.craftcitizen</groupId>
                <artifactId>imagemaps</artifactId>
                <version>1.0.6</version>
            </dependency>
            <dependency>
                <groupId>co.aikar</groupId>
                <artifactId>taskchain-bukkit</artifactId>
                <version>3.7.2</version>
            </dependency>
        </dependencies>

        <repositories>
            <repository>
                <id>aikar</id>
                <url>https://repo.aikar.co/content/groups/aikar/</url>
            </repository>
            <repository>
                <id>spigot</id>
                <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
            </repository>
            <repository>
                <id>github</id>
                <name>ImageMaps repository</name>
                <url>https://maven.pkg.github.com/SydMontague/ImageMaps</url>
            </repository>
            <repository>
                <id>dmulloy2-repo</id>
                <url>https://repo.dmulloy2.net/repository/public/</url>
            </repository>
            <repository>
                <id>jitpack.io</id>
                <url>https://jitpack.io</url>
            </repository>
            <repository>
                <id>placeholderapi</id>
                <url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
            </repository>
            <repository>
                  <id>md_5-public</id>
                  <url>https://repo.md-5.net/content/groups/public/</url>
            </repository>
            <repository>
                  <id>enginehub-maven</id>
                  <url>https://maven.enginehub.org/repo/</url>
            </repository>
            <repository>
                <id>codemc-snapshots</id>
                <url>https://repo.codemc.io/repository/maven-snapshots/</url>
            </repository>
            <repository>
                <id>sk89q-repo</id>
                <url>https://maven.enginehub.org/repo/</url>
            </repository>
            <repository>
                <id>codemc-repo</id>
                <url>https://repo.codemc.io/repository/maven-public/</url>
            </repository>
            <repository>
                <id>papermc</id>
                <url>https://papermc.io/repo/repository/maven-public/</url>
            </repository>
        </repositories>
     
        <build>
            <finalName>DeadAPI</finalName>
            <sourceDirectory>src/main/java</sourceDirectory>
            <resources>
                <resource>
                    <targetPath>.</targetPath>
                    <filtering>true</filtering>
                    <directory>${basedir}</directory>
                    <includes>
                        <include>plugin.yml</include>
                        <include>donator.yml</include>
                        <include>ips.yml</include>
                        <include>leaderboards.yml</include>
                        <include>loot.yml</include>
                        <include>market.yml</include>
                        <include>pets.yml</include>
                        <include>players.yml</include>
                        <include>regions.yml</include>
                        <include>reports.yml</include>
                        <include>santa.yml</include>
                        <include>shops.yml</include>
                        <include>restarter.yml</include>
                        <include>stats.yml</include>
                        <include>tasks.yml</include>
                        <include>towns.yml</include>
                        <include>travel.yml</include>
                    </includes>
                </resource>
            </resources>

            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.3.0-SNAPSHOT</version>
                    <configuration>
                        <dependencyReducedPomLocation>C:\Users\End User\Documents\DeadAPI Repo\dependency-reduced-pom.xml</dependencyReducedPomLocation>
                        <relocations>
                            <relocation>
                                <pattern>co.aikar.taskchain</pattern>
                                <shadedPattern>com.deadmc.DeadAPImaven.external.co.aikar.taskchain</shadedPattern>
                            </relocation>
                        </relocations>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <source>16</source>
                        <target>16</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
       
    </project>
     
     
  4. So how are you going to import your library?
     
  5. I am trying to import the TaskChain project into my own project.