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

[HELP] Compiler Plugins from Command Line. #859

Open
DiCaius opened this issue Sep 8, 2021 · 0 comments
Open

[HELP] Compiler Plugins from Command Line. #859

DiCaius opened this issue Sep 8, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@DiCaius
Copy link

DiCaius commented Sep 8, 2021

Describe the bug
I'm writing a small bazel rule to run the kotlin compiler on some targets and I was trying to get the compiler command down to get the code to properly compile.

To Reproduce
I have the following code in my src/main/kotlin/common/test.kt:

package common

import arrow.Optics

@Optics
data class Person(val name: String, val address: Address) { companion object }

@Optics
data class Address(val street: String) { companion object }

fun main() {
    val person = Person("Jarle", Address("Veien 1"))
    val streetLens = Person.address.street
    val upperCase = streetLens.modify(person, String::toUpperCase)
    println("HELLO, WEARY TRAVELLER!")
}

Running the following command:

kotlinc src/main/kotlin/common/test.kt -include-runtime -d test.jar -classpath $BAZEL_JARS/io_arrow_kt_arrow_core_0_13_2.jar:$BAZEL_JARS/io_arrow_kt_arrow_optics_0_13_2.jar:$BAZEL_JARS/io_arrow_kt_arrow_annotations_0_13_2.jar:$BAZEL_JARS/io_arrow_kt_arrow_meta_1_5_10_SNAPSHOT.jar:$BAZEL_JARS/io_arrow_kt_arrow_meta_prelude_1_5_10_SNAPSHOT.jar:$BAZEL_JARS/io_arrow_kt_arrow_optics_plugin_1_5_10_SNAPSHOT.jar -Xplugin=$BAZEL_JARS/kotlin/lib/annotations-13.0.jar -Xplugin=$BAZEL_JARS/io_arrow_kt_arrow_meta_1_5_10_SNAPSHOT.jar -Xplugin=$BAZEL_JARS/io_arrow_kt_arrow_optics_plugin_1_5_10_SNAPSHOT.jar -P plugin:arrow.meta.plugin.compiler:generatedSrcOutputDir=$PROJECT_ROOT/build -verbose

Results in:

logging: using Kotlin home directory /nix/store/cqx94xvmqan7kmbwap5xzxbadqmscfp7-kotlin-1.5.21
logging: using JVM IR backend
logging: configuring the compilation environment
exception: java.lang.IllegalStateException: The provided plugin arrow.meta.OpticsMetaPlugin is not compatible with this version of compiler
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:617)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:130)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:170)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:431)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:226)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:152)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:90)
	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.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:222)
	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:214)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:271)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.jetbrains.kotlin.preloading.Preloader.run(Preloader.java:87)
	at org.jetbrains.kotlin.preloading.Preloader.main(Preloader.java:44)
Caused by: java.lang.AbstractMethodError: Receiver class arrow.meta.OpticsMetaPlugin 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.
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:609)
	... 23 more

I suspect I messed up either the classpath or there's some option missing to properly link arrow-optics-plugin to arrow-meta

Expected behavior
The code to compile normally.

Screenshots
Not applicable.

Environment (please complete the following information):

Additional context
I'm not running this from my bazel rule just yet, I'm running this directly from the command line for the time being.

@DiCaius DiCaius added the bug Something isn't working label Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant