Skip to content

Task with name 'mergeDiktatReports' not found in root project #1920

@sergeypospelov

Description

@sergeypospelov

Describe the bug

In USVM we use gradle convention plugin (buildSrc) to share build logic. When we include Diktat gradle plugin into usvm.kotlin-conventions.gradle.kts, the build fails with the exception.

Expected behavior

The build succeeds.

Observed behavior

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/sergey/Programming/Work/usvm/usvm-core/build.gradle.kts' line: 1

* What went wrong:
An exception occurred applying plugin request [id: 'usvm.kotlin-conventions']
> Failed to apply plugin 'com.saveourtool.diktat'.
   > Task with name 'mergeDiktatReports' not found in root project 'usvm'.

Steps to Reproduce

Project structure:

buildSrc/
    src/main/kotlin/
        usvm.kotlin-conventions.gradle.kts
    build.gradle.kts
usvm-core/
    src/
    build.gradle.kts
gradle/
settings.gradle.kts
diktat-analysis.yml
gradle.properties
gradlew
gradlew.bat

buildSrc/build.gradle.kts

plugins {
    `kotlin-dsl`
}

repositories {
    mavenCentral()
    gradlePluginPortal()
}

val kotlinVersion = "1.9.23"
val diktatVersion = "2.0.0"

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
    implementation("com.saveourtool.diktat:diktat-gradle-plugin:$diktatVersion")
}

buildSrc/src/main/kotlin/usvm.kotlin-conventions.gradle.kts

plugins {
    kotlin("jvm")
    `java-library`
    `maven-publish`
    id("com.saveourtool.diktat")
}
// ...

usvm-core/build.gradle.kts

plugins {
    id("usvm.kotlin-conventions")
}

Environment information

  • diktat version: 2.0.0
  • build tool: gradle
  • how is diktat run: plugin
  • link: USVM

Extra

Brief investigation led to this snippet:

val rootMergeSarifReportsTask = if (path == rootProject.path) {
tasks.register(MERGE_SARIF_REPORTS_TASK_NAME, SarifReportMergeTask::class.java) { reportMergeTask ->
reportMergeTask.output.set(getGitHubActionReporterMergeOutput())
}
} else {
rootProject.tasks.named(MERGE_SARIF_REPORTS_TASK_NAME, SarifReportMergeTask::class.java)
}

Looks like we won't register any task if there are no top-level build.gradle.kts.

Adding build.gradle.kts only with

plugins {
    id("com.saveourtool.diktat")
}

solves the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions