如何访问Gradle复合构建中所有已包含构建的源目录集合?

huangapple go评论93阅读模式
英文:

How to access collection of source directories of all included build in composite build of Gradle?

问题

settings.gradle

  1. rootProject.name = 'my-composite';
  2. includeBuild 'my-app';
  3. includeBuild 'my-utils';

build.gradle

  1. project.ext.files1 =
  2. fileTree("C:/my-composite/my-app/src").matching {
  3. include '*.java';
  4. }
  5. project.ext.files2 =
  6. fileTree("C:/my-composite/my-utils/src").matching {
  7. include '*.java';
  8. }
  9. 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

  1. rootProject.name = 'my-composite'
  2. includeBuild 'my-app'
  3. includeBuild 'my-utils'

I am currently using files method to get the collection in build.gradle

  1. project.ext.files1 =
  2. fileTree("C:/my-composite/my-app/src").matching {
  3. include '*.java'
  4. }
  5. project.ext.files2 =
  6. fileTree("C:/my-composite/my-utils/src").matching {
  7. include '*.java'
  8. }
  9. 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

  1. 应该能够执行:

fileTree(gradle.includedBuild("my-app").projectDir.resolve("src")).matching {
include("*.java")
}

英文:

Should be able to do:

  1. fileTree(gradle.includedBuild("my-app").projectDir.resolve("src")).matching {
  2. include("*.java")
  3. }

huangapple
  • 本文由 发表于 2020年9月29日 01:24:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/64106820.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定