我有一个带有不同子项目的分销项目,我想完成以下操作:
- (root)
- 客户
- 模块A
- 模块B
- 模块C
- 模型
我想放
protoc {
artifact = 'com.google.protobuf:protoc:3.5.0'
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.7.0"
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
} }
dependencies {
compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
compile "io.grpc:grpc-netty:1.7.0"
compile "io.grpc:grpc-protobuf:1.7.0"
compile "io.grpc:grpc-stub:1.7.0"
}
对于模块A,B和C。
目前,我在根build.gradle
subprojects{
apply plugin: 'java'
sourceCompatibility = 1.8
group 'project'
version '0.0.1-SNAPSHOT'
jar {
manifest {
attributes 'Main-Class': "com.project.${project.name}.App"
}
doFirst {
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
}
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
}
}
因此,每个子项目都使用Java插件,并具有定义依赖项和JAR任务。我如何只为某些子项目放置第一个块?
我尝试使用像多项目构建中的变量 - gradle,但我无法在subprojects
块中访问它。
预先感谢您。我真的有兴趣正确使用Gradle,很难在简单的Android/Java项目之外进入它。请随时包含我应该阅读的任何文档:)
编辑:
谢谢。如果我以前从未搜索过,我不会在这里发布。显然我缺少关键字"子集",谁会给我您链接的解决方案。
这里描述了一个解决方案:https://discuss.gradle.org/t/configure-only-only-subset-subset-ob-subprojects/5379/3
您可以使用项目列表运行configure()。
project.ext {
subprojectList = subprojects.findAll{
it.name == 'subprojectA' ||
it.name == 'subprojectB' ||
it.name == 'subprojectC'
}
}
configure(project.subprojectList) {
// insert your custom configuration code
}
或
configure([project(':a'), project(':b'), project(':c')]) {
// configuration
}