我有一個運行的JAR本的build.gradle如何庫JAR文件的依賴在複製的gradle
apply plugin: 'java'
apply plugin: 'application'
manifest.mainAttributes("Main-Class" : "com.test.HelloWorld")
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.+'
)
}
,但它運行失敗,因爲依賴罐子找不到。
然後我添加以下代碼:
task copyToLib(type: Copy) {
into "$buildDir/output/libs"
from configurations.runtime
}
,但沒有改變......我無法找到該文件夾輸出/庫...
我怎樣才能複製依賴庫罐子指定的文件夾或路徑?
你如何運行代碼? –
@PeterNiederwieser Niederwieserfirst我運行:gradle構建,獲取可運行jar文件 然後,運行jar文件:java -jar XXX.jar – jychan
您可能想使用Sync而不是Copy。另請參閱https://docs.gradle.org/current/userguide/working_with_files.html#sec:sync_task – morty