Skip to content

Update Kotlin dependency to latest stable 1.7 #623

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

Closed
wants to merge 2 commits into from

Conversation

VirtualTim
Copy link

@VirtualTim VirtualTim commented Feb 8, 2023

1.5.32 -> 1.7.22.
1.8 is available as of Dec 28, 2022, but it was not immediately clear to me if this would be compatible.

This doesn't really count as code, so I don't see a need to fill out the Contributor License Agreement, if this gets merged.

1.6.21 -> 1.7.22.
1.8 is available as of Dec 28, 2022, but it was not immediately clear to me if this would be compatible.
@cowtowncoder
Copy link
Member

Baseline Kotlin version dependencies need to be discussed somewhere; perhaps this issue is the place. The challenge is that we have to be quite conservative -- upgrading to latest patch of same minor version is fine, but jumping from 1.5 to 1.7 is a big change. This is different from the question of which versions module will be compatible with (we have CI matrix build to check that).

So, @dinomite @k163377 would we want to try increasing Kotlin baseline for 2.15(.0)? Probably not to 1.7, but 1.6.x could be possibility.

@k163377
Copy link
Contributor

k163377 commented Feb 10, 2023

Perhaps we need to stay with 1.5.x as that is the lowest language version currently supported by Kotlin.
https://kotlinlang.org/docs/kotlin-evolution.html#compatibility-flags:~:text=we%20support%20the%20development%20for%20three%20previous%20language%20and%20API%20versions

@cowtowncoder
Copy link
Member

cowtowncoder commented Feb 10, 2023

@k163377 yes that is kind of my leaning too.

Module itself supports Kotlin versions 1.4 - 1.7, and CI now checks this compatibility too.
(by compiling against 1.5 but running unit tests against multiple kotlin-core versions)

@VirtualTim
Copy link
Author

VirtualTim commented Feb 14, 2023

Apologies, I originally went to commit this against maser, which is on 1.6.21. But then I saw the recommendation to submit PR's against 2.15, which is on 1.5.32.

That being said, you can update the compiler/plugin version independent of the language version. So perhaps the better approach is to control the language version independently of the plugin version?
Edit: I've updated the PR with this idea.

This allows us to control API/language version independently of Kotlin plugin versions.
See: https://kotlinlang.org/docs/maven.html#specifying-compiler-options
@cowtowncoder
Copy link
Member

WDYT @k163377 @dinomite @viartemev ?

@k163377
Copy link
Contributor

k163377 commented Feb 16, 2023

I tried dependency:tree locally, is this really using 1.5.x?

[INFO] --- maven-dependency-plugin:3.3.0:tree (default-cli) @ jackson-module-kotlin ---
[INFO] com.fasterxml.jackson.module:jackson-module-kotlin:bundle:2.15.0-SNAPSHOT
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.15.0-SNAPSHOT:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-core:jar:2.15.0-SNAPSHOT:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.15.0-SNAPSHOT:compile
[INFO] +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.7.22:provided
[INFO] |  +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.7.22:provided
[INFO] |  \- org.jetbrains:annotations:jar:13.0:provided
[INFO] +- org.jetbrains.kotlin:kotlin-reflect:jar:1.7.22:compile
[INFO] +- junit:junit:jar:4.13.2:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.jetbrains.kotlin:kotlin-test-junit:jar:1.7.22:test
[INFO] |  \- org.jetbrains.kotlin:kotlin-test:jar:1.7.22:test
[INFO] \- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.15.0-SNAPSHOT:test
[INFO]    +- org.codehaus.woodstox:stax2-api:jar:4.2.1:test
[INFO]    \- com.fasterxml.woodstox:woodstox-core:jar:6.5.0:test

