I have cloned a Spring boot project from github and I have opened it in intellij. So I am trying to run the build.gradle but I just get this error:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.3.3.RELEASE']
Failed to apply plugin [id 'org.springframework.boot']
Spring Boot plugin requires Gradle 5 (5.6.x only) or Gradle 6 (6.3 or later). The current version is Gradle 5.2
This is the plugin:
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
What is going on here?
You have Gradle version 5.2. The error states that the Spring Boot plugin specifically requires either 5.6.x (e.g., 5.6.4) or a version greater than or equal to 6.3 (e.g., 6.3, 6.6.1).
You need to upgrade your Gradle version to a 5.6 variant or a newer version that is greater than or equal to 6.3.
You need to configure a Gradle version for a project to be 5.6.x only or 6.3 or later:
If wrapper.properties is used for the project the Gradle version is saved in the gradle-wrapper.properties file in the gradle directory of your project.
See detailed steps at Configure a Gradle version for a project
documentation page.
Related
I'm getting a weird resolution error when trying to upgrade to spring boot 3. I have a kotlin/spring project. The only thing sort of related is this, but it's not the same dependency.
Here's the error:
Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.0.
Here's my dependency declaration:
plugins {
id 'io.spring.dependency-management' version '1.1.0' // latest at this time
id 'org.springframework.boot' version '3.0.0'
id 'org.jetbrains.kotlin.plugin.jpa' version '1.7.10'
id 'org.jetbrains.kotlin.plugin.spring' version '1.7.10'
}
Here's my full output:
What I've tried:
Switching to Java 17
Searching online for the same exact error - no luck so far. (11-29-2022 10AM ET)
Modify the Gradle JVM in the settings
Hello i want to create a Spring boot app with kotlin and Gradle but i have this issue in the plugins line, it doens't recognize any plugin i add ,i couldn't undrestand what's missing, i'm using Gradle 6.3v , jdk 8
Error:
Error
And that's the build.gradle file
build.gradle.kts
Your first plugin declaration has a typo in the version:
kotlin("jvm") version "1.3.11" needs to be kotlin("jvm") version "1.3.71"
I would start by changing that so all usages of kotlin plugins are aligned on a recent version.
If that does not resolve the problem, try running the build from the CLI with the added flag --stacktrace which may tell you more about why is the plugin not found.
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
I'm trying to publish an artifact to ~/.m2 (maven-local) and as a Gradle newbie, i'm not sure what i'm missing
All the examples i've seen so far suggests using a publishing block which throws deprecation warnings when i run any Gradle commands.
Also including the maven-publish plugin without any publishing block causes the same warnings.
repositories {
mavenLocal()
jcenter()
}
plugins {
`maven-publish`
kotlin("jvm") version("1.3.10")
id("org.jetbrains.dokka") version "0.9.16"
}
As part of making the publishing plugins stable, the 'deferred
configurable' behavior of the 'publishing {}' block has been
deprecated. In Gradle 5.0 the
'enableFeaturePreview('STABLE_PUBLISHING')' flag will be removed and
the new behavior will become the default. Please add
'enableFeaturePreview('STABLE_PUBLISHING')' to your settings file and
do a test run by publishing to a local repository. If all artifacts
are published as expected, there is nothing else to do. If the
published artifacts change unexpectedly, please see the migration
guide for more details:
https://docs.gradle.org/4.10.2/userguide/publishing_maven.html#publishing_maven:deferred_configuration.
If it actually published to maven-local, i might have ignored the warning for now, but it's not publishing at all, neither does gradle publishToMavenLocal, it simply says BUILD SUCCESSFUL in __s with the above warning.
Trying the recommended route (according to the link) of adding the publishing block inside a subprojects block causes lots of red in intellij
Not sure if that's Kotlin DSL or not ... trying something else that was shown on the Kotlin DSL version of the Gradle Docs:
Any idea what i'm missing?
Here's my Gradle version and other relevant info (IntelliJ has Kotlin 3.1.0)
gradle -version
------------------------------------------------------------
Gradle 4.10.2
------------------------------------------------------------
Build time: 2018-09-19 18:10:15 UTC
Revision: b4d8d5d170bb4ba516e88d7fe5647e2323d791dd
Kotlin DSL: 1.0-rc-6
Kotlin: 1.2.61
Groovy: 2.4.15
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 1.8.0_151 (Oracle Corporation 25.151-b12)
OS: Mac OS X 10.14.1 x86_64
I think all you need to do is apply the maven plugin then run the install task. Details of how to apply the plugin are here, e.g. using the Kotlin DSL you'd have:
plugins {
maven
}
Then you just run the install task, e.g. from your IDE (the Gradle window in IntelliJ in your case) or a command line, e.g. ./gradlew install.
Regarding applying the maven plugin, if you're new to Gradle you probably want to get clear on the Gradle plugins DSL (which the above code snippet is an example of). If you're not using that then the way you apply the plugin is slightly different (e.g. you have to use the apply command). There are details here. Note that the decision about whether to use the Gradle plugins DSL is different from the choice of using Groovy or Kotlin for the language in which you write the build.gradle file.
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")
...
}