Dyescape / kotlin-maven-symbol-processing

KSP extension for the kotlin-maven-plugin
MIT License
39 stars 6 forks source link

Update to Kotlin 1.8.10 breaks the KSP plugin Arrow Optics code generation #83

Closed jesperancinha closed 1 year ago

jesperancinha commented 1 year ago

Intro

Hello there,

I have created this same issue in the KSP plugin thread, but on further investigation, it seems more likely now that the below problem is more related to the Dyescape plugin I'm using to generate the arrow optics source code. I've just pushed a simple change where I'm isolating the problem by creating a module that does literally nothing in Kotlin but uses this plugin combined with the latest Kotlin version:

https://github.com/jesperancinha/jeorg-kotlin-test-drives/actions/runs/4095596978/jobs/7062617936

Details

I have two projects where I'm using a special configuration in Maven to generate the source code for arrow optics. The exception I get is:

Error:  Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.8.10:compile (compile) on project jeorg-kotlin-optics-crums-1: Compilation failure
Error:  java.lang.NoClassDefFoundError: org/jetbrains/kotlin/cli/jvm/plugins/ServiceLoaderLite
Error:      at com.google.devtools.ksp.KotlinSymbolProcessingExtension.loadProviders(KotlinSymbolProcessingExtension.kt:83)
Error:      at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:243)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:123)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:99)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:257)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:42)
Error:      at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:248)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:88)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47)
Error:      at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:167)
Error:      at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
Error:      at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:101)
Error:      at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
Error:      at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
Error:      at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execCompiler(KotlinCompileMojoBase.java:228)
Error:      at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:237)
Error:      at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:55)
Error:      at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execute(KotlinCompileMojoBase.java:209)
Error:      at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execute(K2JVMCompileMojo.java:222)
Error:      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)
Error:      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
Error:      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
Error:      at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
Error:      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
Error:      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:298)
Error:      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
Error:      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
Error:      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
Error:      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
Error:      at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
Error:      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
Error:      at java.base/java.lang.reflect.Method.invoke(Method.java:578)
Error:      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
Error:      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
Error:      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
Error:      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Error:  Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.cli.jvm.plugins.ServiceLoaderLite
Error:      at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
Error:      at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
Error:      at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
Error:      at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
Error:      ... 42 more
Error:  
Error:  
Error:  -> [Help 1]
Error:  
Error:  To see the full stack trace of the errors, re-run Maven with the -e switch.
Error:  Re-run Maven using the -X switch to enable full debug logging.
Error:  
Error:  For more information about the errors and possible solutions, please read the following articles:
Error:  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Error:  
Error:  After correcting the problems, you can resume the build with the command
Error:    mvn <args> -rf :jeorg-kotlin-optics-crums-1
make: *** [Makefile:4: build-maven] Error 1
Error: Process completed with exit code 2.

Examples of builds that fail are:

The special configuration I'm using in these projects are:

<plugin>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-maven-plugin</artifactId>
    <version>${kotlin.version}</version>
    <executions>
        <execution>
            <id>test-compile</id>
            <phase>test-compile</phase>
            <goals>
                <goal>test-compile</goal>
            </goals>
        </execution>
        <execution>
            <id>compile</id>
            <phase>compile</phase>
            <goals>
                <goal>compile</goal>
            </goals>
            <configuration>
                <sourceDirs>
                    <source>src/main/kotlin</source>
                    <source>target/generated-sources/ksp</source>
                </sourceDirs>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <compilerPlugins>
            <compilerPlugin>ksp</compilerPlugin>
        </compilerPlugins>
        <jvmTarget>${java.version}</jvmTarget>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>com.dyescape</groupId>
            <artifactId>kotlin-maven-symbol-processing</artifactId>
            <version>${kotlin-maven-symbol-processing.version}</version>
        </dependency>
        <dependency>
            <groupId>io.arrow-kt</groupId>
            <artifactId>arrow-optics-ksp-plugin</artifactId>
            <version>${arrow-optics-ksp-plugin.version}</version>
        </dependency>
    </dependencies>
</plugin>

I'm not entirely sure where this bug is coming from. My best guess is that it comes from the KSP plugin but it could also have to do with the dyescape symbol processing dependency which I still need to get optics from project arrow to work. Maybe Kotlin itself has an issue, but I would like to get feedback from you first.

Please let me know your thoughts on this and thanks in advance!

MrDienns commented 1 year ago

Hey @jesperancinha, thanks for the detailed heads up. We'll do a bit of digging and get back you.

jdillon commented 1 year ago

any update here, i Just ran into this myself :-\

MrDienns commented 1 year ago

We will be updating the plugin to support Kotlin 1.8 likely somewhere this week.

SiemenHubper commented 1 year ago

Would be nice! We ran into this too while trying to use KSP with a maven project that depends on kotlin 1.8.10, and really don't feel like converting our current million lines pom.xml to gradle or having to write our own maven extension just so we can use KSP :D

fxshlein commented 1 year ago

Hi everyone, sorry for the long wait!

Version 1.5 is now released, supporting kotlin 1.8.10: https://central.sonatype.com/artifact/com.dyescape/kotlin-maven-symbol-processing/1.5

Please let us know if there are any issues.

jesperancinha commented 1 year ago

@fxshlein Great work! It works flawlessly with Kotlin 1.8.10. This is also the reason why it feels a bit uncomfortable to have to say that version 1.5 of this plugin doesn't seem to work with Kotlin 1.8.20. I'm getting this error at the moment:

Error:  Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.8.20:compile (compile) on project jeorg-ksp-plugin-test: Compilation failure
Error:  java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.incremental.storage.BasicMap.<init>(java.io.File, com.intellij.util.io.KeyDescriptor, com.intellij.util.io.DataExternalizer)'
Error:      at com.google.devtools.ksp.PersistentMap.<init>(Incremental.kt:56)
Error:      at com.google.devtools.ksp.FileToSymbolsMap.<init>(Incremental.kt:62)
Error:      at com.google.devtools.ksp.IncrementalContext.<init>(Incremental.kt:189)
Error:      at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$1.invoke(KotlinSymbolProcessingExtension.kt:174)
Error:      at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$1.invoke(KotlinSymbolProcessingExtension.kt:171)
Error:      at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:394)
Error:      at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:171)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:123)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:99)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:257)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:42)
Error:      at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:248)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:88)
Error:      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47)
Error:      at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:168)
Error:      at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
Error:      at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:100)
Error:      at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:46)
Error:      at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
Error:      at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execCompiler(KotlinCompileMojoBase.java:230)
Error:      at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:237)
Error:      at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:55)
Error:      at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execute(KotlinCompileMojoBase.java:211)
Error:      at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execute(K2JVMCompileMojo.java:222)
Error:      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)
Error:      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)
Error:      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
Error:      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
Error:      at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
Error:      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
Error:      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:299)
Error:      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
Error:      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
Error:      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:963)
Error:      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:296)
Error:      at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
Error:      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
Error:      at java.base/java.lang.reflect.Method.invoke(Method.java:578)
Error:      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
Error:      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
Error:      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
Error:      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

Would you like me to open a bug for you about this? It's not urgent for the time being. Any way, on my side, this bug in particular for Kotlin 1.8.10 can be closed. Thank you!

SiemenHubper commented 1 year ago

1.5 with 1.8.10 works like a charm, thanks!

jesperancinha commented 1 year ago

Hi there,

Thanks for your great answers and the will to change and update this plugin. However, I have decided to use Gradle and so further Kotlin updates won't be using this plugin anyway. I think this is a great plugin and I definitely encourage you to continue developing it. Who knows, maybe someday I'll get back to using it, but for now, I will have to skip this. Since the first update to Kotlin 1.8.10 already works I am now closing this issue.

I wish you great success! thank you once again!