apply plugin: 'java'
archivesBaseName = 'foo-client'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
//version = '1.0'
dependencies{
compile 'foo:bar:1.0-SNAPSHOT',
'foo:bar-common:1.0-SNAPSHOT',
'foo:bar-communication-api:1.0-SNAPSHOT'
}
repositories{
flatDir{
dirs '/lib'
}
}
执行继承的jar
任务时,这将在项目的foo-client.jar
目录中创建build/lib
。我需要做的是包含几个放在同一目录中的jar,否则项目将无法正常运行。
我该怎么做?
答案 0 :(得分:0)
您可以将外部jar定义为运行时依赖项,然后使用复制任务将它们复制到build / lib,例如:
task copyLibs(type: Copy) {
from configurations.runtime
into "$buildDir/libs"
}
答案 1 :(得分:0)
使用Gradle 1.1以下功能,
apply plugin: 'java'
archivesBaseName = 'foo-client'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
task copyToLib(type: Copy){
into 'bar\\lib'
from configurations.runtime
from configurations.default.allArtifacts.getFiles()
}
dependencies{
compile 'foo:bar-agent-dist:2.0.0-SNAPSHOT',
'foo:bar-common:2.0.0-SNAPSHOT',
'foo:bar-communication-api:2.0.0-SNAPSHOT'
}
repositories{
flatDir{
dirs '/lib'
}
}