Unresolved reference: include


I have a weird problem. I wrote a plugin in the buildSrc catalog, and everything works fine.
Now I want to publish it on https://plugins.gradle.org/ so I moved it to :plugin module. Everything else stays the same.
And now I can’t build it because I’m getting an error:
Unresolved reference: include

Part of the code that fails.

            subProject.fileTree(subProject.projectDir).matching {
            }.onEach { file ->

When I’m removing this incude, I can build this :plugin module.
Any ideas?

You probably do not apply the kotlin-dsl plugin which among other things applies the sam-with-receiver plugin.
So either apply the kotlin-dsl plugin, or do the parts it does and that you need manually, or use it instead of this.

Thank you for replying. I have kotlin-dsl added.

My build.gradle.kts file:

plugins {
    id("com.gradle.plugin-publish") version "1.2.1"

group = ...
version = ...

gradlePlugin {

dependencies {

Can you share the project?

This is probably caused by

The embedded-kotlin and kotlin-dsl plugins rely on features of Kotlin 1.8.20 that might work differently than in the requested version 1.9.0.
Kotlin DSL property assignment is an incubating feature.

Because when you change the KGP version to 1.8.20, it works as expected.
Or if you change the this to it it also works, but then is shown as error in the IDE.

1 Like

Thank you!
I thought that this was just a warning but fortunate, this was a main issue.
So I downgraded the kotlin android plugin to 1.8.22 and compose-compiler to 1.4.6, and started working.
Now I need to figure out how to bring back the newest Kontlin android plugin.

1 Like