1

this is my build.gradle

repositories {
    mavenCentral()
    maven{url 'http://example.com/repository/maven-public/'}
}

dependencies {
    compile group: 'com.example', name: 'example-commlib', version: '1.0'
}

and the link http://example.com/repository/maven-public/ is build from Nexus Repository Manager which can accessable.

and when I click Refresh Gradle Project in eclipse. I can see the link is point to

https://repo.maven.apache.org/..../example-commlib-1.0.pom

I think the right url is

http://example.com/repository/maven-public/.../example-commlib-1.0.pom

I've check the gradle setting and maven setting in eclipse. It seems fine.

So what's the problem?

chanjianyi
  • 607
  • 4
  • 15
  • 35

1 Answers1

1

Do you have other dependencies on this project? It is possible that the "pom.xml" file of one of the packages you are pulling references example-commlib as a dependency and has the Apache Maven URL hardcoded, and resolves the URL beforehand. You can use gradle dependencies to show the dependency tree and find which version is affected. The answers in this post have suggestions on how to force a specific dependency as well: How can I force Gradle to set the same version for two dependencies?

  • yes, I have other dependencies on this projects. but it seems no any dependencies relate to example-commlib. and so weird is that if I run the command `gradlew bootJar`, there is totally normal without any errors. The errors just come in the eclipse IDE. – chanjianyi Oct 22 '19 at 07:24
  • I see. I did not realize the issue is only in IDE build. Doing some research I see The mavenCentral() alias means that dependencies are fetched from the central Maven 2 repository. his is probably where your unexpected link is coming from. Try flipping the order of mavenCentral() and maven{url 'http://example.com/repository/maven-public/'}, Gradle will look for dependencies in the repository order you specify. – Tony Farias Oct 23 '19 at 01:43
  • yeah. I've tried flip it. but it stuck in the `synchronize gradle project`. looks like it cant connect to `maven{url 'example.com/repository/maven-public'}` – chanjianyi Oct 23 '19 at 02:55
  • Ok . I'd suggest a test where maven{url 'example.com/repository/maven-public'} is your only repository, and then trying to debug the connection issue locally. Perhaps the URL is not accessible locally, and you can source the same .pom from a different URL. – Tony Farias Oct 23 '19 at 14:26