2

I have a hosted Sonatype Nexus repository on a local network. It has a Maven group containing a proxy repository for the public Maven repository. In the past this configuration was superb and I encountered few issues.

I recently configured https and ssl on the Nexus repository as Docker would not easily log into insecure Nexus Docker registries during CI/CD processes. I did end up re-configuring the Maven repositories at this point.

Then I updated build.gradle:

repositories {
    maven {
        credentials {
            username "${nexusUsername}"
            password "${nexusPassword}"
        }

        name = 'RepositoryName'
        url = "https://${nexusURL}:${nexusPort}/repository/maven-public"
    }
}

with the nexus* variables defined in ~/.gradle/gradle.properties:

nexus<Variable>=<value>

I have also added the appropriate certificate to the java jre keystore with the keytool and added the certificate in Idea's settings (File > Settings... : Tools > Server Certificates).

When trying to download dependencies (through the Maven proxy) using Gradle (by clicking "import changes" on the pop-up notification in Intellij Idea) the Build output shows "Could not resolve: <dependency>" for each dependency. This behavior is consistent across all of my projects (even ones that previously were able to resolve dependencies).

I have, under most circumstances, been able to get the dependencies to resolve through Nexus when running a Gradle task (:dependencies, :idea, :build) from the project's build.gradle file from a command line. The resulting downloads are not available to the project in Idea. However, after the dependencies have been resolved once, the artifacts are cached in Nexus's Maven proxy repository allowing Gradle/Idea to correctly resolve all dependencies.

What could be causing Gradle/Idea's failure to resolve artifacts through Nexus's Maven proxy? Is there a way to get Gradle/Idea to correctly resolve dependencies through the Nexus Maven group/proxy?

For now I've just added mavenCentral() to the repository list in build.gradle but I would prefer to only include the Nexus Maven group in the future. Caching resources for 1GB/s download is really nice. I would also like to better understand Gradle/Idea and what is causing this issue.

More information:

  • Intellij Idea has been reinstalled to version 2018.2.6 Build #IC-182.5107.16 during the process of trying to fix this issue. The old version is lost to history.
  • Gradle has been updated to version 4.10.2. Previous version was 4.5.1.
  • I've printed each of the nexus* variables via println to ensure the values were correct.
  • No configuration of Idea's settings for Gradle (local Gradle distribution, default Gradle wrapper, Gradle 'wrapper' task configuration) managed to resolve dependencies.
  • Every configuration of deleting at least one of ./.idea, ./.gradle, and ~/.gradle/caches was tried.
  • Idea is not in offline-mode. Sequences of toggling offline-mode and "Refresh all Gradle projects" did not change the outcome.
  • I have run an Idea configuration of Gradle's dependencies task with --warning-mode all --debug and compared the log to the output of gradle dependencies --warning-mode all --debug on command line. The logs seem to be producing the same statements (in wildly different orders) until the "Could not resolve:" message appears in the Idea output. I did not find any nearby error messages that would explain the failure. If it would help diagnose the issue I can upload those files.
  • I have tried setting the repository to point directly at the Nexus Maven proxy instead of the Maven group. This did not allow Gradle/Idea to resolve dependencies.
  • Should I be using a http/https proxy for Gradle? I don't understand the goal of using a proxy in this context.
  • I have not done anything with Grail. I don't know what Grail is and suspect I do not currently need it.
  • OS is Windows 10.
  • Dependencies are not resolved when using compile or implementation in build.gradle.
  • Transitive dependencies don't seem to be relevant.
nlettner
  • 31
  • 5

1 Answers1

1

I must not have added the certificate to the correct jre installation. I added it more recently and the issue was resolved.

Also, superstitious notes for anyone else having a similar issue:

  • I added the certificate (a wildcard certificate) under the alias (using the -alias command line parameter for keytool): *.example.com
  • I also added it under an alias for the full address: nexus.example.com

I don't know whether either of those had any impact on Idea/Gradles' success in resolving artifacts. I believe it was working before I added the second alias.

nlettner
  • 31
  • 5