Request attribute of a GAVCE dependency

Right now I am trying to do

dependencies {
  configuration('G:A:V:C') {
    attributes { }
  }
}

however that doesn’t work due to ‘Cannot add attributes or capabilities on a dependency that specifies artifacts or configuration information’. Omitting the classifier makes it work again, presumably due to the classifier being an attribute constraint already. Any idea on how to properly solve this? I suppose I could add the attributes to the configuration, but that might just be an extra layer of abstraction that isn’t necessary.

The goal is to register an artifact transform for a specific artifact only.

Also the attribute I’m trying to add is a custom one that isn’t present in the variant selection thingy (given that the artifact I’m attempting to transform was published before I really knew about gradle variants), so if you try to push me down that hole: No thank you, I’d rather not rewrite the entire ecosystem.

I guess you could either use a component metadata rule to ad-hoc make the classified artifact a proper variant that you can then resolve using artifacts instead of specifying the classifier.

Or you could maybe use an artifact view on which you then request the attributes so that the attribute transform can then kick in.

Artifact views were indeed what I was looking after, and relatively more compact than some of the other alternatives I explored.