Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kotlin source/target version. #5899

Merged
merged 1 commit into from
May 2, 2023

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Apr 28, 2023

The 4.0 upcoming version of Micronaut (now M2) uses an upgraded version of Kotlin gradle plugin that somewhat breaks its backward compatibility.
According to KT-32805, Kotlin compiler task used to inherit from SourceTask that has sourceCompatibility and targetCompatibility properties, but from version 1.7 it derives just from DefaultTask.

According to that report, the plugin ignored the *Compatibility properties even before that. The proper settings reside in kotlinOptions structure.

This resulted in

Reason: groovy.lang.MissingPropertyException: Could not get unknown property 'sourceCompatibility' for task ':aop:compileKotlin' of type org.jetbrains.kotlin.gradle.tasks.KotlinCompile.
groovy.lang.MissingPropertyException: Could not get unknown property 'sourceCompatibility' for task ':aop:compileKotlin' of type org.jetbrains.kotlin.gradle.tasks.KotlinCompile.
	at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
	at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
	at org.gradle.api.internal.AbstractTask.property(AbstractTask.java:571)
	at org.gradle.api.DefaultTask.property(DefaultTask.java:169)
	at org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.detectSources(NbProjectInfoBuilder.java:1088)

This PR makes the kotlinOptions the primary source for source/target version kotlinCompile task; falls back to the previous behaviour. In addition task properties are fetched by a safe helper that does not throw on a missing property. The procedure should be safe for all versions of Kotlin plugin: should they not expose kotlinOptions.{jvmTarget|languageLevel}, it will be (safely) taken from {source,target}Compatibility properties of the task.

Fixes #5896

@sdedic sdedic added kind:bug Bug report or fix Gradle [ci] enable "build tools" tests priority:high High priority issue that should, if possible, be fixed in next release labels Apr 28, 2023
@sdedic sdedic added this to the NB18 milestone Apr 28, 2023
@sdedic sdedic requested review from lkishalmi and MartinBalin April 28, 2023 18:10
@sdedic sdedic self-assigned this Apr 28, 2023
Copy link
Contributor

@lkishalmi lkishalmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
Thank you for fixing this one!

@mbien mbien linked an issue Apr 29, 2023 that may be closed by this pull request
@neilcsmith-net neilcsmith-net merged commit 2470c07 into apache:delivery May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gradle [ci] enable "build tools" tests kind:bug Bug report or fix priority:high High priority issue that should, if possible, be fixed in next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

groovy.lang.MissingPropertyException from Micronaut-Core
3 participants