gradle won't sync plugins anymore - gradle

Gradle is running an experiment today, where they disable all HTTP communication: https://blog.gradle.org/decommissioning-http
Yesterday, I could sync my project just fine; I am not using a proxy or any other 'funky' setup.
buildscript {
ext {
...
}
repositories {
mavenCentral()
}
dependencies {
...
}
}
plugins {
id "com.palantir.docker" version "0.20.1"
}
repositories {
mavenCentral()
}
While yesterday I could download the dependencies (--refresh-dependencies), it does not work today.
./gradlew clean build --refresh-dependencies now fails with an error:
* What went wrong:
A problem occurred configuring root project 'myproject-backend'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.20.1.
Required by:
project : > com.palantir.docker:com.palantir.docker.gradle.plugin:0.20.1
> Could not resolve gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.20.1.
> Could not get resource 'https://plugins.gradle.org/m2/gradle/plugin/com/palantir/gradle/docker/gradle-docker/0.20.1/gradle-docker-0.20.1.pom'.
> Could not HEAD 'https://plugins.gradle.org/m2/gradle/plugin/com/palantir/gradle/docker/gradle-docker/0.20.1/gradle-docker-0.20.1.pom'.
> peer not authenticated
It's also not related to this specific plugin, all my other projects won't sync either (e.g. spring plugin cannot be synced, flyway plugin cannot be synced etc.).
I tried to upgrade my gradle version to the new 6.0, but this did not help either.
Any advice on how to solve this?
Thank you.
// EDIT: My gradle-wrapper.properties file looks like this:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

It may be related to your java version.
Gradle added support for TLSv3 on the 14.11.2019 (and disabled TLSv1.0) in plugins.gradle.org, and it seems that "old" Java versions have problems with it:
https://status.gradle.com/incidents/q2vq49fndxg0
For us it failed with 11.0.1, and we had to upgrade to 11.0.5

Related

gradle can't download ua-parser file

