spotbugs / spotbugs-gradle-plugin

https://plugins.gradle.org/plugin/com.github.spotbugs
Apache License 2.0
180 stars 68 forks source link

[BUG] Disabling spotbugsIntegrationTest Task in Separate Gradle Configuration File #951

Open CedricNdong opened 1 year ago

CedricNdong commented 1 year ago

Describe the bug When attempting to disable the spotbugsIntegrationTest task in a separate spotbugs.gradle file and then applying this file in the main build.gradle, I encounter a groovy.lang.MissingPropertyException for the task spotbugsIntegrationTest, even though this task exists.

To Reproduce Steps to reproduce the behavior:

  1. Add the SpotBugs plugin with version 5.0.14 in the build.gradle file.
  2. Create a new spotbugs.gradle file in the project's root directory with the content: spotbugsIntegrationTest.enabled = false

image

3.In the build.gradle file, apply the SpotBugs plugin with apply from: "$rootDir/spotbugs.gradle"

  1. Execute the Gradle task to see the error:
  2. See error

Expected behavior The spotbugsIntegrationTest task should be disabled and not run during the build.

Actual behavior I receive the following error: Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'spotbugsIntegrationTest' for root project '...' of type org.gradle.api.Project.

Environment Gradle version: 7.4.2 SpotBugs plugin version: 5.1.1 Java version: openjdk 17.0.6 2023-01-17 Operating System: Windows 11

Additional context I've attempted to use lazy configuration with tasks.named('spotbugsIntegrationTest').configure, but the issue persists.

KengoTODA commented 1 year ago

Thanks for your report, could you try two more approaches:

pro100yevhen commented 6 months ago

Hey there! I encountered a similar issue. My project structure looks like this:

src:
- integrationTest
- main
- test
- pactTest

I'm using Gradle version 8.2.1 and the SpotBugs plugin version 6.0.14. Any insights or suggestions on how to resolve this would be much appreciated!

image

The error: A problem occurred evaluating root project 'skarb-ngo'.

Could not find method spotbugsIntegrationTest() for arguments [build_12mb3e7o58k220dky36lig4uu$_run_closure3$_closure17@513b5b3f] on project ':kafka-starter' of type org.gradle.api.Project.