对于多项目Gradle项目,foo,bar和baz。我正在尝试创建一个任务,创建一个包含库和javadoc的zip文件,即foo.jar,AND foo-javadoc.jar ..
./build.gradle
./settings.gradle
./foo/build.gradle
./bar/build.gradle
./baz/build.gradle
settings.gradle
include ":foo"
include ":bar"
include ":baz"
顶级构建
allprojects {
apply plugin: 'java'
task generateJavadoc (type : Javadoc) {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath
failOnError = false
}
task javadocJar(type: Jar, dependsOn: generateJavadoc) {
classifier = 'javadoc'
from generateJavadoc.destinationDir
}
artifacts {
archives javadocJar
}
}
task buildZip(type: Zip, dependsOn: build) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from (project(':foo').configurations.runtime) {
into 'jars'
}
from (project (':foo').configurations.archives.all) {
into 'jars'
}
}
当我使用gradle clean buildZip
调用此文件时,会创建一个zip文件,但是没有任何我想要的-javadoc JAR ... JavaDoc jar生成到项目构建目录中,例如: foo / build / lib / foo-javadoc.jar我尝试了project (':foo').artifacts
等的多种组合。
答案 0 :(得分:0)
使用以下方法可以实现。注意javadocJar
是allprojects
块
from (rootProject.allprojects.javadocJar.outputs) {
into 'javadoc'
}