Cannot resolve dependencies that are resolved by Maven

issue-acknowledged
gradle-3529

(Manu Sridharan) #1

Here is my Gradle build script:

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'org.eclipse.scout.sdk.deps', name: 'org.eclipse.jface', version: '3.12.0.v20160518-1929'
}

My src/main/java directory just contains a trivial Java source file. When I run gradle compileJava, I get this output:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not find any version that matches org.eclipse.scout.sdk.deps:org.eclipse.swt.win32.win32.x86:[3.105.0,3.105.1).
  Versions that do not match:
      3.105.0.v20160603-0902
      3.104.0.v20150528-0211
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/eclipse/scout/sdk/deps/org.eclipse.swt.win32.win32.x86/maven-metadata.xml
  Required by:
      :gradleTest:unspecified > org.eclipse.scout.sdk.deps:org.eclipse.jface:3.12.0.v20160518-1929
> Could not find any version that matches org.eclipse.scout.sdk.deps:org.eclipse.core.commands:[3.8.0,3.8.1).
  Versions that do not match:
      3.8.0.v20160316-1921
      3.7.0.v20150422-0725
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/eclipse/scout/sdk/deps/org.eclipse.core.commands/maven-metadata.xml
  Required by:
      :gradleTest:unspecified > org.eclipse.scout.sdk.deps:org.eclipse.jface:3.12.0.v20160518-1929
> Could not find any version that matches org.eclipse.scout.sdk.deps:org.eclipse.equinox.common:[3.8.0,3.8.1).
  Versions that do not match:
      3.8.0.v20160509-1230
      3.7.0.v20150402-1709
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/eclipse/scout/sdk/deps/org.eclipse.equinox.common/maven-metadata.xml
  Required by:
      :gradleTest:unspecified > org.eclipse.scout.sdk.deps:org.eclipse.jface:3.12.0.v20160518-1929

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

However, when I generate a pom.xml file from the above build script using the Maven plugin, the project builds fine when running mvn compile. I’m not sure if this is an issue with Gradle or with the version numbers being used by this project. I’ve created a sample project for reproducing the problem here:

Please let me know if I can provide more information. Thanks!

Gradle Version: 2.14.1
Operating System: Mac OS X 10.11.6 x86_64
Is this a regression? No


(Manu Sridharan) #2

Just a “bump” on this issue. I tried the script out with the latest Gradle nightly (3.1-20160815000022+0000) and observed the same problem. If someone could let me know if this is a known issue, or if there is a workaround, I would appreciate it. Thanks!


(Chris Doré) #3

I don’t have a solution for you, it does seem like it could be a Gradle bug, but I was at least able to get the dependencies resolved using a workaround that forces Gradle to use certain versions.

configurations.conpile.resolutionStrategy {
    force 'org.eclipse.scout.sdk.deps:org.eclipse.swt.win32.win32.x86:3.105.0.v20160603-0902'
    force 'org.eclipse.scout.sdk.deps:org.eclipse.core.commands:3.8.0.v20160316-1921'
    force 'org.eclipse.scout.sdk.deps:org.eclipse.equinox.common:3.8.0.v20160509-1230'
}

(Stefan Wolf) #4

I had a closer look at what is the underlying issue for this behavior (apart from that version ranges are directly from hell):
The StaticVersionComparator compares the various parts of two versions. Given that one version (like 3.8.0.v) has a part which another version doesn’t (the v compared to 3.8.0) the version is bigger if the part is a number and smaller if the part is something else. This means that 3.8.0.v (or 3.8.0.v20160316-1921) is smaller than 3.8.0 since v is not a number (see the code).

This is not a very strange convention given that things like alpha, beta and rc should all be smaller than the version without a suffix. Do you know what the corresponding Maven code looks like, i.e. how Maven does the version comparison?


(Lance Java) #5

I’ve shown a way to implement a custom version comparator in this post. Warning - Untested


(Manu Sridharan) #6

Thanks a lot for the workaround! This is really helpful.


(Manu Sridharan) #7

Hi Stefan, thanks for taking a look! I am not familiar with the implementation of maven, so I don’t know how they do this version comparison stuff. I’m also guessing there is no specification of how this should work. If I find some relevant code or documentation, I will post here.