📣 Plugin Portal is now mirrorable

Follow these instructions to setup your own mirror: https://plugins.gradle.org/docs/mirroring

3 Likes

Using the opportunity to plug my old question about proxying/mirroring in restricted connectivity environment

Hi Eric,

I’m relatively new at Gradle and setting up Gradle proxy repo in Nexus. I created a proxy using your instructions in Nexus, however, Gradle keeps referring to https://plugins.gradle.org/m2 for downloading the plugins that I want it to download from our Nexus repo:
strong text
Download https://plugins.gradle.org/m2/com/moowork/gradle/gradle-grunt-plugin/0.13/gradle-grunt-plugin-0.13.pom
Download https://plugins.gradle.org/m2/com/moowork/gradle/gradle-node-plugin/0.13/gradle-node-plugin-0.13.pom
Download https://plugins.gradle.org/m2/com/moowork/gradle/gradle-node-plugin/0.13/gradle-node-plugin-0.13.jar
Download https://plugins.gradle.org/m2/com/moowork/gradle/gradle-grunt-plugin/0.13/gradle-grunt-plugin-0.13.jar
Download http://nexusrepo:8081/nexus/content/groups/gradle-build/com/moowork/gradle/gradle-node-plugin/1.2.0/gradle-node-plugin-1.2.0.pom
Download http://nexusrepo:8081/nexus/content/groups/gradle-build/com/moowork/gradle/gradle-node-plugin/1.2.0/gradle-node-plugin-1.2.0.jar

Here’s my build script block and plugins block:

buildscript{
repositories {
maven{
credentials{
username = ‘nexususer’
password = ‘nexuspassword’
}
url ‘http://nexusrepo:8081/nexus/content/groups/gradle-build/
}
}
}

plugins {
id “com.moowork.grunt” version “1.2.0”
id “com.moowork.node” version “1.2.0”
}

I’m not sure why it cannot get com.moowork.grunt plugin of version 1.2.0 from nexus as it does exists there. Also, earlier, i had 0.13 version listed and then updated it to 1.2.0 but it still downloads 0.13 version from Gradle portal. I cleared cached but that didn’t help.

Can you please advise, what I’m doing wrong?

Thanks,
Binoy

Hi Binoy,

You must use the pluginManagement {} DSL block in your settings.gradle file as documented here to affect where Gradle looks for plugins using the plugins {} DSL block.

Let me know if that does not solve your issues.

Cheers,
Eric

Yes, that seems to have resolved which repository to look at, but now I get this e
rror:

  • What went wrong:
    Plugin [id: ‘com.moowork.node’, version: ‘1.2.0’] was not found in any of the following sources:

This plugin does exist here : http://nexusrepo:8081/nexus/content/repositories/gradle-plugin/com/moowork/gradle/gradle-node-plugin/1.2.0/

I ran the build with debug and found this:

11:14:25.352 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection request: [route: {}->http://nexusrepo:8081][total kept alive: 0; route allocated: 0 of 20; total allocated: 0 of 20]
11:14:25.352 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection leased: [id: 15][route: {}->http://nexusrepo:8081][total kept alive: 0; route allocated: 1 of 20; total allocated: 1 of 20]
11:14:25.352 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {}->http://nexusrepo:8081
11:14:25.376 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connecting to nexusrepo/:8081
11:14:25.399 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connection established :38206<->:8081
11:14:25.399 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request GET /nexus/content/repositories/gradle-plugin/com/moowork/node/com.moowork.node.gradle.plugin/1.2.0/com.moowork.node.gradle.plugin-1.2.0.pom HTTP/1.1

I can see the connection gets established and then it does a GET request to the 1.2.0 pom file in a different path. Why is that?

It then fails with this message:

11:14:25.399 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Target auth state: UNCHALLENGED
11:14:25.399 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Proxy auth state: UNCHALLENGED
11:14:25.424 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection can be kept alive indefinitely
11:14:25.424 [DEBUG] [org.apache.http.impl.auth.HttpAuthenticator] Authentication required
11:14:25.424 [DEBUG] [org.apache.http.impl.auth.HttpAuthenticator] nexusrepo:8081 requested authentication
11:14:25.424 [DEBUG] [org.apache.http.impl.client.TargetAuthenticationStrategy] Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
11:14:25.424 [DEBUG] [org.apache.http.impl.client.TargetAuthenticationStrategy] Challenge for Negotiate authentication scheme not available
11:14:25.424 [DEBUG] [org.apache.http.impl.client.TargetAuthenticationStrategy] Challenge for Kerberos authentication scheme not available
11:14:25.424 [DEBUG] [org.apache.http.impl.client.TargetAuthenticationStrategy] Challenge for NTLM authentication scheme not available
11:14:25.424 [DEBUG] [org.apache.http.impl.client.TargetAuthenticationStrategy] Challenge for Digest authentication scheme not available
11:14:25.424 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection [id: 15][route: {}->http://nexusrepo:8081] can be kept alive indefinitely
11:14:25.424 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection released: [id: 15][route: {}->http://nexusrepo:8081][total kept alive: 1; route allocated: 1 of 20; total allocated: 1 of 20]
11:14:25.424 [INFO] [org.gradle.internal.resource.transport.http.HttpClientHelper] Failed to get resource: GET. [HTTP HTTP/1.1 401 Unauthorized: http://nexusrepo:8081/nexus/content/repositories/gradle-plugin/com/moowork/node/com.moowork.node.gradle.plugin/1.2.0/com.moowork.node.gradle.plugin-1.2.0.pom]

I’m not sure why is it looking for the plugin in a different path. Any advise?

Thanks,
Binoy

I have tested with other gradle plugins, i get the same results as shown above. Not sure why it can’t get plugins from Nexus and getting the connection established once and then Unauthorized the second time. Any information will be helpful.

Thanks,
Binoy

Would it not be possible to have a global settings.gradle?
I am concerned to having this pluginManagement duplicated in every code repository. What if we need to change something later, it would have to be changed in every repository and all branches. When we used Maven we only needed to change the ~/.m2/settings.xml

Perhaps if this could be used from a global settings.gradle at
~/.gradle/settings.gradle

We already have other default properties related to Nexus URL, Username and Password in ~/.gradle/gradle.properties.

Hi Eric,

This has been resolved. The pluginManagement in settings.gradle file was missing credentials block. I had the credentials in the subproject/build.gradle buildscripts block but that was not enough. This piece of information is missing in the documentation.

Thanks for your help!
-Binoy

I’m glad to read this Binoy.

Cheers,
Eric