I'm trying to test some jenkins job seed dsls and for that I needed to download in gradle all plugins jenkins had, one of them was blueocean and in my build.gradle I've got this line
testPlugins 'io.jenkins.blueocean:blueocean:1.23.2'
and I get thrown this exception
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find ua_parser:ua-parser:1.3.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- https://repo.maven.apache.org/maven2/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
- http://repo.jenkins-ci.org/releases/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- http://repo.jenkins-ci.org/releases/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
- https://jcenter.bintray.com/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.pom
- https://jcenter.bintray.com/ua_parser/ua-parser/1.3.0/ua-parser-1.3.0.jar
Required by:
project : > io.jenkins.blueocean:blueocean:1.23.2 > io.jenkins.blueocean:blueocean-rest-impl:1.23.2
I tried running with gradlew 4.8.1 and 6.0.1
I tried addint the ua-parser to build.gradle
compile group: 'ua_parser', name: 'ua-parser', version: '1.3.0'
I tried removing all gradle cache and refresh dependencies
rm -rf ~/.gradle/cache
./gradlew test --refresh-dependencies # or ./gradlew build ..
I disabled the vpn so it wasn't some firewall not allowing me to connect to the site, maybe I have some outdated gradle repository stored ? (I'm not familiar with gradle yet, so maybe something simple is escaping my sight)
EDIT 1:
I think this might be related to missing repository so tried adding new one by hand I found the https://github.com/jenkinsci/blueocean-plugin and tried add it to settings.gradle
sourceControl {
gitRepository("https://github.com/jenkinsci/blueocean-plugin.git") {
producesModule("org.gradle.blueocean:utilities")
}
}
and then referencing in build.gradle
dependencies {
...
implementation 'org.gradle.blueocean:utilities'
but doesn't seem to work, does anyone know how to add/where to search for gradle repositories (specifically with blueocean poms)
had to add those lines in repositories in build.gradle
repositories {
mavenCentral()
maven { url 'http://repo.jenkins-ci.org/releases/' }
maven { url 'https://mvnrepository.com/artifact/io.jenkins.blueocean' }
maven { url 'https://mvnrepository.com/artifact/ua_parser/ua-parser' }
maven { url 'https://mvnrepository.com/artifact' }
maven { url 'https://maven.twttr.com/' }

Plugin [id: 'org.springframework.boot', version: '2.2.4.RELEASE'] was not found in any of the following sources:

I have just downloaded the springboot project from http://start.spring.io/. After running it I got this error.
* What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.2.4.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.2.4.RELEASE')
Searched in the following repositories:
Gradle Central Plugin Repository
* 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.
Can any one please suggest what is root cause.
I would recommend you to run gradle build command in your terminal.
After this, do a gradle sync.
Must be some problem with your IDE.
Hope this solves your issue.
Accepted answer didn't work for me. I am able to resolve this after adding settings.gradle file in project root with,
settings.gradle:
pluginManagement {
repositories {
maven { url "<Repo_URL>" }
}
}
In my case I had configured a proxy from my job in the gradle.properties file, but I wasn't through their VPN.
If this is also your case, you can just comment the lines in that file, or just connect to the VPN if it is possible.
I could solve it as follows:
In the build.gradle file add the following lines:
Then you must open a command window and enter the folder where you have the project and execute the following order:
gradle build
That's it, with this your error must be solved ... Greetings !!!
None of the answers above worked for me, what fixed it was removing '.RELEASE' from the version (see here)
id("org.springframework.boot") version "2.5.4.RELEASE"
to
id("org.springframework.boot") version "2.5.4"
I had this problem, too. I used the OpenJDK 1.8 in my Spring Boot Project which for whatever reason created these complications, so I changed it to Amazon Corretto JDK 11 and the sync and build ran without errors.
If you use IntelliJ I would recommend you to change your SDK in the Project Structure/Project, Project Structure/Modules and Project Structure/SDKs and finally change the Gradle JVM to the new JDK version in Settings/Build, Execution, Deployment/Build Tools/Gradle/GradleJVM.
You are using incompatable gradle versions!!!
Check your gradle version:
your gradle version: gradle --version
project version: gradle/wrapper/gradle-wrapper.properties has property distributionUrl where you can find project version
If there is difference between your gradle version and project gradle version just download and use project gradle version https://gradle.org/releases/
I had this issue too, after trying out all the above it wasn't resolved. Then by trying gradle with other versions and other version of JDK, then I figured out that it was due to SSL authentication issue. In my case I have to add the security certificates from my local nexus repository to the JDK used by Gradle and the problem was resolved.
You can download the SSL certificates by browsing to the nexus repository manager and downloading it from the browser.
Guys for me was just old Gradle version, I updated following this link https://gradle.org/install/. For Ubuntu:
$ mkdir /opt/gradle
$ unzip -d /opt/gradle gradle-7.0.2-bin.zip
$ ls /opt/gradle/gradle-7.0.2
LICENSE NOTICE bin getting-started.html init.d lib media
Team adding below in build.gradle will help solve the issue:
allprojects {
apply plugin: 'maven'
apply plugin: "io.spring.dependency-management"
group = 'com.wnp'
version = '6.5.0-SNAPSHOT'
}
I had the same error. The reason was in my Windows machine path to the java certs in gradle.properties file having in correct format (i.e / instead of \ ) systemProp.javax.net.ssl.trustStore=<JAVA_HOME>\\lib\\security\\cacerts
The default build.gradle file generated by spring.io only includes mavenCentral in repositories. Not sure why, but once in a while, this error shows up. Add jcenter as well in there, it should work.
To be more clear repositories could look like following after change
repositories {
jcenter()
mavenCentral()
}
In my case I was on vpn and it blocked the traffic from above repositories.
First of all you need to understand the problem. Why did this error occur ?
The lines in build.gradle file
plugins {
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
tells gradle that "spring" and "java" are required for you project to build.
Plugins are task in gradle.
Now for compiling the project the gradle has to bring these plugins specified. for that it
will look in the repositories that you have specified. in
repositories {
mavenCentral()
}
So There must not be any problem with the Code. Refreshing must solve

Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.71'] was not found in any of the following sources

I have a fresh install of IntelliJ, I created a new kotlin gradle project using the following settings:
This produces the following build.gradle.kts, (the exact same file works on my Windows machine):
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.2.71"
}
group = "com.test"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
compile(kotlin("stdlib-jdk8"))
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
Which produces this error, when trying to do a gradle refresh:
Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.71'] was not
found in any of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.2.71')
Searched in the following repositories:
Gradle Central Plugin Repository
Check your Internet connection and make sure your Internet is not restricted.
I solved this problem by turning on proxy for all tunnels (not just HTTP) with a VPN app.
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
// kotlin("jvm") version "1.2.71"
}
group = "com.test"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
compile(kotlin("stdlib-jdk8"))
}
//tasks.withType<KotlinCompile> {
// kotlinOptions.jvmTarget = "1.8"
//}
gradle sync by commenting the above lines. The gradle will be set up.
once the gradle is downloaded, uncomment those line and sync again.
if the dependencies are not downloaded properly, run 'gradle build' in the terminal and click on gradle sync.
This solved the issue for me.
(1) in my case (OpenJDK 11 on Ubuntu 18.04) the problem was Gradle not being able to download the POM file from gradle plugin-server. you can test it by entering this line into jshell:
new java.net.URL("https://plugins.gradle.org/m2/org/jetbrains/kotlin/jvm/org.jetbrains.kotlin.jvm.gradle.plugin/1.3.11/org.jetbrains.kotlin.jvm.gradle.plugin-1.3.11.pom").openStream()
(you can find your url by running gradle with --debug option)
So if you received an exception like this: InvalidAlgorithmParameterException: trustAnchors parameter must be non-empty then the trouble is CA-certs cache. which could be easily fixed by writing these lines into bash Ref:
sudo su
/usr/bin/printf '\xfe\xed\xfe\xed\x00\x00\x00\x02\x00\x00\x00\x00\xe2\x68\x6e\x45\xfb\x43\xdf\xa4\xd9\x92\xdd\x41\xce\xb6\xb2\x1c\x63\x30\xd7\x92' > /etc/ssl/certs/java/cacerts
/var/lib/dpkg/info/ca-certificates-java.postinst configure
By the way do not forget to restart gradle daemon before trying again. (gradle --stop)
(2) another reason could be your internet not having access to bintray.com (the internet of Iran or China) which you can test by putting this line on jshell :
new java.net.URL("https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.3.11/kotlin-gradle-plugin-api-1.3.11.pom").openStream()
If you received a connection timeout, it confirms this theory. In this case you need to buy and have proxy/vpn connected in order to be able to download these dependencies.
Check your gradle and kotlin (or Java) versions.
I got the same error and my issue is solved by specifying the kotlin version in build.gradle:
Before:
plugins {
id 'org.jetbrains.kotlin.jvm'
}
After:
plugins {
id 'org.jetbrains.kotlin.jvm' version "1.4.10"
}
In my case (Ubuntu 20.04), problem was with gradle 7.2, installed from snap.
I have removed gradle 7.2, installed from snap and install gradle 7.2 from sdkman. Works fine for me.
If you are using java like me .I got the issue fixed by adding the following:
Root gradle
dependencies {
ext.kotlin_version = '1.4.10'
classpath "com.android.tools.build:gradle:7.0.4"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
......
}
App gradle file
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
dependencies {
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-compiler:2.38.1"
......
}
Ok, so the answer was very simple all along. For some reason I activated gradle's "Offline work" toggle and that was the cause of the problem.
To disable it simply go to Settings > Build, Execution, Deployment > Build Tools > Gradle and deselect the "Offline work" checkbox.
In my case the problem was because Charles Proxy. After closing Charles I could start working again
I updated my Kotlin version to 1.7.20 and fixed this problem.
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
I recently had similar issue with an empty project autogenerated by Intellij Idea.
Solved this problem by combining Java and Gradle versions.
Initially I had Oracle Java 8 with Gradle 6.8.3.
After several attempts I found a working combination - AdoptOpenJDK 11 and Gradle 5.6.4
In my case I changes the Gradle JVM in Settings > Build, Execution, Deployment > Build Tools > Gradle and it worked.
Disconnect from your VPN (or make sure you have an open internet connection), then restart Android Studio.
If you don't restart it sometimes it continues with invalid proxy properties.
This for Ktor devs. If you are working on a ktor application with the web project generator there is a chance the generator sets invalid jvm plugin version. So make sure you are setting correct version for jvm plugin. You can find the latest jvm plugin version here. Here is the sample build.gradle.kts file.
//Plugin section
plugins {
kotlin("jvm") version "1.8.0"
id("io.ktor.plugin") version "2.2.2"
}
//Dependancy section
dependencies {
...
testImplementation("io.ktor:ktor-server-tests-jvm:1.8.0")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.8.0")
...
}

