I have a project, with `settings.gradle` and `buil...
# community-support
s
I have a project, with
settings.gradle
and
build.gradle
like this:
settings.gradle
Copy code
pluginManagement {
    repositories {
       maven {
            url = '
<http://myserver/artifactory/pg-Thirdparty>'
			allowInsecureProtocol = true
			
			metadataSources {
				mavenPom()
				artifact()
				gradleMetadata()
			}
        }
		
		
		// Fallback to Gradle Plugin Portal
		//gradlePluginPortal()
		
		// Optionally add Maven Central as a fallback
        //mavenCentral()
    }
}
build.gradle
Copy code
plugins {
	id "java"
	
    id("org.sonarqube") version "6.0.1.5171"
    
//id("com.github.seanrl.jaxb") version "2.5.5"
	//id("com.diffplug.spotless") version "7.0.2"
	//id "com.osacky.doctor" version "0.10.0"
	//id("com.github.pt-osda.java-dependencies-analysis") version "1.0.4"
	//id("org.sonarqube") version "6.0.1.5171" 
	//id("io.github.gmazzo.importclasses") version "1.1.0"
	//id("com.autonomousapps.dependency-analysis") version "2.7.0"
}
whereas
pg-Thirdparty
is a virtual repo configured with maven central repo and gradle plugin repo (https://plugins.gradle.org/m2/) but plugins not getting downloaded via our org artifactory. If i uncomment
//gradlePluginPortal()
it just works , but we are not supposed to use like this. Tried all my ways to fix this, unfortunately couldn’t find a reason for this. Some plugins its working but some its not working. For example, in above
//id "com.osacky.doctor" version "0.10.0"
this works if i uncomment but
sonarqube
plugin not working. Getting below error:
Copy code
```
```> Could not resolve all files for configuration ':classpath'.
   > Could not find org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:6.0.1.5171.
     Searched in the following locations:
       - http:
//myserver/artifactory/pg-Thirdparty/org/sonarsource/scanner/gradle/sonarqube-gradle-plugin/6.0.1.5171/sonarqube-gradle-plugin-6.0.1.5171.pom
       - <http://myserver/artifactory/pg-Thirdparty/org/sonarsource/scanner/gradle/sonarqube-gradle-plugin/6.0.1.5171/sonarqube-gradle-plugin-6.0.1.5171.module>
       - <http://myserver/artifactory/pg-Thirdparty/org/sonarsource/scanner/gradle/sonarqube-gradle-plugin/6.0.1.5171/sonarqube-gradle-plugin-6.0.1.5171.jar>
     Required by:
         project : > org.sonarqube:org.sonarqube.gradle.plugin:6.0.1.5171
There is no issue with connectivity from our artifactory server to gradle plugins repository. Please note im able to use plugins in older format like
buildscript{}
block with dependencies declaration but its failing only with
plugins{}
block. Couldn’t figure out if this is issue with our artifactory configuration or gradle build configuration. I’m using
gradle-7.6.4
with JAVA 17.
v
Some plugins its working but some its not working. For example, in above
//id "com.osacky.doctor" version "0.10.0"
this works if i uncomment but
sonarqube
plugin not working.
Osacky Doctor plugin in that version is not published to GPP but MC, SQ plugin in that version is not published to MC but GPP. So that difference would indeed hint at the connection of your mirror to GPP is the problem. Maybe try to resolve a different version of SQ plugin, maybe you requested the new version when it was not yet available and your mirror remembers that and does not recheck. If for example
6.0.0.5145
works.
s
You are right. I tried
3.3
version which is in MC, it worked.. but surely there's no connection issue i feel.. because when we added gradle plugin repo to our virtual repo, there is a Test option in jfrog artifactory UI and it said 'connection successful'. One more strange thing i observed, if i comment out
pluginManagement
block in
settings.gradle
, its able to download the all the plugin versions which are present only in GPP too. I'm confused.. I'm not sure why its failing when i have
pluginManagement
block with our repo URLs in
settings.gradle
. Also one more thing i missed mentioning.. i have one
initscript.gradle
which has buildscript block like this:
buildscript {
repositories {
maven {
url "<http://myserver/artifactory/pg-Thirdparty>"
allowInsecureProtocol = true
}
}
}
So if i remove
pluginManagent
block in
settings.gradle
, is it considering
initscript
configuration to download plugins? but if that is true, why the same piece of configuration not working when i have it in
settings.gradle
.. This all behavior i observed in my local machine ie., removing
pluginManagement
block working fine, when checked log, looks like its directly connecting to GPP for which we have connectivity from our local machines. If remove
pluginManagement
block its failing in gitlab runners becoz runners don't have connectivity to thirdparty repos like MC, GPP etc, for the same reason we are adding thirdparty repos to our virtual repository and using the same. For plugins which are present in MC its working even in runners via our artifactory.. but which are present only in GPP, its failing via our artifactory.. but conn showing as successfull .. totally confused.. 😕
Got the issue. while downloading, plugins.gradle.org redirecting to plugins-artifacts.gradle.org for which artifactory server doesn't have connectivity via our proxy and so its failing. We whitelisted this and it started working. Documentation just says 'plugins.gradle.org' Looks like documentation need to be updated. :)
👌 1
v
there is a Test option in jfrog artifactory UI and it said 'connection successful'.
Just that it can connect does not mean it can download. And even if it could, the actual artifacts are on some CDN servers, so your setup has to follow the redirects it gets. It would be the same if you previously had used the Osacky Doctor plugin and only had GPP as plugin repository and only enabled GPP but not MC on your mirror. Because GPP sends redirects to MC for all things it does not host itself. So Osacky Doctor plugin would resolve from GPP but not from your mirror if it does not follow redirects.
One more strange thing i observed, if i comment out
pluginManagement
block in
settings.gradle
, its able to download the all the plugin versions which are present only in GPP too. I'm confused..
Why? GPP is the default. nothing => GPP anything => only what is added explicitly
Documentation just says 'plugins.gradle.org' Looks like documentation need to be updated. 🙂
I'm not sure which part of the docs you are referring to, so I don't know what exactly it says. But I guess it says you "need to be able to download from plugins.gradle.org" or "you need to mirror plugins.gradle.org" or similar, which is correct and sufficient imho. Because if you proxy requests to plugins.gradle.org, following redirects, and cache the result this is enough and fine. That you additionally have a firewall that blocks access to other domains which are an implementation detail of the plugin portal is a different topic and imho that does not belong to the docs, as this could also easily change as it is an implementation detail of the server and not "part of its API". But feel free to open a ticket, could well be that Gradle folks agree with you and add the information. 🤷‍♂️
👍 1
s
Thank you. This is the documentation i was referring to: https://plugins.gradle.org/docs/mirroring It just says The URL to mirror is https://plugins.gradle.org but didn't talk about further details. So we initially configured this in our virtual repo and got it whitelisted at our proxy. Didn't realize it will do some redirections while downloading plugins actually. It took me sometime to figure this out. When i tried through simple CURL request at artifactory server, identified Location header which redirects to
<http://plugins-artifacts.gradle.org|plugins-artifacts.gradle.org>
to fetch actual plugin contents, which is failing as we didn't whitelist this at our org proxy. So i'm just saying it would be good if document says about these redirection details so that we can get network changes done at once 🙂 But yeah what you said also right, its internal to gradle plugin portal stuff which might change any time.
v
Yeah, of course I got you. Just saying the docs are not wrong. If you mirror that URL that is enough as mirroring would include following the redirects. I only mirror that URL in our Nexus and it works fine. Your problem is the proxy / firewall which does not like the redirects as you found out. So as I said, feel free to open a ticket, probably at https://github.com/gradle/plugin-portal-requests/issues to get information or at least a warning / hint about proxies / firewalls added.
👌 1