8000 Update Kotlin, KSP, KotlinPoet, and Gradle by eygraber · Pull Request #195 · evant/kotlin-inject · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update Kotlin, KSP, KotlinPoet, and Gradle #195

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

Merged
merged 5 commits into from
Jul 20, 2023
Merged

Conversation

eygraber
Copy link
Collaborator
@eygraber eygraber commented May 3, 2022

No description provided.

@evant
Copy link
Owner
evant commented May 3, 2022

I should document this somewhere, but plan to be somewhat conservative on kotlin/ksp updates as the user can update them themselves. Not against updating, but it just needs to be for something we need instead of bumping arbitrarily.

Looks like kotlinpoet: 1.10.2 didn't have a kotlin version bump so that should be safe to do.

@eygraber
Copy link
Collaborator Author
eygraber commented May 3, 2022

I'd say that it might be worth it to keep up to date so that if there is a breaking change that requires a library update it'll be closer to that version. But there's no guarantee on that so ¯_(ツ)_/¯

@evant
Copy link
Owner
evant commented May 3, 2022

For the libs we are using those should be few and far between

@eygraber eygraber force-pushed the update-kotlin branch 3 times, most recently from f1ca5a3 to 9c9d4e3 Compare July 5, 2022 21:21
@eygraber eygraber changed the title Update Kotlin, KSP, and KotlinPoet Update Kotlin, KSP, KotlinPoet, and Gradle Jul 5, 2022
@eygraber
Copy link
Collaborator Author
eygraber commented Jul 5, 2022

@evant I'll be keeping this updated until it is time to merge 😄

@eygraber
Copy link
Collaborator Author

@evant I updated to Gradle 8.2.1 and Kotlin 1.9

This will probably help with bridging the gap towards Kotlin 2.0

@eygraber eygraber mentioned this pull request Jul 12, 2023
@eygraber eygraber force-pushed the update-kotlin branch 3 times, most recently from 290047f to 89e3ed4 Compare July 12, 2023 03:32
@eygraber
Copy link
Collaborator Author

Any idea why the linux build is failing? Does it need more memory?

@eygraber eygraber force-pushed the update-kotlin branch 2 times, most recently from e4e3c2d to 1618e1a Compare July 12, 2023 17:33
@evant
Copy link
Owner
evant commented Jul 18, 2023

Fyi I was testing this locally and was running into issues with the kapt backend. After a bunch of debugging turns out it's running with the embeded gradle kotlin instead of the kotlin version you pull in. This means it was using kotlin 1.8.10 and kotlinx-metadata 0.5.0 which won't work with kotlin 1.9.0.

I think I'm just going to go ahead of get rid of the kapt backend, it's deprecated anyway. Was planning on doing a bugfix release before then but it's getting more and more of a pain to deal with ☹️.

Comment on lines +1 to +7
buildscript {
dependencies {
with(libs.kotlin.gradle.get()) {
classpath("$group:$name:$embeddedKotlinVersion")
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

curious why this is needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Forcing Gradle to use Kotlin 1.9 results in errors, which I think has to do with https://kotlinlang.org/docs/whatsnew19.html#separate-compiler-plugins-for-official-kotlin-libraries but in any case Gradle has always said not to force a different version of Kotlin for their runtime because they offer no guarantees (Gradle 8.3 should have Kotlin 1.9 support).

Copy link
Owner

Choose a reason for hiding this comment

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

ah so this overrides the version of kotlin uses when compiling the build script logic right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

https://docs.gradle.org/8.3-rc-1/release-notes.html

The rc releases sometimes have issues, but I've used them in the past with no problems. It should allow kapt to stay in if you really don't want to remove it yet.

If you do want to remove kapt, I have a stashed changeset that's most of the way there, and I can make a PR. Unless you want the cathartic experience of ripping it out 😅


plugins {
kotlin("jvm")
}

val libs = the<LibrariesForLibs>()

kotlin {
jvmToolchain(17)
Copy link
Owner

Choose a reason for hiding this comment

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

I don't quite understand the distinction between the jvmToolchain and the target version. Is there a reason we need both and that they should be different?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The toolchain version specifies which version of Java should be used to compile the project. The target version specifies the least compatible version of bytecode that will be produced (i.e. projects using at least Java 8 can use this library).

@eygraber
Copy link
Collaborator Author

Are the kapt tests not run on CI? I didn't notice that they were failing locally.

I pushed a new commit addressing your comments.

@evant
Copy link
Owner
evant commented Jul 20, 2023

I didn't notice that they were failing locally.

Hm, I wonder if it has something to do with the toolchain support. I'm running with java 20 so it's jumping to java 17. When I run with

JAVA_HOME=/usr/lib/jvm/java-17-openjdk ./gradlew test

it works fine.

Ok yeah it does have to do with toolchains. If I remove the toolchain lines and add back setting the source compatibility it works fine. I do wonder if the toolchian thing is worth it? In theory forcing a specific version of javac is good for consistency but running newer versions seems to work fine without it?

implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}

java {
Copy link
Owner

Choose a reason for hiding this comment

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

note: to run with java 20 I had to add

java {
    targetCompatibility = JavaVersion.VERSION_11
}

tasks.withType<KotlinCompile>().configureEach {
    compilerOptions.jvmTarget = JvmTarget.JVM_11
}

(17 probably would work as well)
but either way I think it's good to have for consistency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using a toolchain here would probably be a valid use case (and I tested that it works), but the alternative is to not use java 20 until Gradle supports it.

Copy link
Owner

Choose a reason for hiding this comment

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

but the alternative is to not use java 20 until Gradle supports it

yeah true, I might end up adding a target here because it just means you'd be generating older class files than needed so it's not a huge issue, but it's not a priority or anything.

@eygraber
Copy link
Collaborator Author

TIL that toolchains aren't as good as I thought they were 😅

https://kotlinlang.slack.com/archives/C3PQML5NU/p1689790193010619?thread_ts=1689789822.225749&cid=C3PQML5NU

@eygraber
Copy link
Collaborator Author
eygraber commented Jul 20, 2023

I pushed an update cleaning up some of the source and target usage, and removed the toolchains. Could possibly add the toolchain back conditionally in the future to aid in having a minimum required version of java.

The kapt failure when using java 20 with the toolchain set is odd; I filed KT-60563 with JetBrains.

@evant evant merged commit 2880f47 into evant:main Jul 20, 2023
@eygraber eygraber deleted the update-kotlin branch July 20, 2023 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0