Ibotta / gradle-aspectj-pipeline-plugin

A Gradle plugin for Android projects which performs AspectJ weaving using Android's bytcode manipulation pipeline.
Apache License 2.0
75 stars 15 forks source link

Kotlin 1.7.0 breaking changes #24

Closed jdvp closed 2 years ago

jdvp commented 2 years ago

Updating my sample project from Kotlin 1.6.21 to 1.7.0 breaks the plugin

Sample project: https://github.com/jdvp/AndroidAspectExample

You can check out master and just update the Kt version. Prior to updating ./gradlew clean lint test will run successfully and after updating it will fail with the following error:

* What went wrong:
Could not determine the dependencies of task ':app:aopWeaveDebug'.
> class org.jetbrains.kotlin.gradle.tasks.KotlinCompile_Decorated cannot be cast to class org.gradle.api.tasks.compile.AbstractCompile (org.jetbrains.kotlin.gradle.tasks.KotlinCompile_Decorated is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @6f886d4a; org.gradle.api.tasks.compile.AbstractCompile is in unnamed module of loader org.gradle.initialization.MixInLegacyTypesClassLoader @6cc4cdb9)

This appears to be because of the following:

Kotlin compile tasks no longer inherit the Gradle AbstractCompile task. They inherit only the DefaultTask.

which is mentioned in the What's new in 1.7.0 Changes in compile tasks section

vdelricco commented 2 years ago

Published 1.4.0 which adds support for Kotlin 1.7.0.

jdvp commented 2 years ago

@vdelricco Just checking, I noticed that 1.4.0 release notes mention that it requires Kt 1.7.0 but is that true? I tried compiling my app with Ibotta 1.4.0 and Kt 1.5.0 and it seemed to work? Maybe I had some weird caching issue though

vdelricco commented 2 years ago

Oh interesting! It's certainly possible there are some build configurations that work properly. When applying this to our main app codebase, I received the following error when using the 1.4.0 release of this plugin:

FAILURE: Build failed with an exception.

* What went wrong:
'org.gradle.api.file.ConfigurableFileCollection org.jetbrains.kotlin.gradle.tasks.KotlinCompile.getLibraries()'

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
java.lang.NoSuchMethodError: 'org.gradle.api.file.ConfigurableFileCollection org.jetbrains.kotlin.gradle.tasks.KotlinCompile.getLibraries()'
        at com.ibotta.gradle.aop.PipelineAopWeaverPlugin.gatherClasspaths(PipelineAopWeaverPlugin.kt:386)
        at com.ibotta.gradle.aop.PipelineAopWeaverPlugin.access$gatherClasspaths(PipelineAopWeaverPlugin.kt:34)
        at com.ibotta.gradle.aop.PipelineAopWeaverPlugin$configureAopWeaveTask$1$2.invoke(PipelineAopWeaverPlugin.kt:297)
        at com.ibotta.gradle.aop.PipelineAopWeaverPlugin$configureAopWeaveTask$1$2.invoke(PipelineAopWeaverPlugin.kt:34)
        at com.ibotta.gradle.aop.AopWeaveTask.getClassPath(AopWeaveTask.kt:43)

I was able to get past this by updating our kotlin version from 1.6.10 to 1.7.0 (and then faced other errors later on because we're not quite ready for 1.7.0 😅) which was the reason for the note in the 1.4.0 release. I didn't do much digging after that though, so like I said this may be limited to our build config and will work in some other scenarios. Would be interested to hear if you uncover anything else 😄