New for Gradle here. Trying to run a demo kotlin project created through springboot.io with Kotlin+Gradle.
Ensured kotlin, Gradle, Java installed through the commands kotlin --version, gradle --version and java.
JAVA
java -version
openjdk version "17.0.9" 2023-10-17 LTS
OpenJDK Runtime Environment Corretto-17.0.9.8.1 (build 17.0.9+8-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.9.8.1 (build 17.0.9+8-LTS, mixed mode, sharing)
GRADLE
gradle --version
------------------------------------------------------------
Gradle 8.7
------------------------------------------------------------
Build time: 2024-03-22 15:52:46 UTC
Revision: 650af14d7653aa949fce5e886e685efc9cf97c10
Kotlin: 1.9.22
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 17.0.9 (Amazon.com Inc. 17.0.9+8-LTS)
OS: Mac OS X 13.4 x86_64
KOTLIN
kotlin -version
Kotlin version 1.9.24-release-822 (JRE 17.0.9+8-LTS)
when I execute the gradle build the below error keep consuming my time. Any help to progress would be highly appreciated.
I deeply searched through net for any climbs to proceed.
I tried to troubleshoot the issue with gradle build --scan and gradle build --stacktrace and I almost get the same error as below
* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.9.22'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.22')
Searched in the following repositories:
Gradle Central Plugin Repository
Google
MavenRepo
I referred through mavenrepo and I can see the kotlin plugin. Really unsure why still it says the plugin could not be found.
Any help would be great and Thanks for your time reading this.
Some general notes not directly related to your issue:
which Kotlin version you have installed (or whether you have any at all) is more or less pointless for the Gradle build as the installed Kotlin version is not used, but what you use in the build script. The installed Kotlin version is handy if you want to execute Kotlin Script files (...kts) or if you want to compile Kotlin sources without using Gradle
which Gradle version you have installed (or whether you have any at all) is more or less pointless, usually you never need and Gradle version installed at all, as each Gradle project should usually contain the 4 Gradle Wrapper files that control which version is used to build the project and auto-provisions it and you should always use the Gradle Wrapper to build a project. An installed Gradle version is usually only helpful for projects missing the Wrapper files (which I consider a build bug in the project), or to bootstrap a new Gradle project, but for that you usually can also use your IDE which usually comes with a Gradle version shipped, or even the wrapper of another Gradle build you have on disk.
Declaring mavenCentral()aftergradlePluginPortal() is just wasting time if something is not found. gradlePluginPortal() redirects to JCenter for anything it does not serve itself and JCenter is forwarding to MavenCentral for things it does not serve itself, so if something was not found in gradlePluginPortal(), it will also not be found in mavenCentral(). Having mavenCentral()beforegradlePluginPortal() can make sense to mitigate one of the regular outages of JCenter if the missing thing is actually on MavenCentral, not on JCenter itself, and can save the redirect through JCenter if something is actually available on MavenCentral.
Regarding the error message, I have no idea why the plugin is not found, but applying the Kotlin Gradle Plugin in the settings script is anyway wrong, even if it would have been found, application will fail as it is a project plugin that needs to be applied in your build script, not a settings plugin.
Now why it is not found I donât know.
As you correctly said, it is available on mavenCentral() and thus also on gradlePluginPortal().
You could try rerunning with --refresh-dependencies in case it was some temporary quirk and Gradle just remembers that it did not find it.
If it is still not found, you can additionally add --info or --debug to maybe get more information what exactly happens when it tries to download the plugin.
Most often this is caused by some Firewall, Anti-Virus, or proxy, or the need to use a Proxy while not having it configured for Gradle.
Thanks so much for reading my issue and sharing your thoughts.
I tried to run the build with gradle build info and below is what I get it as and noticeably âBuild cache is disabled all the way down and the process terminatesâ. Is that gives any clue here?
Starting Build
Caching disabled for Kotlin DSL script compilation (Settings/TopLevel/stage1) because:
Build cache is disabled
Caching disabled for Kotlin DSL script compilation (Settings/TopLevel/stage2) because:
Build cache is disabled
Settings evaluated using settings file '/Users/Ms@hh.com/Desktop/SnapshotService/demo/settings.gradle.kts'.
Projects loaded. Root project using build file '/Users/Ms@hh.com/Desktop/SnapshotService/demo/build.gradle.kts'.
Included projects: [root project 'root-project']
> Configure project :
Evaluating root project 'root-project' using build file '/Users/Ms@hh.com/Desktop/SnapshotService/demo/build.gradle.kts'.
Caching disabled for Kotlin DSL script compilation (Project/TopLevel/stage1) because:
Build cache is disabled
FAILURE: Build failed with an exception. I'm thinking why the build should go suddenly informing build cache disabled but I didn't do this intentionally.
Plugin in the settings script is anyway wrong, even if it would have been found, application will fail as it is a project plugin that needs to be applied in your build script, not a settings plugin. Removed plugin from settings.gradle.kts and the situation is similar.
Having mavenCentral()beforegradlePluginPortal() - mavenCentral() moved to first place now after understanding why it should be scanned first. Thanks
When I tried to gradle build --scan and got as below âŠ
gradle build --scan
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all artifacts for configuration 'classpath'.
> Could not resolve com.gradle:gradle-enterprise-gradle-plugin:3.16.2.
Required by:
unspecified:unspecified:unspecified
> Could not resolve com.gradle:gradle-enterprise-gradle-plugin:3.16.2.
> Could not get resource 'https://repo.maven.apache.org/maven2/com/gradle/gradle-enterprise-gradle-plugin/3.16.2/gradle-enterprise-gradle-plugin-3.16.2.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/com/gradle/gradle-enterprise-gradle-plugin/3.16.2/gradle-enterprise-gradle-plugin-3.16.2.pom'.
> Got SSL handshake exception during request. It might be caused by SSL misconfiguration
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.gradle:gradle-enterprise-gradle-plugin:3.16.2.
> Could not get resource 'https://plugins.gradle.org/m2/com/gradle/gradle-enterprise-gradle-plugin/3.16.2/gradle-enterprise-gradle-plugin-3.16.2.pom'.
> Could not GET 'https://plugins.gradle.org/m2/com/gradle/gradle-enterprise-gradle-plugin/3.16.2/gradle-enterprise-gradle-plugin-3.16.2.pom'.
> Got SSL handshake exception during request. It might be caused by SSL misconfiguration
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I tried to build with out VPN connection but I still stay with the same issue of Plugin [id: 'org.jetbrains.kotlin.jvm'] was not found in any of the following sources:
Thatâs using the installed Gradle version which I said you should not use to execute a build, but always the Gradle wrapper gradlew that is part of the project
âBuild cache is disabled all the way down and the process terminatesâ. Is that gives any clue here?
The build cache is not enabled by default, that is just an informational warning and not any cause for build failure. See Build Cache for further information.
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
This means the HTTPS connection cannot be done securely.
This can have many reasons, for example a man-in-the-middle attack, or some portal page showing instead of the real response, or broken certificates in the Java you use to run Gradle, âŠ
To really investigate you would need to enable javax.net.debug logging and be able to interpret the output.
I installed gradle manually through homebrew. should not I install manually if the gradle project is imported from other repo? If already installed, should I uninstall now. I keep getting the below issue. Java home version is pointing to /Users/M@i.com/Library/Java/JavaVirtualMachines/corretto-17.0.9/Contents/Home. If I select gradle to be controlled from IntelliJ in the screenshot then wonât that be controlled from the IDE? can you please clear my confusion? Thanks.
Could not open init generic class cache for initialization script â/private/var/folders/n1/qd4ndth54tzfcqnsp6lnnhl00000gq/T/wrapper_init9.gradleâ (/Users/M@g.com/Downloads/gradle-8.6/bin/caches/8.6/scripts/49u46auhyi0mkz3oj0077s53o).
BUG! exception in phase âsemantic analysisâ in source unit âBuildScriptâ Unsupported class file major version 66
I installed gradle manually through homebrew. should not I install manually if the gradle project is imported from other repo?
As I said, you practically never need any installed Gradle version, and especially not if you just try to build an existing project.
If already installed, should I uninstall now.
Doesnât matter, as long as you do not use it.
If you call gradle ... you do use it.
Never do that, always use ./gradlew ....
I keep getting the below issue. Java home version is pointing to /Users/M@i.com/Library/Java/JavaVirtualMachines/corretto-17.0.9/Contents/Home. If I select gradle to be controlled from IntelliJ in the screenshot then wonât that be controlled from the IDE? can you please clear my confusion? Thanks.
Yes, the option in the screenshot controls the version used to run Gradle.
One option is to use JAVA_HOME, but thatâs not what you selected, you selected to use the Project JDK which is Java 22.
And the error complains about exactly that, as you try to run Gradle 8.6 with Java 22 which is not supported: Compatibility Matrix
So which java version should we go with for gradle 8.6 here? Could you tell me how to the compatibility matrix given above works since I donât see 8.6 at all and I assumed from 8.4 to 8.7 java 22 supports?
No, not at all.
From 8.7 on you can use Java 22 as toolchain.
There is not Gradle version that can be run with Java 22 yet.
Gradle 8.6 can use up to Java 21 as a toolchain and up to Java 19 to run it with.