How to spring-boot 2.4.0 and kotlin 1.4.20 - spring-boot

I am trying to build a spring-boot Microservice.
The build is using releasee 2.4.0 of spring-boot.
I am trying to compile this build with the new release 1.4.20 of kotlin.
How can I build this without failures?
Try to create a kotlin Microservice with start.spring.io. Edit the pom to use the newest kotlin release...
When building:
Execution compile of goal org.jetbrains.kotlin:kotlin-maven-plugin:1.4.20:compile failed: A required class was missing while executing org.jetbrains.kotlin:kotlin-maven-plugin:1.4.20:compile: kotlin/reflect/KDeclarationContainer
...
If you choose kotlin as main language (as one should) and picks java 15, one get the following error:
Compilation failure
[ERROR] Unknown JVM target version: 15
[ERROR] Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14
There is something fundamentally wrong with the spring-boot configuration provided from start.spring.io as the target of the new kotlin version 1.4.20 is java 15: what's new in kotlin 1.4.20

The error seemed to be a bug only visible on Mac OS Big Sur (intel version), but was solved by updating to kotlin release 1.4.21

updating kotlin version works for me.

Related

Module was compiled with an incompatible version of Kotlin error after upgrading spring_cloud.version to 2021.0.0

I am attempting to update the spring cloud dependency from spring_cloud.version=2020.0.3
to spring_cloud.version=2021.0.0.
This causes an error when running the gradle build due to the following error
> Task :dispute-visa:compileKotlin FAILED
e: /Users/my.name/.gradle/caches/modules-2/files-2.1/org.springframework.cloud/spring-cloud-function-context/3.2.1/3b1b11733424ba90bd0b030a924e6b7deb2ff845/spring-cloud-function-context-3.2.1.jar!/META-INF/spring-cloud-function-context.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.
/Users/my.name/.gradle/caches/modules-2/files-2.1/org.springframework.cloud/spring-cloud-function-context/3.2.1/3b1b11733424ba90bd0b030a924e6b7deb2ff845/spring-cloud-function-context-3.2.1.jar!/META-INF/spring-cloud-function-context.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.2.
The spring cloud dependency is implementation("org.springframework.cloud:spring-cloud-stream-binder-kafka")
If this spring cloud dependency is removed then the build works.
If the spring cloud dependency is replaced with another spring cloud dependency then the build will fail with a similar error.
These are the relevent versions of other parts
kotlin.version=1.5.32
spring_boot.version=2.5.6
I have tried changing kotlin version and spring boot version with no effect.
Any help appreciated!

Quarkus 1.2.0 native Build not working with Java 11

I downloaded a default application from https://code.quarkus.io/, changed maven.compiler.source/target to 11, and added a Java 11 feature to org.acme.ExampleResource like var x = 1.
Then I started a build using mvnw package -Pnative -Dquarkus.native.container-build=true.
In the logs I see:
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 19.2.1 CE
As expected the build now fails with the error message
UnsupportedFeatureException: Class initialization of io.quarkus.runner.ApplicationImpl failed
Cause is
UnsupportedClassVersionError: org/acme/ExampleResource has been compiled by a more recent version of the Java Runtime (class file version 55.0)
Why does it use Graal VM 19.2.1 instead of 19.3.1?
If I do a multistage build like described on https://quarkus.io/guides/building-native-image, the compilation works.

"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.

Wrong Major Version number when running Sonar Scanner with Java 11

I'm currently migrating a project from java 8 to java 11, and have been using Sonar scanner, with gradle, to send the code to SonaQube. After migrating to Open JDK 11, I amd getting the following error when running the gradle sonarqube tasks:
java.lang.IllegalArgumentException: Unsupported class file major version 55
I have read online that the scanner should be run with jdk 8, even though the analysis can be run on an version of java files, but have not been able to figure this out.
Ideally, I would be able to run gradle sonarqube with the Java 11 JDK. I found another question seeming to have success with Java 11 using Maven, but their error is different, and I don't think their solution would apply to me.
Is this problem solvable, or will I need to wait for Sonar Scanner to have support for JDK 11?
If someone like me this will helpful.
Source code Java 8(55), with jenkins and sonarqube scanner.
My error was
INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.11 AdoptOpenJDK (64-bit)
.....
java.lang.IllegalArgumentException: Unsupported class file major version 55
Check this link : Why does sonar-scanner force the usage of the embedded JRE?
And Change your sonnar-scanner.bat or sonnar-scanner.sh
use_embedded_jre=false

SonarQube 5.6 with Java Project (JDK 1.6)

I want to configure SonarQube for my maven project which is on jdk 1.6.
Can I use the latest SonarQube 5.6. It say code should be complied with jdk 1.8 only.
Is it possible to analyse code with older version of JDK with SonarQube on latest vesrion of JDK?
My project is compiled on jdk1.6. Do I need to use scanner which supports jdk1.6 because if I uses sonar-maven-plugin - 3.1.1 it gives error :
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar (default-cli) on project StreamDiffCLI: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1:sonar failed: Unable to load the mojo 'sonar' in the plugin 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0
I believe you're misreading the docs. You can compile your project with whatever version of Java you like. 1.4 even. But you must analyze with 8.
If you are installing Sonar-Cube with latest version with JDK 1.8 but your project is compatible to JDK 1.6 the use :
if project are supporting JDK 1.6, please use “sonar.java.source=1.6” in your configuration file to avoid rules applicable for JDK>1.6
e.g in build.xml (ANT)

Resources