Skip to content
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

Gradle failed resolving partially resolved dependencies #17144

Closed
glefloch opened this issue May 10, 2021 · 1 comment
Closed

Gradle failed resolving partially resolved dependencies #17144

glefloch opened this issue May 10, 2021 · 1 comment

Comments

@glefloch
Copy link
Contributor

In a simple gradle project with 2 repositories (mavenLocal(), mavenCentral()), gradle sometimes fails to find dependencies with the following error:

Caused by: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find jboss-annotations-api_1.2_spec-1.0.2.Final.jar (org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:1.0.2.Final).
Searched in the following locations:
    file:/home/g/.m2/repository/org/jboss/spec/javax/annotation/jboss-annotations-api_1.2_spec/1.0.2.Final/jboss-annotations-api_1.2_spec-1.0.2.Final.jar

It appears that the folder exists my local repository but for some reason (due to other builds), only the pom file has been resolved.
If I clean my maven local repository, the next execution will be ok.

Expected Behavior

Gradle should not fail and try to resolved that dependency using the next repository.

Current Behavior

Gradle fail to resolve the dependency and build fail. If I clean my maven repository then the resolution is ok.

Steps to Reproduce

  • Create a simple gradle project
  • remove a jar from a dependency in your local maven repository
  • try to build the project

Your Environment

  • Java 11
  • Gradle 6.8.3
@jjohannes
Copy link
Contributor

Using mavenLocal() as repository is not safe/stable as it may be modified by other tools like Maven while you run a build. What you describe is a broken publication in a repository where the pom exists, but the Jar is missing. Gradle does not just jump over these as the assumption is that repositories are not broken. The solution for this is to fix the corresponding publication in the repository.

Note that if you remove mavenLocal() as repository, Gradle will still check your .m2 folder for Jars that were already downloaded there (effectively using is as a cache).

See also: https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:case-for-maven-local

Please avoid using mavenLocal() as repository. Only use it if you absolutely need to (e.g. because you need to interact with a Maven build).

If you want to publish something locally, please use a separate (and isolated) folder as repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants