Hello
So in the past I roughly used this syntax to add tasks dependcies as declared by the configuration to the task, if automatic wiring does not work:
val useRuntTime by tasks.registering(Sync::class){
val used = configurations.runtimeClasspath
from(used.map { it.files.filter { it.extension == ".jar" } }) //just a dummy to break automatic wiring
dependsOn(used) // add dependency explicitly because the filter...
into("build/runTime")
}
and this will automatically build every project on the runtimeClasspath
However now I am working with artifact transform and that makes me questioning my understanding of gradle…
So now roughly the same thing but now i am using an artifact transform…
val lazyConfig = configurations.resolvable("lazyConfig"){
extendsFrom(configurations.implementation.get())
attributes {
attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, "transformed-jar")
}
}
abstract class MyTransform : TransformAction<TransformParameters.None> {
@get:InputArtifact
abstract val inputArtifact: Provider<FileSystemLocation>
override fun transform(outputs: TransformOutputs) {
println("this is very expensive.." + inputArtifact.get() )
Thread.sleep(1000)
println("done")
val asFile = inputArtifact.get().asFile
if (asFile.isFile) {
outputs.file(asFile)
}
}
}
val useTransform by tasks.registering(Sync::class){
val used = lazyConfig
from(used.map { it.files.filter { it.extension == ".jar" } })
dependsOn(used)
into("build/transform")
}
And in this example dependend projects are no longer build. However if I I am able to use this syntax:
val useTransform by tasks.registering(Sync::class){
from(lazyConfig)
into("build/transform")
}
then project dependencies are build again.
So I am currently a bit unsure: Have I been using a problematic syntax the entire time, is this a bug with artifacts transormations?