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

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

Open
sergeypospelov opened this issue Mar 11, 2024 · 1 comment
Open
Labels
bug Something isn't working
Milestone

Comments

@sergeypospelov
Copy link

sergeypospelov commented Mar 11, 2024

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.

@sergeypospelov sergeypospelov added the bug Something isn't working label Mar 11, 2024
@nulls
Copy link
Member

nulls commented Mar 11, 2024

hi @sergeypospelov, thanks for raising a bug and a brief investigation. We will look into it

@0x6675636b796f75676974687562 0x6675636b796f75676974687562 added this to the 2.1.0 milestone Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants