gradle拷贝静态资源文件_如何在gradle中复制依赖库库JAR

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.+'

)

}

build.dependsOn(copyToLib)

task copyToLib(type: Copy) {

into "$buildDir/output/libs"

from configurations.runtime

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值