Reputation: 1188
I am using Gradle Shadow in an attempt to include all dependencies when building my Minecraft Forge mod JAR. The dependency in question is JDA, which is included in the generated JAR, but when I run the Minecraft server I'm presented with this error: java.lang.NoClassDefFoundError: org/slf4j/Logger at net.dv8tion.jda.internal.utils.IOUtil.<clinit>(IOUtil.java:35)
I would have expected Shadow to include all dependencies (including dependencies of dependencies), but SLF4J is definitely not being included in the generated JAR. I've tried a handful of variations, including multiple different slf4j packages, different JDA versions, and a whole bunch of variations of configurations in the build.gradle file.
Gradle: 7.3.3
Shadow: 7.0.0
My build.gradle file (minus a few mod specifics, i.e. mod id):
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java-library'
repositories {
mavenCentral()
maven {
name 'm2-dv8tion'
url 'https://m2.dv8tion.net/releases'
}
}
shadowJar {
dependencies {
include(dependency('org.slf4j:slf4j-api:1.7.36'))
include(dependency('net.dv8tion:JDA:4.3.0_298'))
}
}
dependencies {
minecraft 'net.minecraftforge:forge:1.16.5-36.2.34'
implementation 'org.slf4j:slf4j-api:1.7.36'
implementation 'net.dv8tion:JDA:4.3.0_298'
}
Upvotes: 1
Views: 429