简体   繁体   中英

exported runnable jar doesn't contain dependency jars from eclipse 2018-12 with java 11. How do we solve this?

My byild.gradle file

Able to export jar with JAVA 8. when I configure to JAVA 11 exported jar doesn't contain external jars

// Apply the java-library plugin to add support for Java Library apply plugin: 'java-library'

// In this section you declare where to find the dependencies of your project
repositories {
    jcenter()
}

configurations 
    { 
        all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12' //by both name and group
    }

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:21.0'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'

    compile group: 'com.microsoft', name: 'sqljdbc4', version: '3.0'
    compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.15'
    compile group: 'com.ibatis', name: 'ibatis2-common', version: '2.1.7.597'
    compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
    compile group: 'org.yaml', name: 'snakeyaml', version: '1.21'
    compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
    compile group: 'org.json', name: 'json', version: '20171018'

    compile group: 'com.itextpdf', name: 'itextpdf', version: '5.5.13'
    compile group: 'com.itextpdf.tool', name: 'xmlworker', version: '5.5.13'  
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.2'
}

add this below lines into your build.gradle

jar { manifest {attributes "Main-Class": "your main class" } from {configurations.compile.collect { it.isDirectory()? it : zipTree(it) } }

then do a clean/build, the jar created in \\build\\libs folder is your runnable jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM