Trying to use Meta, and I get the error ```Caused...
# arrow-meta
j
Trying to use Meta, and I get the error
Copy code
Caused by: java.lang.AbstractMethodError: Receiver class package.MyMetaPlugin does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
I assume it is something to do with the default implementation not getting picked up from Meta interface?
Copy code
e: java.lang.IllegalStateException: The provided plugin package.MyMetaPlugin is not compatible with this version of compiler
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:675)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:169)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:216)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:111)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:485)
	at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:61)
	at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:37)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:76)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45)
	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227)
	at org.jetbrains.kotlin.cli.bc.K2Native$Companion$mainNoExitWithGradleRenderer$1.invoke(K2Native.kt:393)
	at org.jetbrains.kotlin.cli.bc.K2Native$Companion$mainNoExitWithGradleRenderer$1.invoke(K2Native.kt:392)
	at org.jetbrains.kotlin.util.UtilKt.profileIf(Util.kt:22)
	at org.jetbrains.kotlin.util.UtilKt.profile(Util.kt:16)
	at org.jetbrains.kotlin.cli.bc.K2Native$Companion.mainNoExitWithGradleRenderer(K2Native.kt:392)
	at org.jetbrains.kotlin.cli.bc.K2NativeKt.mainNoExitWithGradleRenderer(K2Native.kt:634)
	at org.jetbrains.kotlin.cli.utilities.MainKt$daemonMain$1.invoke(main.kt:62)
	at org.jetbrains.kotlin.cli.utilities.MainKt$daemonMain$1.invoke(main.kt:62)
	at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:17)
	at
My implementation is
Copy code
@AutoService(ComponentRegistrar::class)
public open class MyMetaPlugin: Meta {
    override fun intercept(ctx: CompilerContext): List<CliPlugin> =
        TODO()
}
a
which version of Meta and the Kotlin compiler are you using?
j
1.6 for both
a
you might be missing some files in the
resources
folder, here’s how we do it for another plug-in https://github.com/arrow-kt/arrow-meta/tree/main/plugins/analysis/kotlin-plugin/src/main/resources/META-INF/services
j
Yeh I have those files. I have built arrow meta from source on my machine and it has worked fine. I just can't seem to figure out why on my version it doesn't work. My guess is that JVM wise it can't find the default implementations of the Meta class. But everything I try results in the same error
And to clarify, the plugin builds fine, but when it's attached to the compiler it falls over with not compatible, because it got abstract method error
a
which version of meta are you depending on? (or maybe it’s easier to share your Gradle file if that’s possible)
j
I think I have just realised it doesn't support multiplatform. So the mockproject class is in a different package
Managed to get past that but now getting "registerProjectComponents!!!! Called in IDEA!!!! Something is wrong" Assumedly I am a bit stuck now on using it in multiplatform project?
Version wise, I have checked it out
So using master
a
we’ve only checked building the plug-in as a JVM project, and then it works on both JVM and multiplatform projects
j
Yeh I am doing the same thing. However I fall back to that error if I use 1.6.0 from maven
Is it something to do with the jdk8 kotlin dependency maybe?
Copy code
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm")
    kotlin("kapt")
    `java-library`
    `maven-publish`
}

apply(from = "../maven-publishing-setup.kts")

repositories {
    maven("<https://oss.sonatype.org/content/repositories/snapshots/|https://oss.sonatype.org/content/repositories/snapshots/>")
    mavenLocal()
}

dependencies {
//
//    compileOnly("org.jetbrains.kotlin:kotlin-compiler")
//    compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10")

    implementation("io.arrow-kt:arrow-meta:1.6.10")

//    kapt("com.google.auto.service:auto-service:1.0.1")
    api("com.squareup:kotlinpoet:1.10.2")
    implementation(project(":generate-mock-annotations"))

}

tasks.named("compileKotlin") { dependsOn("syncSource") }
repositories {
    mavenCentral()
}

tasks.withType<KotlinCompile> {
    kotlinOptions.freeCompilerArgs = listOf(
        "-Xjvm-default=compatibility",
    )
    kotlinOptions.jvmTarget = "1.8"
}
tasks {
    jar {
        from(
            sourceSets.main.get().compileClasspath.filter { dependency ->
                listOf(
                    "arrow-kt",
                    "ktlint",
                    "ec4j"
                ).any {
                    dependency.absolutePath.contains(it)
                }
            }.map(::zipTree)
        )
    }
}

publishing {
    publications {
        create<MavenPublication>("default") {
            from(components["java"])
            artifact(tasks.kotlinSourcesJar)
        }
    }
}
This is the compiler plugin block
builds ok
Copy code
compilations.getByName("test") {
                kotlinOptions.freeCompilerArgs =
                                                    listOf("-Xplugin=$projectDir/../plugin/build/libs/plugin-1.0.0.jar",
                            "-P", "plugin:arrow.meta.plugin.compiler:generatedSrcOutputDir=$projectDir/build", "-verbose")
a
I wonder where are you getting
arrow-meta:1.6.10
from, only
1.6.0
has been published
j
Oh, that was me playing around with it, trying to change it to 1.6.10, and publishing to my local mvn repo
seeing if that fixed it
I get the same error with both 1.6.0 and 1.5.0-snapshot
changing kotlin 1.6.0, same error
Copy code
Receiver class package.MyMetaPlugin does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
And it says
com.intellij.mock.MockProject
. Where I think that Meta uses
org.jetbrains.kotlin.com.intellij.mock.MockProject
ok, so I think I know the problem. It is to do with kotlin-compiler vs embeddable
Has this worked previously with multiplatform? As I usually create my plugins against kotlin-compiler
j
Finally sorted it:
kotlin.native.useEmbeddableCompilerJar=true in
gradle.properties