-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Dependency version SNAPSHOT
is not recognized as snapshot version
#5613
Comments
This is the line that causes the problem: Line 267 in ed8edd8
This should fix the issue: diff --git a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/repositories/resolver/MavenResolver.java b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/repositories/resolver/MavenResolver.java
index 62d5114b811..ae10e82473b 100644
--- a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/repositories/resolver/MavenResolver.java
+++ b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/repositories/resolver/MavenResolver.java
@@ -264,7 +264,7 @@ public class MavenResolver extends ExternalResourceResolver<MavenModuleResolveMe
}
protected static boolean isNonUniqueSnapshot(ModuleComponentIdentifier moduleComponentIdentifier) {
- return moduleComponentIdentifier.getVersion().endsWith("-SNAPSHOT");
+ return moduleComponentIdentifier.getVersion().endsWith("-SNAPSHOT") || "SNAPSHOT".equals(moduleComponentIdentifier.getVersion());
}
private MavenUniqueSnapshotComponentIdentifier composeSnapshotIdentifier(ModuleComponentIdentifier moduleComponentIdentifier, MavenUniqueSnapshotModuleSource uniqueSnapshotVersion) { Maybe it needs some additonal work, but the main cause should be removed. |
Thanks for the report. This issue seems very specific to Maven corner case. We have no bandwidth to work on it for now. |
@floscher Did you find a workaround to this problem? |
@angeloudy No I didn't find a workaround. |
Like @floscher pointed out, Maven - Glossary clearly states:
This particular use case is not very common and it's not well documented, but it's perfectly valid. Having a quick look to Maven sources, one can find implementation details in several places specifically to support this use case, so it's not accidental! My minimal pull request fixes this issue, improving Gradle's compatibility with Maven. Nevertheless, experimenting with a couple demo projects with real dependencies, one difference remains... Maven dependencies resolution:
Gradle dependencies resolution:
As you can see above with the |
Issue: gradle#5613 Maven compatibility bug fix, now accepting the bare ’SNAPSHOT’ verbatim or the ‘-SNAPSHOT’ suffix for the version string format. Fixes gradle#5613 Signed-off-by: Cláudio Vieira <cldvr@claudiovieira.me>
Any plan for fixing this? |
There is no plan to fix this from the Gradle core team as this does not seem widely used. If someone feels like picking this up, please take a look at the existing PR and make sure test coverage is added. We can then re-open this issue. |
Expected Behavior
When I specify a dependency as
I expect that Gradle downloads the latest snapshot from the given Maven repo.
The URL of the downloaded artifact might look something like this:
https://example.org/maven/org/example/myapp/SNAPSHOT/myapp-20180601.010203-123.jar
In the process I'd expect Gradle to consult
https://example.org/maven/org/example/myapp/SNAPSHOT/maven-metadata.xml
to find the latest version.
Current Behavior
Gradle fails with the following message:
Gradle does not recognize that
SNAPSHOT
is a snapshot version (like1.0-SNAPSHOT
). It treats this version number like a "normal" version number (like1.2.3
).I played around a bit with this and Gradle seems to only treat versions matching
(.+)-SNAPSHOT
as such snapshot versions, but https://maven.apache.org/glossary.html clearly states thatSNAPSHOT
without anything else should also be treated as a snapshot version.Context
I tried using the following repository in one of my builds: https://josm.openstreetmap.de/nexus/content/repositories/snapshots/
When adding the dependency
org.openstreetmap.josm:josm:SNAPSHOT
, Gradle errors out because it can't find the dependency.Steps to Reproduce (for bugs)
See "current behaviour". Add such a dependency and run e.g.
./gradlew dependencies
. Under "context" you'll find an example dependency.The text was updated successfully, but these errors were encountered: