ktfmt-gradle needs at least Gradle 7.2
arturbosch opened this issue ยท 7 comments
๐ Describe the bug
Readme states that Gradle 6.8+ is supported.
โ ๏ธ Current behavior
String.titlecase was introduced in Kotlin 1.5 which is shipped with Gradle starting from 7.2.
We are running Gradle 6.9.2 and can't upgrade due to Gradle 7.0 removed the feature to switch Java compilers.
โ Expected behavior
There are two options:
- Update Readme to only support Gradle 7.2+
- fix
titlecase
usage (and maybe further 1.5 features ? maybe appendLn) to be Kotlin 1.4 compatible.
๐ฃ Steps to reproduce
Run any project with Gradle 6.9.2 and the ktfmt plugin installed.
๐ท Screenshots
๐ฑ Tech info
- Device: Dell Xps 15
- OS: ubuntu 22.10
Ooops that sucks. Yup I think addressing the titlecase
usage would be preferred and setting languageLevel to 1.4 should suffice. Are you up for a PR @arturbosch ? :)
Ooops that sucks. Yup I think addressing the
titlecase
usage would be preferred and setting languageLevel to 1.4 should suffice. Are you up for a PR @arturbosch ? :)
Well maybe, I'm not sure how to fix this as titlecase
uses a Locale
and converts a Char
to a possible multi-char string.
There is no direct replacement in the jdk for it :/. Character.toTitleCase(char)
does a bit less under the hood as it seems.
So this only applies to some wierd unicode task names ... is it important ?
I took a stab at this here:
I've tested this on a Gradle project with 6.9 and I managed to make it work.
The problem you'll face @arturbosch, is that ktfmt-gradle
is adding a dep. constraint on "org.jetbrains.kotlin:kotlin-compiler-embeddable:..."
on version 1.7.22
.
The reason why this is needed is #93 and the linked YouTrack issue.
So even if you're on Gradle 6.9, you'll pull in kotlin-compiler-embeddable
for 1.7
The workaround is for you to pin the kotlin-compiler-embeddable
in your build as:
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.32") {
version {
strictly("1.4.32")
}
}
}
}
Removing the dep. constraint on kotlin-compiler-embeddable
will make it unusable for users on Kotlin 1.7.
I took a stab at this here:
I've tested this on a Gradle project with 6.9 and I managed to make it work. The problem you'll face @arturbosch, is that
ktfmt-gradle
is adding a dep. constraint on"org.jetbrains.kotlin:kotlin-compiler-embeddable:..."
on version1.7.22
.The reason why this is needed is #93 and the linked YouTrack issue. So even if you're on Gradle 6.9, you'll pull in
kotlin-compiler-embeddable
for 1.7The workaround is for you to pin the
kotlin-compiler-embeddable
in your build as:buildscript { dependencies { classpath("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.32") { version { strictly("1.4.32") } } } }
Removing the dep. constraint on
kotlin-compiler-embeddable
will make it unusable for users on Kotlin 1.7.
Thanks! Will I need the workaround if we already use Kotlin 1.7.X Gradle plugin?
if we already use Kotlin 1.7.X Gradle plugin?
Not really. But then I don't fully understand what's your setup.
What's your Gradle version and the KGP version you're on? Are there any other Gradle Plugins that are pulling in kotlin-compiler-embeddable
? (A gradle scan might help to understand).
if we already use Kotlin 1.7.X Gradle plugin?
Not really. But then I don't fully understand what's your setup. What's your Gradle version and the KGP version you're on? Are there any other Gradle Plugins that are pulling in
kotlin-compiler-embeddable
? (A gradle scan might help to understand).
Oh, my misunderstanding. You wrote contraint for the buildscript block.
We use Gradle 6.9.X which ships with Kotlin-Embeddable 1.4.20 and KGP 1.7.1.
Also detekt 1.22.0 and IntelliJ-Gradle-Plugin 1.10.2 which do not ship the Kotlin compiler transitively.
Oh, my misunderstanding. You wrote contraint for the buildscript block. We use Gradle 6.9.X which ships with Kotlin-Embeddable 1.4.20 and KGP 1.7.1. Also detekt 1.22.0 and IntelliJ-Gradle-Plugin 1.10.2 which do not ship the Kotlin compiler transitively.
Thanks for sharing. I've tested with your setup and the fix works correctly ๐