Adam
05/18/2023, 10:42 AMmoduleFooFilesConsumer
, so Gradle ignores it for matching).
// this configuration is used in the `build.gradle.kts` - dependencies { moduleFooFiles(project(":alpha") }
val moduleFooFilesConsumer: NamedDomainObjectProvider<Configuration> = //...
val moduleFooFilesGroupedById: Provider<Map<String?, FileCollection>> =
moduleFooFilesConsumer
.map { conf ->
conf
.incoming
.artifactView { lenient(true) }
.artifacts
.filter { artifact ->
artifact.variant.attributes.getAttribute(MODULE_ID_ATTRIBUTE) != null
}.groupingBy { artifact ->
artifact.variant.attributes.getAttribute(MODULE_ID_ATTRIBUTE)!!.name
}.fold(objects.fileCollection()) { files, element ->
files.from(element.file)
}
}
There are actually a few similar file types - FooFiles, BarFiles, BazFiles - that need to be ‘transmitted’ separately and then the files of all type types are grouped by module ID into some class (to be used by a JavaExec operation in an isolated Gradle Worker)
data class IncomingModule(
val moduleId: String,
val fooFiles: FileCollection,
val barFile: File,
val bazFiles: FileCollection,
)
IncomingModule
needs to be created in a task - but what’s the correct task input for a property of type Provider<Map<String?, FileCollection>>
? I need one that will perform normalization on the files.