我的byild.gradle文件
能够使用JAVA 8导出jar。当我配置为JAVA 11时,导出的jar不包含外部jars
//应用java库插件添加对Java库的支持 应用插件:“ 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'
}
答案 0 :(得分:0)
将此行添加到您的build.gradle
jar { manifest {attributes "Main-Class": "your main class" } from {configurations.compile.collect { it.isDirectory()? it : zipTree(it) } }
然后进行清理/构建, 在\ build \ libs文件夹中创建的jar是您可运行的jar