I am having a few projects, where one project repackages the distribution of another.
I’ve structured this in a custom plugin as follows:
def distributions = project.extensions.findByType(DistributionContainer)
def embed = project.configurations.create("embed")
def configDistribution = distributions.create("config") { Distribution d ->
d.contents.from {
embed.resolvedConfiguration.files.collect {
it.name.endsWith('.tar') ? project.tarTree(it) : project.zipTree(it)
}
}
}
Task configDistTar = project.tasks.getByName(configDistribution.name + 'DistTar')
project.artifacts.add('default', configDistTar)
This gets applied to every project, so any project can aggregate the distribution content of another by referencing it in the embed
configuration.
It all works, but if I build org.gradle.parallel=true
, the dependency between projects is not respected.
I would have expected that the distribution copy spec would try to resolve the configuration, which references an artifact, built by a task in different project.
Instead, when I do gradle clean ass
I get spurious errors such as:
Could not read ‘…\build\distributions…tar’ as it does not exist.