Solved Shadow jar shading everything?

Discussion in 'Spigot Plugin Development' started by ratquaza, Feb 10, 2020.

  1. Currently struggling with my shadow jar build, as it compiles correctly but involves every package/class/etc that I've used, and not just the one I put in the shadowjar.
    This is my build.gradle
    Code (Text):
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
        }
    }

    apply plugin: 'java'
    apply plugin: 'com.github.johnrengelman.shadow'

    group = pluginGroup
    version = pluginVersion

    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'

    repositories {
        mavenCentral()
        maven {
            name = 'spigotmc-repo'
            url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
        }
        maven {
            name = 'sonatype'
            url = 'https://oss.sonatype.org/content/groups/public/'
        }
        maven { url 'https://jitpack.io' }
        maven {
            name = 'codemc-repo'
            url = 'https://repo.codemc.io/repository/maven-public/'
        }
    }

    dependencies {
        testCompile group: 'junit', name: 'junit', version: '4.12'
        compileOnly 'org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT'
        compileOnly "com.github.MilkBowl:VaultAPI:1.7"
        compile group: 'de.tr7zw', name: 'item-nbt-api-plugin', version: '2.2.0'
        compile fileTree(include: ['*.jar'], dir: 'libs')
    }

    shadowJar {
        dependencies {
            include dependency("de.tr7zw:item-nbt-api-plugin:2.2.0")
        }
        relocate("de.tr7zw", "shaded.de.tr7zw")
    }

    import org.apache.tools.ant.filters.ReplaceTokens

    processResources {
        from(sourceSets.main.resources.srcDirs) {
            filter ReplaceTokens, tokens: [version: version]
        }
    }
     
    Anyone know how to fix this?
     
  2. Check that you don't have any extra jars in 'libs' directory
     
  3. I have the Spigot 1.15.2 NMS jar, should I just change the dir to "libraries" and make my build.gradle use that?
     
  4. md_5

    Administrator Developer

    Maybe change it to compileOnly instead of compile?

    Sorry not familiar with gradle
     
    • Agree Agree x 1
  5. I could try that yeah

    EDIT: That seemed to fix it, thank you!