i got a runnable jar with this build.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.+' ) } but it run failed, because the dependencies jars can't find.
and then i add this code:
task copyToLib(type: Copy) { into "$buildDir/output/libs" from configurations.runtime } but nothing change...i can't find the folder output/libs...
how can i copy the dependencies libs jars to a specified folder or path?
Add:
build.dependsOn(copyToLib) When gradle build runs, Gradle builds tasks and whatever tasks depend on it (declared by dependsOn). Without setting build.dependsOn(copyToLib), Gradle will not associate the copy task with the build task.
So:
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 } build.dependsOn(copyToLib)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With