Kyle Wood
08/03/2024, 7:30 PMval filtered = Attribute.of("filtered", Boolean::class.javaObjectType)
configurations.runtimeClasspath {
// require artifacts be filtered
attributes.attribute(filtered, true)
}
dependencies {
attributesSchema {
attribute(filtered)
}
// mark everything as "filtered true" by default, so the transformer doens't normally run
artifactTypes.getByName("jar") {
attributes.attribute(filtered, true)
}
registerTransform(FilterNativeLibraries::class) {
from.attribute(filtered, false)
to.attribute(filtered, true)
}
// ..other dependencies
implementation("org.duckdb:duckdb_jdbc:1.0.0")
components {
// mark a single variable of a single module as "filtered false" so the transformer does run on it
withModule("org.duckdb:duckdb_jdbc") {
withVariant("runtime") {
attributes.attribute(filtered, false)
}
}
}
}
And that does seem to do what I want in terms of the runtime variant does appear to have the filtered: false attribute on it:
Incompatible because this component declares a component, as well as attribute 'filtered' with value 'false' and the consumer needed a component, as well as attribute 'filtered' with value 'true'
So I would expect the transformer I defined to run on it, but it's not executing for some reason.
I've also tried a different approach, where I define the attribute requirement only on a single configuration which runtimeClasspath depends on, but that doesn't seem to work either because transformation is only applied on configurations when they are resolved, and only the root configuration is actually resolved, so that requirement on the filtered configuration doesn't seem to do anything.Vampire
08/03/2024, 8:29 PMKyle Wood
08/03/2024, 8:31 PMKyle Wood
08/03/2024, 8:37 PMKyle Wood
08/03/2024, 8:56 PMKyle Wood
08/03/2024, 8:56 PM