tôi đã nhận một jar Runnable với build.gradle nàylàm thế nào để sao chép các phụ thuộc thư viện lọ trong 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.+'
)
}
nhưng nó chạy thất bại, bởi vì sự phụ thuộc lọ không thể tìm thấy.
và sau đó tôi thêm mã này:
task copyToLib(type: Copy) {
into "$buildDir/output/libs"
from configurations.runtime
}
nhưng thay đổi không có gì ... tôi không thể tìm đầu ra thư mục/libs ...
làm thế nào tôi có thể sao chép các phụ thuộc libs lọ để một thư mục hoặc đường dẫn được chỉ định?
Làm cách nào để bạn chạy mã? –
@PeterNiederwieser Niederwieserfirst tôi chạy: gradle build, lấy file jar runnable sau đó, chạy file jar: java -jar XXX.jar – jychan
Bạn có thể muốn sử dụng Sync thay vì Copy. Xem thêm https://docs.gradle.org/current/userguide/working_with_files.html#sec:sync_task – morty