我有以下项目结构:
(也有外部依赖)
我使用
创建源jar和javadoc jartask sourcesJar(type: Jar) {
destinationDir = file("./../../build/export/$project.name")
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
destinationDir = file("./../../build/export/$project.name")
classifier 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
现在我需要创建一个文件夹,其中包含项目的jar文件和所有依赖项的jar文件。我目前的版本是
task makeLibsDir(type: Copy, dependsOn: ['jar', 'sourcesJar', 'javadocJar']) {
description 'Builds all relevant jar files to use this project as dependency and copies them to the libs folder'
from jar // copying from jar configuration
File outdir = file("./../../build/$project.name/libs/")
outdir.mkdirs()
into outdir
into('/') {
from configurations.runtime
}
}
当我调用project2:makeLibsDir时,我得到一个包含
的文件夹project1.jar project2.jar extDept1.jar ...
但有两个问题
任何想法我怎么能
编辑:Full build.gradle的最小化版本
buildDir = "../build/$project.name"
subprojects {
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
sourceSets {
....
}
jar {
destinationDir = file("./../../build/export/$project.name")
destinationDir.mkdirs()
baseName = project.name
}
task makeLibsDir(type: Copy, dependsOn: ['jar', 'sourcesJar', 'javadocJar']) {
from jar
File outdir = file("./../../build/$project.name/libs/")
outdir.mkdirs()
into outdir
into('/') {
from configurations.runtime
}
}
task sourcesJar(type: Jar) {
destinationDir = file("./../../build/export/$project.name")
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
destinationDir = file("./../../build/export/$project.name")
classifier 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
project(':project1') {
dependencies {
...
}
}
project(':project2') {
dependencies {
...
compile project(':project1')
}
}
project(':project2') {
dependencies {
...
compile project(':project1')
}
}
}