Skip to content
Advertisement

How to remove “extras” from using java gradle shadow plugin

I’m using the gradle shadow plugin in my java project.

plugins {
    id 'java'
    id 'com.github.johnrengelman.shadow' version '7.0.0'
}

I used the following code to get rid of all the dependencies I could.

shadowJar {
    dependencies {
        exclude(dependency("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"))
        exclude(dependency("org.jetbrains:annotations:22.0.0"))
        exclude(dependency("com.comphenix.protocol:ProtocolLib:4.7.0"))
    }
}

However, I’ve got all these extra files in my jar file. I want to remove everything except what’s in the “eu” folder and the “plugin.yml”. How can I do this?

Extra files

Advertisement

Answer

Don’t use shadowJar {} unless you have to, just change “implementation” to “compileOnly” for the dependencies you don’t want in the jar

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement