マルチプロジェクトのgradleビルドがあります。2 つのサブプロジェクトのみに配布タスクを設定したいと考えています。
ルート プロジェクトとサブ プロジェクト A、B & C があるとします。B & C のみの配布タスクを構成したいと考えています。
次の方法で動作します:
root_project/build.gradle
subprojects{
configure ([project(':B'), project(":C")]) {
apply plugin: 'java-library-distribution'
distributions {
main {
contents {
from('src/main/') {
include 'bin/*'
include 'conf/**'
}
}
}
}
}
しかし、私はそれをこのように機能させることに興味があります
subprojects{
configure (subprojects.findAll {it.hasProperty('zipDistribution') && it.zipDistribution}) ) {
apply plugin: 'java-library-distribution'
distributions {
main {
contents {
from('src/main/') {
include 'bin/*'
include 'conf/**'
}
}
}
}
}
B & C の build.gradle には、次のようになります。
ext.zipDistribution = true
後者のアプローチでは、次の2つの問題があります。
問題1
* What went wrong:
Task 'distZip' not found in root project 'root_project'.
* Try:
Run gradle tasks to get a list of available tasks.
問題 2
zipDistribution
以下のコードでroot_projectにプロパティが読み込めるか検証してみました
subprojects {
.....
// configure ([project(':B'), project(":C")]) {
apply plugin: 'java-library-distribution'
distributions {
/* Print if the property exists */
println it.hasProperty('zipDistribution')
main {
contents {
from('src/main/') {
include 'bin/*'
include 'conf/**'
}
}
}
}
// }
.....
}
上記は、it.hasProperty('zipDistribution') に対して null を出力します。
これらの問題が表示されないように、誰かが正しいアプローチを教えてもらえますか?