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

possible incompatibility with the gatlin plugin #10

Closed
corbym opened this issue Jul 27, 2023 · 4 comments · Fixed by #11
Closed

possible incompatibility with the gatlin plugin #10

corbym opened this issue Jul 27, 2023 · 4 comments · Fixed by #11

Comments

@corbym
Copy link

corbym commented Jul 27, 2023

Firstly, thanks for some excellent libraries, very useful!

There seems to be an incompatibility with the gatlin plugin:

> Task :x:x:compileGatlingKotlin FAILED
e: java.util.NoSuchElementException: List is empty.
	at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:214)
	at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:197)
	at io.koalaql.kapshot.plugin.GenerationExtension.generate(GenerationExtension.kt:22)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda$0(JvmIrCodegenFactory.kt:190)
	at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:107)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:224)
	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:57)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.convertToIr(KotlinToJVMBytecodeCompiler.kt:225)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:102)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:168)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:100)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:46)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:495)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:133)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:486)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:409)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:290)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:112)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:627)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1587)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------

Build time:   2022-11-25 13:35:10 UTC
Revision:     daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8

Kotlin:       1.7.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.3 (Amazon.com Inc. 17.0.3+6-LTS)
OS:           Mac OS X 13.4.1 x86_64

> java -version
openjdk version "17.0.3" 2022-04-19 LTS
OpenJDK Runtime Environment Corretto-17.0.3.6.1 (build 17.0.3+6-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.3.6.1 (build 17.0.3+6-LTS, mixed mode, sharing)

To replicate:

  • be me
  • have a project with a gatling plugin and some gatling tests in the gatling module
  • also have a kotlin main module
  • project also uses the kapshot plugin
plugins {
   id("io.koalaql.kapshot-plugin") version "0.1.2"
}
  • mfw try to run the gatling tests using gradlew gatlingRun

I haven't looked too deeply at the issue, but it seems to me this could be easily fixed by not using first and using firstOrNull where the generator is trying to, er, generate.

@corbym
Copy link
Author

corbym commented Aug 29, 2023

@mfwgenerics any thoughts about this? even negative?

@mfwgenerics
Copy link
Owner

Hey @corbym! Just saw this issue now. Thanks for taking a look at my humble plugin.

It's hard to say what's going wrong here without a repro, but I've had some thoughts:

  1. Looks like the exception is coming from here:

val addSourceToBlock = pluginContext
.referenceFunctions(CallableId(
packageName = FqName("io.koalaql.kapshot"),
callableName = Name.identifier("addSourceToBlock")
))
.first()

  1. I believe it's correct for this to throw an exception, since the plugin can't function correctly without being able to reference that addSourceToBlock function.

  2. addSourceToBlock is provided by the runtime dependency library, added to the project here:

override fun apply(target: Project) {
/* make sure we don't try to add dependency until it has been configured by kotlin plugin */
target.plugins.withId("org.jetbrains.kotlin.jvm") {
target.dependencies.add("implementation", "io.koalaql:kapshot-runtime:${BuildConfig.VERSION}")
}
}

It seems to me the problem might be in the inclusion of the runtime dependency. For example, I'm wondering if it should be "api" instead of "implementation". As a workaround, could you try adding it directly to your project/module? I've linked the Maven Central page below.

https://mvnrepository.com/artifact/io.koalaql/kapshot-runtime

@corbym
Copy link
Author

corbym commented Sep 20, 2023

It seems to be ok if I add the api("io.koalaql:kapshot-runtime:0.1.2") into my project's common.gradle deps list, yes.

This can unblock me for now, thanks!

@mfwgenerics
Copy link
Owner

Glad that unblocked you! I'll keep the issue open until I've gotten around to reproducing and fixing the problem.

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 a pull request may close this issue.

2 participants