-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResolvedArtifact returns incorrect extension for certain artifacts #23208
Comments
on 7.4.2, resolving this artifact goes through this codepath: https://github.com/gradle/gradle/blob/v7.4.2/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/repositories/resolver/MavenResolver.java#L255-L260. Evidently it first checked if an artifact with the bogus extension That code was deleted in 65eb04e. |
FYI, I believe that this might also be the underlying cause for #21526. |
Just got wrecked by this too (context) |
This is also a problem in the |
Sorry for the late reply. Thank you for providing a valid report. The issue is in the backlog of the relevant team, but this area of Gradle is currently not a focus one, so it might take a while before a fix is made. |
fixed in #26850 |
Expected Behavior
Certain POMs on Maven Central (specifically,
javax.ws.rs:javax.ws.rs-api:2.1.1
) contain some unusual usages of variable substitution, where the<packaging>
field is set to a property that is only defined when a specific profile is activated.I would expect the following code:
to output
(since the
ResolvedArtifact
for this dependency indeed is a jar).Current Behavior
For the code snippet above, on Gradle 7.5+, the output is:
instead.
For Gradle 7.4.2, the output is:
as expected.
Context
This particular POM is a little bit weird, and there is some past history with it (see #3065).
In our case, we have several internal repositories that use this pattern (for better or worse):
and iterate over the resulting strings assuming they are Maven coordinates that are sent to another process to resolve dependencies from. In those cases, we expect the
getExtension()
method to return some "standard" extension that Maven likely understands, but instead the resolution fails since it is being told to look for a dependency with an extension of${packaging.type}
.This pattern works as expected in Gradle 7.4.2, but the output changed in Gradle 7.5. It's possible this is not really a regression, and is actually a case of "we fixed a bug," but it's hard for me to tell without knowing more about the internals of Gradle.
Steps to Reproduce
The following integration test will reproduce the issue:
It passes on 7.4.2, and fails on 7.5+.
(I don't know how to construct a unit test to demonstrate this because I'm not exactly sure which unit is causing the problem)
Your Environment
I don't have a build scan, but the integration test above should easily reproduce the issue when run from the Gradle source tree in any environment. I tested specifically on MacOS 12.6.2 using JDK version:
as the JVM that launched the Gradle wrapper.
The text was updated successfully, but these errors were encountered: