【发布时间】:2013-01-16 08:47:21
【问题描述】:
如何在 gradle 中导出一个可执行的 jar,这个 jar 可以运行,因为它包含了参考库。
build.gradle
apply plugin: 'java'
manifest.mainAttributes("Main-Class" : "com.botwave.analysis.LogAnalyzer")
repositories {
mavenCentral()
}
dependencies {
compile (
'commons-codec:commons-codec:1.6',
'commons-logging:commons-logging:1.1.1',
'org.apache.httpcomponents:httpclient:4.2.1',
'org.apache.httpcomponents:httpclient:4.2.1',
'org.apache.httpcomponents:httpcore:4.2.1',
'org.apache.httpcomponents:httpmime:4.2.1',
'ch.qos.logback:logback-classic:1.0.6',
'ch.qos.logback:logback-core:1.0.6',
'org.slf4j:slf4j-api:1.6.0',
'junit:junit:4.+'
)
}
运行后:gradle build
它创建构建文件夹,我在 build/libs/XXX.jar 中运行 jar:
java -jar build/libs/XXX.jar
这里有一个执行说:
Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/JoranException
如何使用参考库运行它?
【问题讨论】:
标签: reference jar executable gradle noclassdeffounderror