I am trying to make one task in the JRuby Resolver...
# plugin-development
y
I am trying to make one task in the JRuby Resolver plugin configuration cache-safe. IN the original task a reference to a
Configuration
instance was kept (which doesn't work with CC). The
Configuration.getResolvedConfigration()
method is called in the task action. Originally I went down that way as I need to both the type and classifier of the resolved transitive dependencies. The problem now is that I cannot add a field of type
ResolvedConfiguration
as it will resolve within the configuration phase. I have looked at obtaining
ResolvableDependencies
via
Configuration.getIncoming
, but I can see no way of getting instances of
ResolvedArtifact
out of that when the original configuration is resolved. Any ideas?
For context, this is the function that does the actual work (and which will need to be modified not to take a
Configuration
instance. https://gitlab.com/ysb33rOrg/simplified-jruby-gradle-plugin/-/blame/RELEASE_1_0_1/[…]/org/ysb33r/gradle/jruby/api/gems/GemUtils.groovy?ref_type=tags
m
Dependency resolution types aren't my forte, but, AFAIR, you should strip the Configuration down to
ArtifactCollection
, it can be stored in CC:
configuration.getIncoming().getArtifacts()
y
From there you can go to
ResolvedArtifactResult
, then a
ResolvedVariantResult
and then finally look on the attributes for
artifactType
. Not sure how to obtain the classifier though.
v
I guess what you need is a property of type
Provider<ResolvedComponentResult>
as mentioned on the CC doc page.
y
@Vampire I don't think it is possible to get the artifact classifier via that route.
v
Ah, you are probably right as the classifier is a property of the artifact, not the variant
So hopefully the according
incoming.artifacts.resolvedArtifacts
also mentioned there provides the information
If not directly, maybe you need to get the filename from the identifier and subtract the un-classified filename? 😕
y
It only provides the type and not the classifier
And would be an error-prone approach.
m
Looks like this is a missing piece: https://github.com/gradle/gradle/issues/20979 I'll send this issue through the triage queue again, so someone relevant will take a look.
y
Thanks. In the meantime, I could potentially move the
Configuration
field into an extension on the task, then use a Provider to return what is needed. As long as the Provider then is an input on the task, it should resolve before execution occurs, but after configuration.
v
If you do not mind using an internal class, you could cast to
DefaultModuleComponentArtifactIdentifier
and on that get
name
and on that
classifier
y
That might also be a good workaround.
m
then use a Provider to return what is needed.
This can work, with CC the
ArtifactCollection
is also likely to be computed at store time.
y
Early indications are the extension workaround solves the issue.
👍 1
👌 1