Gradle Build Error Due to Nexus 400 Bad Request Failure

We have a corporate Nexus 3 server, which

  • places our own artifacts and
  • Used as a proxy for Maven Central and other repositories.

Developers use two repositories:

  • maven releases for all released / stable artifacts with release and
  • maven-snapshots for all snapshot artifacts with the snapshot version policy.

Both repositories are used in the Gradle assembly:

repositories { maven { name "snapshots" url "http://nexus3.server:8081/repository/maven-snapshots" } maven { name "releases" url "http://nexus3.server:8081/repository/maven-releases" } } 

Now when Gradle is trying to resolve the snapshot dependency, it is requesting a release repository, Nexus answers to

 Error 400 Bad Request Repository version policy: RELEASE does not allow version: 1.0-SNAPSHOT 

and build failure using

 > Could not resolve group.id:artifact-id:1.0-SNAPSHOT. Required by: :my-project:unspecified > Could not resolve group.id:artifact-id:1.0-SNAPSHOT. > Could not get resource 'http://nexus3.server:8081/repository/maven-releases/group/id/artifact-id/1.0-SNAPSHOT/artifact-id-1.0-SNAPSHOT.pom'. > Could not GET 'http://nexus3.server:8081/repository/maven-releases/group/id/artifact-id/1.0-SNAPSHOT/artifact-id-1.0-SNAPSHOT.pom'. Received status code 400 from server: Bad Request 

How do I configure Gradle to ignore this error and test the following repository ("snapshots")? Or can you configure Nexus to return 404 Not Found instead of 400 Bad Request?

Version: Gradle 2.9

+5
source share
2 answers

RaGe's comment was good advice: the addiction was neither in snapshots nor releases , but in the third repository, which I did not know about. After adding a third repository to Gradle, the dependency was resolved.

+2
source

Check out the Nexus Repository Manager 3 documentation for gradle use , as well as sample projects . This should show you how to use init.gradle to load from a group of repositories.

+2
source

Source: https://habr.com/ru/post/1259171/


All Articles