This message was deleted.
# community-support
s
This message was deleted.
m
Where is the code ? johntravoltalookingaround
Might be that your lambda is inline?
Another issue you might bump into with lambdas is that some of them use invokedynamic starting with some version of Kotlin: https://github.com/gradle/gradle/issues/17052 But IIRC, that causes tasks to be not up-to-date, not
NoClassDefFoundError
e
I typed it up, but then realized a repro project might be better, so I'm working on that (and naturally I can't repro it) 🙈
Here's a repro project showing a
NoClassDefFoundError
seemingly caused by a nested lambda that is referenced in bytecode but is not getting compiled to a class file. If you run:
Copy code
cd plugin
./gradlew publishToMavenLocal
cd ../app
./gradlew tasks
then you should see the failure:
Copy code
* What went wrong:
Com_eygraber_publish_gradle$2$1$1
> Com_eygraber_publish_gradle$2$1$1
To get it to work, edit
plugin/src/main/kotlin/com.eygraber-publish.gradle.kts
line 24 from:
Copy code
repositories {
  githubPackagesPublishing(
    owner = "eygraber",
    repo = repoName
  )
}
to
Copy code
repositories.githubPackagesPublishing(
  owner = "eygraber",
  repo = repoName
)
then run the steps above again and the task will complete successfully.
m
Whatever issue this is, looks like it happens when compiling the plugin. If you unzip
compiler-issue-plugin-0.0.1.jar
, you will not find a matching .class file for
Com_eygraber_publish_gradle$2$1$1
What you can do is try to remove the precompiled script plugin support:
Copy code
plugins {
    `embedded-kotlin`
    id("org.jetbrains.kotlin.plugin.sam.with.receiver")
    id("java-gradle-plugin")
    alias(libs.plugins.publish)
}

samWithReceiver {
    annotation("org.gradle.api.HasImplicitReceiver")
}

gradlePlugin {
    plugins {
        create("com.eygraber-publish") {
            id = "com.eygraber-publish"
            implementationClass = "MyPlugin"
        }
    }
}
The
kotlin-dsl
plugin does a bunch of things to support precompiled script plugins. I'd suspect something is lost there or there is some unfortunate interaction with the Kotlin compiler
By using "regular" (i.e. not precompiled) Kotlin plugins, you'll also save some time. See also https://github.com/android/nowinandroid/issues/39
e
remove the precompiled script plugin support
I have a feeling that will fix it as well, however I found a workaround that's much less involved (see the end of my previous message) I'm going to file an issue for it, but I thought I'd put it here first in case anyone was already aware of the problem
By using "regular" (i.e. not precompiled) Kotlin plugins, you'll also save some time
These plugins are in a different project and are compiled into a separate artifact, precisely to solve the issue you linked 😁
m
Share the link to the issue here when you have it so we can
👍 1
e
v
The question is whether it is a Gradle or Kotlin bug. We'll see.
👀 2