Gradle Upgrade from 5.6 to 6.4.1

Hi Techies,

I have upgraded my gradle version from 5.6.2 to 6.41 since then I am getting dependency issues , My build.gradle file which is working super good in 5.6.2 started failing on 6.4.2, here is my grade script.

apply plugin: ‘java’

buildscript {
repositories {
	maven {
		credentials {
			username "${artifactory_user}"
			password "${artifactory_password}"
		}
		url 'http://artifactory.testcompany.com/artifactory/repo-virtual'
	}
}
 
dependencies {
	 classpath "org.springframework.boot:spring-boot-gradle-plugin:2.2.6.RELEASE"
}
}

Error Log with Gradle 6.4.1 is below:

C:\Gradle6.4.1_Check>gradle build

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'Gradle6.4.1_Check'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.6.RELEASE.
     Required by:
         project :
      > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.6.RELEASE.
         > Could not parse POM http://artifactory.com/artifactory/repo-virtual/org/springframework/boot/spring-boot-gradle-plugin/2.2.6.RELEASE/spring-boot-gradle-plugin-2.2.6.RELEASE.pom
            > Could not resolve org.springframework.boot:spring-boot-tools:2.2.6.RELEASE.
               > Could not resolve org.springframework.boot:spring-boot-tools:2.2.6.RELEASE.
                  > Could not parse POM http://artifactory.com/artifactory/repo-virtual/org/springframework/boot/spring-boot-tools/2.2.6.RELEASE/spring-boot-tools-2.2.6.RELEASE.pom
                     > Could not resolve org.springframework.boot:spring-boot-parent:2.2.6.RELEASE.
                        > Could not resolve org.springframework.boot:spring-boot-parent:2.2.6.RELEASE.
                           > Could not parse POM http://artifactory.com/artifactory/repo-virtual/org/springframework/boot/spring-boot-parent/2.2.6.RELEASE/spring-boot-parent-2.2.6.RELEASE.pom
                              > Could not resolve org.springframework.boot:spring-boot-dependencies:2.2.6.RELEASE.
                                 > Could not resolve org.springframework.boot:spring-boot-dependencies:2.2.6.RELEASE.
                                    > Could not parse POM http://artifactory.com/artifactory/repo-virtual/org/springframework/boot/spring-boot-dependencies/2.2.6.RELEASE/spring-boot-dependencies-2.2.6.RELEASE.pom
                                       > Could not resolve io.rsocket:rsocket-bom:1.0.0-RC6.
                                          > Could not resolve io.rsocket:rsocket-bom:1.0.0-RC6.
                                             > Could not parse module metadata http://artifactory.com/artifactory/repo-virtual/io/rsocket/rsocket-bom/1.0.0-RC6/rsocket-bom-1.0.0-RC6.module
                                                > Use JsonReader.setLenient(true) to accept malformed JSON at line 3 column 1 path $

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

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.4.1/userguide/command_line_interface.html#sec:command_line_warnings

This is a known issue of RSocket 1.0.0-RC6, which publishes the hint to use module metadata, but doesn’t have published module metadata. This was resolved in the next release candidate of RSocket.

You’re probably better off using the released version rather than a release candidate anyway, but if you really don’t want to do that, you can work-around the issue by telling Gradle to ignore the module metadata redirection, even if the dependency contains the hint to use it: Metadata Sources.

Thanks for the response James, But I could able to download RSocket with gradle version 5.6.2 , do you think this issue was with Gradle Versio 6.4.2 ?

There’s multiple things going wrong here. Some of them are unique to you, but may also be out of your control. The options I provided are how you can easily resolve it as a user. Let’s go through them in more detail:

  • RSocket 1.0.0-RC6 is broken. The published POM file contains the instruction to use Gradle metadata instead of using the POM file. Regardless of what any version of Gradle does with this, this is broken in this version and you can avoid that problem by using the next RC, 1.0.0-RC7 or a later released version. Making only this change will resolve the specific error you posted.

  • Gradle Metadata is relatively new. I would expect that at least some number of projects other than RSocket may not be handling this correctly in certain versions. While it wouldn’t be my first choice, you can easily opt-out of Gradle metadata entirely, and just rely on the traditional POM files by specifying the metadata sources and ignoring the metadata redirection. Making only this change will also resolve the specific error you posted.

  • Both Gradle 5.6.2 and Gradle 6.4.2 will successfully handle the circumstance where the repository is missing Gradle metadata. As long as the repository returns a 404, Gradle will ignore the error and continue on. This works correctly when using JCenter / Maven Central directly or through a correctly functioning Artifactory instance.

However, you have something wrong with the response you received from Artifactory. You didn’t get a 404. You received some successful response, that isn’t the metadata, and therefore it’s not able to be parsed:

This error can occur when the HTTP request for rsocket-bom-1.0.0-RC6.module returns something other than a 404. Different versions of Artifactory have bugs that can cause this, including cache corruption, or something like a proxy could be interfering as well.

Actually, quite the opposite. This sounds like Gradle 6.4.2 no longer has an issue that was present in Gradle 5.6.2. Although, you want the download of RSocket to be successful, that’s not really the correct behavior here. If a dependency says that consumers should prefer Gradle metadata, and your build is configured (by default) to use Gradle metadata, the correct behavior when receiving bad metadata should be to tell you that’s what happened, not silently ignore it.

Your options are to use a version of the dependency that doesn’t specify to use Gradle metadata, configure your build to ignore Gradle metadata, or troubleshoot why your Artifactory instance may be returning an unexpected response for the rsocket-bom-1.0.0-RC6.module file (and fix that if you have the power to fix Artifactory issues at your organization).

I am running into exact same issue, did you solve your issues and could you please share your final solutions? Thanks.

we have same problem with a corrupted .module in our local Nexus repository (that we are NOT able to delete). The workaround that we have in place is to ignoreGradleMetadataRedirection()

repositories {
    maven {
        url "http://repo.mycompany.com/repo"
        metadataSources {
            mavenPom()
            artifact()
            ignoreGradleMetadataRedirection()
        }
    }
}

This workaround is documented in the User Guide > Working with Dependencies > Learning the Basics > Declaring Repositories > Supported metadata sources.

This is still not ideal for us, ideally, it would be nice to have a flag/property/etc. to ignore invalid gradle metadata JSON (.module files) and use the POM instead.