-3

enter image description here this is my build.gradle

enter image description here this is what happens when i attempt to run the built jar.

 plugins {
    id 'java'
}


group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    implementation "net.dv8tion:JDA:5.0.0-alpha.6"
    implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.1.2'
    implementation"io.github.bonigarcia:webdrivermanager:5.1.0"

}

test {
    useJUnitPlatform()
}
jar {
    manifest {
        attributes 'Main-Class': 'bullshitPackage.main'
    }

    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
Minn
  • 5,688
  • 2
  • 15
  • 42
  • 2
    [Please do not upload images of code/errors when asking a question.](//meta.stackoverflow.com/q/285551) – seenukarthi Feb 21 '22 at 10:44
  • Does this answer your question? [With the new update of JDA 4.2.0 the new built JAR file on the VPS returns NoClassDefFoundError](https://stackoverflow.com/questions/63426422/with-the-new-update-of-jda-4-2-0-the-new-built-jar-file-on-the-vps-returns-nocla) – Minn Feb 21 '22 at 11:39

1 Answers1

0

You could use the shadowjar plugin to include all dependencies in your jar.

To use it in your build.gradle file, try:

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0"
    }
} 
 
plugins {
    id 'java'
    id 'com.github.johnrengelman.shadow' version '7.0.0'
}



group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    implementation "net.dv8tion:JDA:5.0.0-alpha.6"
    implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.1.2'
    implementation"io.github.bonigarcia:webdrivermanager:5.1.0"

}

test {
    useJUnitPlatform()
}
jar {
    manifest {
        attributes 'Main-Class': 'bullshitPackage.main'
    }

    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

Then from your console, navigate to your project's root folder that contains the file gradlew, then run gradlew shadowjar to build the jar into the ./build/libs folder.

thorin9000
  • 171
  • 1
  • 6