Cannot locate tasks that match ':buildSrc:compileJava'

I got this error when using gradle 8 when build the project:

Cannot locate tasks that match ':buildSrc:compileJava' as project 'buildSrc' not found in root project 'buildSrc'.

I’m trying to create convention plugin for android using buildSrc with the following configuration:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    `kotlin-dsl`
}

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17.toString()
    }
}

repositories {
    google()
    mavenCentral()
}

dependencies {
    compileOnly("com.android.tools.build:gradle:8.1.4")
    compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21")
}

i’m trying various configuration included my previous configuration which is working well in my old project with gradle 7.
i’m not sure what is the problem, but they keep saying the same errors.

here is my other configuration:

plugins {
    `kotlin-dsl`
}

repositories {
    gradlePluginPortal()
    google()
    mavenCentral()
}

dependencies {
    implementation("com.android.tools.build:gradle:7.4.2")
    implementation("com.android.tools.build:gradle-api:7.4.2")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
    testImplementation("junit:junit:4.13")
}

gradlePlugin {

    // library configs
    plugins {
        register("AndroidLibraryConfigV0") {
            id = "AndroidLibraryConfigV0"
            implementationClass = "com.yesdok.conventionplugin.AndroidLibraryConfigV0"
        }
    }
    plugins {
        register("AndroidLibraryConfigV1") {
            id = "AndroidLibraryConfigV1"
            implementationClass = "com.yesdok.conventionplugin.AndroidLibraryConfigV1"
        }
    }
    plugins {
        register("AndroidLibraryConfigV2") {
            id = "AndroidLibraryConfigV2"
            implementationClass = "com.yesdok.conventionplugin.AndroidLibraryConfigV2"
        }
    }

    // module configs
    plugins {
        register("AndroidModuleConfigV1") {
            id = "AndroidModuleConfigV1"
            implementationClass = "com.yesdok.conventionplugin.AndroidModuleConfigV1"
        }
    }
    plugins {
        register("AndroidModuleConfigV2") {
            id = "AndroidModuleConfigV2"
            implementationClass = "com.yesdok.conventionplugin.AndroidModuleConfigV2"
        }
    }
}

That one is working fine in my old project.
But with new project with gradle 8 i keep getting that error.

Can you share a build --scan if it can be generated?
How do your settings scripts look like?
How do you execute the build?

here is my projectRoot/build.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.name = "DebugRemoverPlugin"
include(":app")

projectRoot/settings.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.name = "DebugRemoverPlugin"
include(":app")

here is my buildSrc gradle config

buildSrc/build.gradle

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    `kotlin-dsl`
}

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17.toString()
    }
}

repositories {
    google()
    mavenCentral()
}

dependencies {
    compileOnly("com.android.tools.build:gradle:8.1.4")
    compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21")
}

that’s all.
i didn’t use buildSrc/settings.gradle

i tried to configure gradle enterprise but i’m not succeed

You just need to run with --scan, no setup needed