JailedBird / ArouterKspCompiler

Arouter KSP annotation processor
Apache License 2.0
72 stars 6 forks source link

能支持下java11么? #5

Closed phoenixsky closed 1 year ago

phoenixsky commented 1 year ago

task (current target is 11) and 'kspReleaseKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.

JailedBird commented 1 year ago

我不是很懂Java11和Java8的兼容性问题,插件里面使用的 sourceCompatibility = JavaVersion.VERSION_1_8, demo(app模块)使用的是JDK11的gradle去运行的,没发现问题;

你看看这篇stackoverflow?看看能不能解答疑惑👀
https://stackoverflow.com/questions/69079963/how-to-set-compilejava-task-11-and-compilekotlin-task-1-8-jvm-target-com

phoenixsky commented 1 year ago

image 如上图是警告,并不是错误。 原因是,我项目里java的版本指定的是11,个别模块依赖了这个arouter的ksp,可能你项目里指定的是1.8 就有了上图的提示,我试图覆盖你指定的1.8但是没生效。

JailedBird commented 1 year ago

我在这个分支,app模块配置jdk11, 导入jdk8的jitpack 远端依赖,没报这个warning🤣 https://github.com/JailedBird/ArouterKspCompiler/tree/test-jdk11-build-warning 我再看看warning信息吧

JailedBird commented 1 year ago

复现了类似的问题😂,如下图:

image

你检查下对应那个模块,compileOptions 和 kotlinOptions 的版本号是不是不一致? PS: 初步测试不一致会出现你的那个问题,一致(均为11)就不会

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '11'
    }
JailedBird commented 1 year ago

还不行,你就说下Kotlin版本吧,我打一个Java11 的版本,你试试🤣

phoenixsky commented 1 year ago

"1.8.20-1.0.2"这个版本 搞个java11的吧。我试试

JailedBird commented 1 year ago

试试这个版本:1.8.20-1.0.2-beta01-jdk11 打包记录:https://jitpack.io/#JailedBird/ArouterKspCompiler/1.8.20-1.0.2-beta01-jdk11

phoenixsky commented 1 year ago

试试这个版本:1.8.20-1.0.2-beta01-jdk11 打包记录:https://jitpack.io/#JailedBird/ArouterKspCompiler/1.8.20-1.0.2-beta01-jdk11

试了下不行,就知道不是这个插件的问题了,我使用room的ksp也会出现这个问题。sorry。。。。 目前我把所有module都加了限制:

    tasks.withType(KotlinCompile::class.java) {
        kotlinOptions {
            jvmTarget = JavaVersion.VERSION_11.toString()
        }
    }
    java {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }

这样就可以了,辛苦你了

JailedBird commented 1 year ago

上述Kotlin高版本问题,均可参考如上方案:

https://stackoverflow.com/questions/69079963/how-to-set-compilejava-task-11-and-compilekotlin-task-1-8-jvm-target-com