Answer the question
In order to leave comments, you need to log in
How to consider dependencies when building a jar file?
There is some java project with build.gradle like this:
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.1'
}
mainClassName = "Main"
group 'org.q'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'net.dv8tion', name: 'JDA', version: '4.1.1_121'
compile group: 'org.mongodb', name: 'mongodb-driver-sync', version: '3.12.2'
compile group: 'org.atteo.classindex', name: 'classindex', version: '3.4'
annotationProcessor group: 'org.atteo.classindex', name: 'classindex', version: '3.4'
}
jar {
manifest {
attributes 'Main-Class': 'discordbot.Main'
}
}
compileJava.options.encoding = 'UTF-8'
Exception in thread "main" java.lang.NoClassDefFoundError: net/dv8tion/jda/api/JDABuilder
at discordbot.Main.main(Main.java:17)
Caused by: java.lang.ClassNotFoundException: net.dv8tion.jda.api.JDABuilder
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
Answer the question
In order to leave comments, you need to log in
Seems like something is missing.
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question