Groovy version inside Gradle - gradle

I have upgrade gradle on my local machine.
then i checked the version, it returned;
------------------------------------------------------------
Gradle 4.10.2
------------------------------------------------------------
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_171 (Oracle Corporation 25.171-b11)
the groovy version is ; 2.4.15.
And I want to upgrade the gradle to 4.10.2 in my spring boot project, But I am using gradle 2.5.0 in my project.
is it caused any problem?
can we use 2.5.0 or any other groovy version in gradle 4.10.2?
What does the gradle's groovy version on my local machine mean?

There will be no foreseeable problems. It's basically like this: Gradle utilizes Groovy to run it's tasks - and in those you have this Groovy version at disposal. In the end it's just the build tool -- it's supposed to do a proper job at isolating class-path/-loading.
The Groovy plugin in Gradle will take care to pick up the proper version from your compile-time dependencies. So unless you are doing things in your tasks or mess with configurations, you should be pretty safe.
Since you mentioned Spring Boot: be sure to pin your Groovy version with ext['groovy.version'] = '2.5.3' though, or else you end up with the problem described above due to the ways the Spring Boot plugin deals with dependencies.

Related

What version of java does gradle use to run your application?

I have a JavaFX project I am working on using Gradle. What version of java is used when I use the gradle run task from the application plugin?
In IntelliJ I can go into the Gradle settings and change the "Gradle JVM" to any version I want. Is this just the version of java that is used to run the build? Or is this also the version that my application will be run on?
Where does my JAVA_HOME come into this, if at all?
Irrespective of IDEs, Gradle will use whatever language level of the JVM that is running Gradle. Typically whatever the value is for JAVA_HOME.
See Environment variables and Targeting a specific Java version
The new way to do it as of Gradle 6.7 is to use Toolchains for JVM projects
Your IDE should respect whatever Gradle configuration that is configured.

IntelliJ IDEA unable to resolve fine working gradle dependency

I'm currently working on a Kotlin project with Gradle (source code here). It's a Bukkit plugin which depends on a library I maintain (library source code here). When running ./gradlew assemble in a terminal, everything works fine and the build succeeds (log below).
$ ./gradlew assemble --console plain
> Task :compileKotlin
w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath
w: /home/axel/.gradle/caches/modules-2/files-2.1/com.github.axelrindle/PocketKnife/v1.3.0/b2303013bfd8e21c419f1d640ef374afc48e86af/PocketKnife-v1.3.0.jar: Library has Kotlin runtime bundled into it
> Task :compileJava NO-SOURCE
> Task :processResources
> Task :classes
> Task :inspectClassesForKotlinIC
> Task :jar
> Task :assemble
BUILD SUCCESSFUL in 5s
4 actionable tasks: 4 executed
But when working in IDEA, my library is the only one the IDE fails to resolve for whatever reason.
I've already tried the following steps:
Delete gradle/idea caches (~/.gradle/caches;.idea)
Reinstall IDEA
Delete IDEA config directory (.IdeaIC2019.1)
Reimport the project in IDEA
I've already read the following questions/answers, but none of them worked:
Getting Gradle dependencies in IntelliJ IDEA using Gradle build
Unable to resolve dependencies in IntelliJ IDEA 2018.1
Gradle dependencies not working in IntelliJ
IntelliJ won't recognize some imports from gradle project
Intellij: Gradle dependency not found
Also, my idea.log can be found here: https://pastebin.com/0Z5b3Wdp
Last but not least some version information:
IntelliJ IDEA 2019.1.3 (Community Edition)
Build #IC-191.7479.19, built on May 28, 2019
JRE: 1.8.0_202-release-1483-b58 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.18.0-21-generic
$ ./gradlew --version
------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------
Build time: 2019-04-26 08:14:42 UTC
Revision: 261d171646b36a6a28d5a19a69676cd098a4c19d
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 12.0.1 (Oracle Corporation 12.0.1+12)
OS: Linux 4.18.0-21-generic amd64
After a lot of failed troubleshooting, I found out what the problem was. My library contained the bundled kotlin runtime, which was causing impossible to debug resolving issues with IDEA. I split up the project into multiple subprojects, where the actual api dependency does not bundle the kotlin runtime. This fixed my issues.
I just cloned your repository from https://github.com/axelrindle/Broadcaster-Plugin
In your build.gradle file you are referencing version 1.2.2 of your PocketKnife artefact, which does not exist in your GitHub. If you use an existing version like 1.2.1 IntelliJ can resolve the dependency.

"unable to resolve class" error after upgrading gradle 3 to gradle 4

Grails version: 3.2.9
Gradle initial version: 3.4.1 (everything works fine with this version)
Gradle upgraded version:4.10.3
Plugin: org.grails.grails-gsp
When I run gradlew war after upgrading gradle version to 4.10.3 I start to get the following error during execution of compileGroovyPages task:
dashboard_gsp.groovy: 2: unable to resolve class com.abnd.CarStatusEnum
# line 2, column 1.
import com.abnd.CarStatusEnum
^
Location of class com.abnd.CarStatusEnum is src/main/groovy/com/abnd/CarStatusEnum in the same project where the build is being run and gradlew war task completes successfully with gradle version 3.4.1. However when I upgrade gradle version to 4.10.3 then I start to get this error. Same happens with gradle version 4.1.
1) Any clue what can be the problem ?
2) Is that a good idea to use gradle version 4.x.x or 5.x.x with grails version 3.x.x as with gradle 5.x.x I start to get even more issues as some grails plugins(like grails-gsp v3.3.2 which is latest stable version) use some features that have been deprecated in gradle 4.x.x and removed from gradle 5.x.x (see the error bellow)?
Failed to apply plugin [id 'org.grails.grails-gsp']
Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.
1) Any clue what can be the problem ?
Yes. The error message is a clue that the GSP compiler can't find the enum class. This is because our plugin isn't compatible with Gradle 4.10.3.
2) Is that a good idea to use gradle version 4.x.x or 5.x.x with
grails version 3.x.x
No. Those Gradle versions are not supported with the version of Grails you are using.
I hope that helps.

Sonar 5 returns no code coverage data using the groovy plugin and using cobertura for code coverage

Sonar 5 returns no code coverage data using the groovy plugin and using cobertura for code coverage. Maven also fails to return code coverage.
Configure a test instance with SonarQube 5.4 and the flowing plugins:
Build Breaker 1.1
Findbugs 3.3
Git 1.2
Groovy 1.3.1
Java 3.9
JavaScript 2.11
LDAP 1.5.1
PHP 2.8
Python 1.5
SVN 1.3
Web Analyze HTML 2.4
PMD 2.5
The old instance with Version 4.3.2 works? Does the cobertura plugin need to be installed, since it has been deprecated, or can the Java plug-in provide the correct support?
Indeed the import of Cobertura reports is no more supported out of the box. This requires to install the following dedicated community SonarQube Cobertura plugin : https://github.com/SonarQubeCommunity/sonar-cobertura/releases

Gradle plugin compatibility - how to find out?

Can Gradle plugins for 1.11+ be expected to work for 2.+, and if not, how can one find out the state of compatibility?
Specifically, I have had success using Gradle 1.11 in a project spring-boot project. When upgrading to Gradle 2.2, I noticed that the spring-boot plugin does not seem to be available, although I haven't found any references to a particular Gradle version in the Spring Boot Gradle documentation (http://docs.spring.io/autorepo/docs/spring-boot/1.2.0.BUILD-SNAPSHOT/reference/html/build-tool-plugins-gradle-plugin.html).
Using Gradle 2.2, I get:
* What went wrong:
A problem occurred evaluating root project 'NN'.
> Failed to apply plugin [id 'spring-boot']
> A problem occurred configuring project ':webapp'.
> Extension of type 'SpringBootPluginExtension' does not exist. Currently registered extension types: [DefaultExtraPropertiesExtension, DefaultArtifactPub
licationSet_Decorated, ReportingExtension_Decorated, DefaultProjectSourceSet_Decorated, DefaultBinaryContainer_Decorated]
It depends on the particular plugin, and would ideally be tested/documented there. 1.x to 2.x was a big jump in terms of the Groovy version used by Gradle, which can cause compatibility issues for plugins implemented in Groovy. Also, 1.x plugins using deprecated or internal APIs may not work in 2.x.

Resources