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

能支持下java11么? #5

Closed
phoenixsky opened this issue May 6, 2023 · 9 comments
Closed

能支持下java11么? #5

phoenixsky opened this issue May 6, 2023 · 9 comments

Comments

@phoenixsky
Copy link

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
Copy link
Owner

JailedBird commented May 6, 2023

我不是很懂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

@JailedBird JailedBird pinned this issue May 6, 2023
@phoenixsky
Copy link
Author

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

@JailedBird
Copy link
Owner

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

@JailedBird
Copy link
Owner

JailedBird commented May 6, 2023

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

image

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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '11'
    }

@JailedBird
Copy link
Owner

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

@phoenixsky
Copy link
Author

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

@JailedBird
Copy link
Owner

JailedBird commented May 8, 2023

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

@phoenixsky
Copy link
Author

试试这个版本: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
Copy link
Owner

JailedBird commented May 8, 2023

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

No branches or pull requests

2 participants