Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,27 @@ abstract class AbstractFindBugsPluginIntegrationTest extends AbstractIntegration
result.assertTaskNotSkipped(":findbugsMain")
}

def "does not fail if resources are generated into classes"() {
given:
goodCode()
buildFile << """
compileJava {
doLast {
def manifest = new File(destinationDir, "META-INF/MANIFEST.MF")
manifest.parentFile.mkdirs()
manifest.text = "manifest"
def properties = new File(destinationDir, "com/example/service.properties")
properties.parentFile.mkdirs()
properties.text = "someProp=value"
}
}
"""
when:
succeeds("check")
then:
!result.error.contains("Wrong magic bytes")
}

private static boolean containsXmlMessages(File xmlReportFile) {
new XmlSlurper().parseText(xmlReportFile.text).BugInstance.children().collect { it.name() }.containsAll(['ShortMessage', 'LongMessage'])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,23 @@ public FileTree getSource() {
@SkipWhenEmpty
@PathSensitive(PathSensitivity.RELATIVE)
@InputFiles
protected FileCollection getCandidateClassFiles() {
// We need to resolve the classes into a set of files so @SkipWhenEmpty will work
// Otherwise, a collection of empty directories is not seen as "empty"
return getClasses().getAsFileTree();
}

/**
* The class directories to be analyzed.
*/
@Internal
public FileCollection getClasses() {
return classes;
}


/**
* The classes to be analyzed.
* The class directories to be analyzed.
*/
public void setClasses(FileCollection classes) {
this.classes = classes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected void configureForSourceSet(final SourceSet sourceSet, FindBugs task) {
taskMapping.map("classes", new Callable<FileCollection>() {
@Override
public FileCollection call() {
return sourceSet.getOutput().getClassesDirs().getAsFileTree();
return sourceSet.getOutput().getClassesDirs();
}
});
taskMapping.map("classpath", new Callable<FileCollection>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class FindBugsPluginTest extends AbstractProjectBuilderSpec {
description == "Run FindBugs analysis for ${sourceSet.name} classes"
source as List == sourceSet.allJava as List
findbugsClasspath == project.configurations.findbugs
classes.empty // no classes to analyze
candidateClassFiles.empty // no classes to analyze
reports.xml.destination == project.file("build/reports/findbugs/${sourceSet.name}.xml")
!ignoreFailures
effort == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</thead>
<tr>
<td>classes</td>
<td><literal><replaceable>sourceSet</replaceable>.output</literal></td>
<td><literal><replaceable>sourceSet</replaceable>.output.classesDirs</literal></td>
</tr>
<tr>
<td>classpath</td>
Expand Down