Skip to content
This repository has been archived by the owner on Oct 7, 2019. It is now read-only.

Build is not failing on project with only test sources root #33

Open
mkordas opened this issue Nov 22, 2015 · 0 comments
Open

Build is not failing on project with only test sources root #33

mkordas opened this issue Nov 22, 2015 · 0 comments

Comments

@mkordas
Copy link

mkordas commented Nov 22, 2015

FindBugs Maven Plugin behaves differently depending whether src/main/java is empty or not. If it doesn't exist (module is test-only and contains only src/test/java) build is not failing:

[INFO] --- findbugs-maven-plugin:3.0.3:findbugs (findbugs) @ findbugs-fail-build ---
[INFO] Fork Value is true
     [java] Warnings generated: 1
[INFO] Done FindBugs Analysis....
[INFO] 
[INFO] <<< findbugs-maven-plugin:3.0.3:check (findbugs) < :findbugs @ findbugs-fail-build <<<
[INFO] 
[INFO] --- findbugs-maven-plugin:3.0.3:check (findbugs) @ findbugs-fail-build ---

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

When there is some production code in module (src/main/java not empty) the build fails:

[INFO] --- findbugs-maven-plugin:3.0.3:findbugs (findbugs) @ findbugs-fail-build ---
[INFO] Fork Value is true
     [java] Warnings generated: 1
[INFO] Done FindBugs Analysis....
[INFO] 
[INFO] <<< findbugs-maven-plugin:3.0.3:check (findbugs) < :findbugs @ findbugs-fail-build <<<
[INFO] 
[INFO] --- findbugs-maven-plugin:3.0.3:check (findbugs) @ findbugs-fail-build ---
[INFO] BugInstance size is 1
[INFO] Error size is 0
[INFO] Total bugs: 1
[INFO] Private method io.github.mkordas.ClassWithFindBugsViolationInTest.unusedPrivateMethod() is never called [io.github.mkordas.ClassWithFindBugsViolationInTest] At ClassWithFindBugsViolationInTest.java:[line 5] UPM_UNCALLED_PRIVATE_METHOD
[INFO] 
To see bug detail using the Findbugs GUI, use the following command "mvn findbugs:gui"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

I think it is bug in FindbugsViolationCheckMojo there's an if checking whether 'main' classes exist and if not, plugin assumes that there was nothing analyzed and code to fail the build is not invoked.

There are two workarounds:

  • add
    <classFilesDirectory>${project.build.testOutputDirectory}</classFilesDirectory>
    to configuration
  • add any code to src/main/java
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant