Hi, I got a naive question about composite build: how can I get the build artifact (.aar, .jar, etc) from an included build in root project? For example, I have a root project named A, and a project will be included in a composite build by A, which named B. B is a Android Library and will produce a .aar archive. A also has many other runtime dependencies. A has a task to collect build artifacts of runtimeClasspath configuration, however the task cannot find B in the runtimeClasspath configuration.
// setttings of A
includeBuild("../B")
// core code of the task collecting runtime configuration in A
@InputFiles
@PathSensitive(PathSensitivity.NAME_ONLY)
ConfigurableFileCollection getBuildArtifacts() {
return variant.getRuntimeConfiguration()
.getIncoming()
.artifactView {
attributes {
it.attribute(artifactType, 'aar')
}
}.getArtifacts()
.getArtifactFiles()
}
How can I get the build artifact produced by B in A’s task?
What I tried so far
I know included builds do not share configuration so I cannot get archives by configuration, which can be done in multiple-project build like this:
def buildArtifacts = project.files()
project.subprojects.each { p ->
buildArtifacts.from(p.configurations.archives.artifacts.files)
}
I wonder if there’s a similar API for composite build? I found includedBuild, which can get projectDir of each included builds, then I can access the .aar in output folder by hardcode. However I don’t think it’s a good idea since the path of .aar file may change.
Any suggestion will be appreciated.