Gradle version 3.3 does not support forTask() method on BuildActionExecuter

I just updated my Android Studio to 3.0 canary 1.
Now I am working on my existing project on Android Studio 3.0 canary 1.
By default gradle:3.0.0-alpha1 is set in my project: gradle_file.
So I changed my gradle version to 2.2.3 and now I'm getting this error:
Error:Failed to complete Gradle execution.
Cause: The version of Gradle you are using (3.3) does not support the
forTasks() method on BuildActionExecuter. Support for this is
available in Gradle 3.5 and all later versions.
I attached my gradle file here
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I've just had the same issue. Fixed it by changing Gradle distributionUrl in "gradle-wrapper.properties".
Here is what I have configured:
#Wed Mar 22 16:13:58 BRT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
for more details
Offical video to help migaration
https://www.youtube.com/watch?v=oBsbI8ICYKg
see also comment below from #TmTron
Change in the file "gradle-wrapper.properties".
Put this line and Sync Project-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
This will work. For Check latest version services.gradle.org/distributions
After changed, Sync Project, Clean and Rebuild project once from Build menu.
This happened when trying to build debug apk.
SOLUTION: Update Gradle version to 3.5
Navigate to File -> Project Structure -> Project -> Gradle Version = 3.5
This works for Android Studio 3.0
Please follow the below steps:
Open your project in android studio
In Android menu, open gradle-wrapper.properties
Change the distribution url line with the below line
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
Thats it. Build your project now.
Screenshot is attached for more understanding.
I resolved the issue by changinf distributionUrl in the following code in gradle-wrapper.properties file
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Once add these with Top level Gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
We have two way to deal with it.
You can update your gradle's version from the early one to 3.5 version product;
Or,you can figure your gradle wrapper to 4.1 version.
All of the ways are both useful.
Only Change the gradle URL to
"distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip"
as follow image :
Open gradle-wrapper.properties
Replace:
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
With:
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
Now sync project
Click here for more understand
put this code in gradle-wrapper.properties file and it will work with you
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

Gradle dependency resolution error, <exclude org: module="l:ame="*" type="*

When running the "war" task for a web application project using Gradle 1.10, the following error started showing up when I included a dependency on cxf-bundle 2.6.13:
Could not resolve all dependencies for configuration ':runtime'.
Could not resolve <exclude org: module="l:ame="*" type="*.
Required by:
:gradle_dep_issue_example:unspecified > org.apache.cxf:cxf-bundle:2.6.13
java.lang.IllegalArgumentException (no error message)
Stopping and starting the gradle daemon has no effect, nor does clearing out the .gradle folder. However, running the war task and passing the --refresh-dependencies option does resolve the issue. Unfortunately, the --refresh-dependencies option must be used every time.
Here is a small build.gradle file which will reproduce the issue when the "downloadRuntimeDeps" task is run.
apply plugin: 'war'
repositories {
mavenCentral()
}
dependencies {
compile 'org.apache.cxf:cxf-bundle:2.6.13'
}
task downloadRuntimeDeps(type: Copy){
from configurations.runtime
into new File(getBuildDir(), "/runtime-deps/")
}
The issue ended up only impacting gradle version 1.10. I tested with versions 1.8 and 1.11, and neither had this problem.
There are no bug fixes included in the release notes for gradle 1.11 that reference an issue like this, so I assume this was fixed while resolving a seemingly unrelated issue.
The solution was to upgrade all my projects to use gradle 1.11

Resources