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

Make it possible to compile with apollo-gradle-plugin and Kotlin 1.5 #4218

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

martinbonnin
Copy link
Contributor

Bumping KotlinPoet pulled kotlin-stdlib:1.7 as a dependency and the Kotlin 1.5 compiler fails with these warnings:

> Task :compileKotlin FAILED
'compileJava' task (current target is 17) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /Users/mbonnin/.gradle/caches/modules-2/files-2.1/com.apollographql.apollo3/apollo-gradle-plugin/3.3.2/fcf5eff2ad1c8e0cd36be9e5457cf0257b4c3b01/apollo-gradle-plugin-3.3.2.jar!/META-INF/kotlinpoet.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
e: /Users/mbonnin/git/test-gradle-7-4/src/main/kotlin/Main.kt: (2, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from /Users/mbonnin/.gradle/caches/modules-2/files-2.1/com.apollographql.apollo3/apollo-gradle-plugin/3.3.2/fcf5eff2ad1c8e0cd36be9e5457cf0257b4c3b01/apollo-gradle-plugin-3.3.2.jar!/kotlin/Unit.class

KotlinPoet is not part of the apollo-gradle-plugin public API. It should be safe to remove its .module file (this is where the compiler is looking for things like top-level declarations).

kotlin.Unit is provided by Gradle in the first place so there should be no need to include it in the relocated jar.

@netlify
Copy link

netlify bot commented Jun 22, 2022

Deploy Preview for apollo-android-docs canceled.

Name Link
🔨 Latest commit 437d2b9
🔍 Latest deploy log https://app.netlify.com/sites/apollo-android-docs/deploys/62b379a03d7fcc000a249cf8

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

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

Wow! 👏

@martinbonnin martinbonnin merged commit 7546672 into main Jun 23, 2022
@martinbonnin martinbonnin deleted the strip-unit-and-module-files branch June 23, 2022 10:17
@JavierStuart
Copy link

Is it planned to include this in the next version? I am having it when trying to upgrade to Kotlin 1.7.0

@BoD
Copy link
Contributor

BoD commented Jul 8, 2022

@JavierStuart Yes this will be included in the next release, which is currently planned to be released early next week.

@martinbonnin
Copy link
Contributor Author

Is it planned to include this in the next version? I am having it when trying to upgrade to Kotlin 1.7.0

@JavierStuart Double checking we're talking about the same thing: this patch is to make it possible to use Kotlin 1.5 (current Gradle embedded version) with the latest Apollo version. Using Kotlin 1.7.0 shouldn't cause any issue. Can you share your stacktrace?

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