Hello, I'm trying to make a Forge mod with JDA. (Java Discord)
I've been able to use the gradle shadow plugin to include the dependencies. And my mod loads properly and functions in the dev environment.
But once compiled into the shadow jar, (yes I am using the shadowJar task in gradle) it crashes in production on a Forge server.
Here is my build.gradle file
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '6.1.0'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
version = '1.16.5-1.0'
group = 'com.dbkynd.discordallowlist' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'discordallowlist'
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
mappings channel: 'official', version: '1.16.5'
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
mods {
discordallowlist {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
mods {
discordallowlist {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
args '--mod', 'discordallowlist', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
discordallowlist {
source sourceSets.main
}
}
}
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
mavenCentral()
maven {
name 'm2-dv8tion'
url 'https://m2.dv8tion.net/releases'
}
}
dependencies {
minecraft 'net.minecraftforge:forge:1.16.5-36.1.35'
shadow('mysql:mysql-connector-java:8.0.25')
shadow('net.dv8tion:JDA:4.3.0_298') {
exclude module: 'opus-java'
}
}
shadowJar {
classifier ''
configurations = [project.configurations.shadow]
}
reobf {
shadowJar {}
}
shadowJar.finalizedBy('reobfShadowJar')
jar {
manifest {
attributes([
"Specification-Title" : "discordallowlist",
"Specification-Vendor" : "DBKynd",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.version,
"Implementation-Vendor" : "DBKynd",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
jar.finalizedBy('reobfJar')
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
The Forge server crashes on startup with this error: java.lang.NoClassDefFoundError: gnu/trove/set/TLongSet
Though I can clearly see it in the jar file.
I believe I am shadowing correctly because the mysql connector is added and I can see a successful mysql connection being established before the crash.
Thanks for any and all help.