英文:
How to access collection of source directories of all included build in composite build of Gradle?
问题
settings.gradle
rootProject.name = 'my-composite';
includeBuild 'my-app';
includeBuild 'my-utils';
build.gradle
project.ext.files1 =
fileTree("C:/my-composite/my-app/src").matching {
include '*.java';
}
project.ext.files2 =
fileTree("C:/my-composite/my-utils/src").matching {
include '*.java';
}
project.ext.allFiles = project.ext.files1.plus(project.ext.files2);
可以使用 gradle.includedBuild('my-app') 动态生成源代码列表吗?
还是有没有办法使用任务来返回每个已包含构建的源目录?
还有其他的方法可以实现吗?
英文:
I have a gradle project with composite build. I have to get the source files collection to use in jacoco instrumentation. Is there any to get the source directories of all included builds.
settings.gradle
rootProject.name = 'my-composite'
includeBuild 'my-app'
includeBuild 'my-utils'
I am currently using files method to get the collection in build.gradle
project.ext.files1 =
fileTree("C:/my-composite/my-app/src").matching {
include '*.java'
}
project.ext.files2 =
fileTree("C:/my-composite/my-utils/src").matching {
include '*.java'
}
project.ext.allFiles = project.ext.files1.plus(project.ext.files2)
can we generate the source list dynamically using gradle.includedBuild('my-app')?
(or)
Is there any way to use a task to return source directory of each inculdede build?
or is there any other way to do it?
答案1
得分: 1
应该能够执行:
fileTree(gradle.includedBuild("my-app").projectDir.resolve("src")).matching {
include("*.java")
}
英文:
Should be able to do:
fileTree(gradle.includedBuild("my-app").projectDir.resolve("src")).matching {
include("*.java")
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论