Personally, I don`t think it should be merged.

I understand the desire to use a newer version of Kotlin, and I feel the same way.
However, upgrading only the compiler version seems a bit tricky (at least I don't have enough knowledge to say "merging this will not cause any problems").
If there is no clear benefit to be gained by upgrading, I feel that the disadvantage of reduced maintainability in the future due to increased complexity is greater.

@cowtowncoder
Copy link
Member

I tried dependency:tree locally, is this really using 1.5.x?

This is bit different than what he is saying: he is saying that the dependency would be to 1.7.x, but compiler behavior is specified to produce bytecode (?) that should work with Kotlin 1.5 too.

However: this would still by default increase kotlin-core transitive dependency to 1.7 for everyone (unless they locally override it).

I don't think we want to merge this for 2.15, although could start discussing increasing dependency to 1.6 for 2.16 (or 1.7 if community wants that instead).

@k163377
Copy link
Contributor

k163377 commented Feb 17, 2023

Oops, I guess I misunderstood.
However, if even the stdlib version is affected, I feel it is better to avoid the merge so as not to cause problems like #556.

@VirtualTim
Copy link
Author

VirtualTim commented Feb 17, 2023

For clarity, you might want to read: https://kotlinlang.org/docs/maven.html#attributes-common-to-jvm-and-js.
Specifically:

Property name Description
kotlin.compiler.languageVersion Provide source compatibility with the specified version of Kotlin
kotlin.compiler.apiVersion Allow using declarations only from the specified version of bundled libraries

To me it sounds like this would actually help prevent problems like #556. If this project is supposed to be Kotlin 1.4 compatible we can guarantee that by setting those properties to 1.4.

@cowtowncoder
Copy link
Member

Thank you @VirtualTim that makes sense and is what I thought. The main remaining question is whether we'd want to upgrade dependency since it will change observed dependencies downstream. I do not have strong opinion on this, other than to say that most users will consider it (incorrectly but understandably) as increasing minimum baseline, thinking module will no longer work with older Kotlin cores.

And so it's a balancing act: at some point we will drop support for older cores, too, of course; but until then figuring out settings that are balanced.

Having said that, I will let module maintainers -- specifically, @k163377 and @dinomite -- decide on what to do here, wrt version 2.15.

@k163377
Copy link
Contributor

k163377 commented Feb 18, 2023

Several verifications and considerations did not change the conclusion that it should not be merged.
The main reason is that the requirements of this project can be accomplished with the current simple versioning.

I also found a problem with this approach.
When a dependent library has a problem like #556, running the test as usual does not seem to result in an error.

Here is the verification code.
When version.kotlin is 1.7.22, main runs without error, but when version.kotlin is 1.4.32, it fails.

verification code
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>versioning-sandbox</artifactId>
    <groupId>org.wrongwrong</groupId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>consoleApp</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.code.style>official</kotlin.code.style>
        <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
        <version.kotlin>1.4.32</version.kotlin>
        <kotlin.compiler.languageVersion>1.4</kotlin.compiler.languageVersion>
        <kotlin.compiler.apiVersion>1.4</kotlin.compiler.apiVersion>
    </properties>

    <repositories>
        <repository>
            <id>mavenCentral</id>
            <url>https://repo1.maven.org/maven2/</url>
        </repository>
    </repositories>

    <build>
        <sourceDirectory>src/main/kotlin</sourceDirectory>
        <testSourceDirectory>src/test/kotlin</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${version.kotlin}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${version.kotlin}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
            <version>${version.kotlin}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-kotlin</artifactId>
            <version>2.13.2</version>
        </dependency>
    </dependencies>
</project>
package org.wrongwrong

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper

class Temp(val value: String)

fun main() {
    val mapper = jacksonObjectMapper()

    mapper.writeValueAsString(Temp("aaa"))
}

There are no dependencies defined that would satisfy this condition, and there are CI grid tests, so this problem is unlikely to actually occur with the current version of jackson-module-kotlin.
However, there is no guarantee that it will not occur in the future.
In conclusion, I don't think there is a clear advantage to merging this for long term maintenance.

@VirtualTim
Copy link
Author

Thanks for taking the time to consider this.
See free to close, or re-target to master.

@k163377
Copy link
Contributor

k163377 commented Feb 20, 2023

Thanks for the suggestion.

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.

3 participants