Last active
April 28, 2025 13:55
-
-
Save abdulowork/e53cde5a228b6d3957bc086656f36a87 to your computer and use it in GitHub Desktop.
Synthetic reproduction of the transforms resolution performance bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@CacheableTransform | |
internal abstract class T : TransformAction<TransformParameters.None> { | |
@get:PathSensitive(PathSensitivity.RELATIVE) | |
@get:InputArtifact | |
abstract val inputArtifact: Provider<FileSystemLocation> | |
override fun transform(outputs: TransformOutputs) { | |
outputs.file(inputArtifact.get().asFile) | |
} | |
} | |
val numberOfUnrelatedTransformedAttributes = 10 | |
val direct = Attribute.of("attr", String::class.java) | |
val consumables = configurations.create("consumable") { | |
isCanBeResolved = false | |
attributes.attribute(direct, "direct") | |
} | |
artifacts.add( | |
consumables.name, | |
tasks.register<Jar>("stubJar") { | |
from(layout.projectDirectory.file("build.gradle.kts")) | |
destinationDirectory.set(layout.buildDirectory.dir("stubJar")) | |
}, | |
) | |
val transformedAttribute = Attribute.of("transformedAttribute", String::class.java) | |
dependencies.artifactTypes.register("jar") { | |
attributes.attribute(transformedAttribute, "initial_state") | |
} | |
// Technically registering this transform doesn't change anything | |
dependencies.registerTransform(T::class.java) { | |
from.attribute(transformedAttribute, "initial_state") | |
to.attribute(transformedAttribute, "unrequested_state") | |
} | |
(1..numberOfUnrelatedTransformedAttributes).forEach { | |
val unrelated = Attribute.of("unrelated$it", String::class.java) | |
dependencies.registerTransform(T::class.java) { | |
from.attribute(unrelated, "a") | |
to.attribute(unrelated, "b") | |
} | |
} | |
run { | |
val resolvableConfigurations = configurations.create("res") { | |
isCanBeConsumed = false | |
attributes.attribute(direct, "direct") | |
attributes.attribute(transformedAttribute, "requested_state") | |
dependencies.add(project.dependencies.project(":")) | |
} | |
val resolutions = resolvableConfigurations.incoming.artifacts.resolvedArtifacts.map { | |
it.map { | |
it.variant.attributes.toString() | |
} | |
} | |
tasks.register("explodeGradleWithOOM") { | |
inputs.files(resolvableConfigurations) | |
doLast { | |
println(resolutions.get()) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment