Skip to content

Commit

Permalink
feat: srop support for SpotBugs 4.4.x and older
Browse files Browse the repository at this point in the history
Signed-off-by: Kengo TODA <skypencil@gmail.com>
  • Loading branch information
KengoTODA committed Jul 31, 2023
1 parent d0bae3c commit 7b514e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
26 changes: 0 additions & 26 deletions src/main/groovy/com/github/spotbugs/snom/SpotBugsTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
private FileCollection pluginJarFiles
private FileCollection spotbugsClasspath

private Provider<Boolean> isSupportingMultipleReports

void setClasses(FileCollection fileCollection) {
this.classes = fileCollection
}
Expand Down Expand Up @@ -361,20 +359,6 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {

def configuration = project.getConfigurations().getByName(SpotBugsPlugin.CONFIG_NAME)
def logger = this.log
isSupportingMultipleReports = project.provider {
configuration.resolve()
java.util.Optional<Dependency> spotbugs =
configuration.getDependencies().stream()
.filter { dependency -> "com.github.spotbugs" == dependency.group && "spotbugs" == dependency.name }
.findFirst()
if (!spotbugs.isPresent()) {
logger.warn("No spotbugs found in the {} configuration", SpotBugsPlugin.CONFIG_NAME)
return false
}
SemanticVersion version = new SemanticVersion(spotbugs.get().getVersion())
logger.debug("Using SpotBugs version {}", version)
return version >= new SemanticVersion("4.5.0")
}

def spotbugsSlf4j = project.configurations.getByName(SpotBugsPlugin.SLF4J_CONFIG_NAME)
spotbugsClasspath = project.layout.files {
Expand Down Expand Up @@ -523,16 +507,6 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
showStackTraces.get();
}

/**
* The multiple reports feature is available from SpotBugs 4.5.0
*
* @see <a href="https://github.com/spotbugs/spotbugs/releases/tag/4.5.0">GitHub Releases</a>
*/
@Internal
boolean isSupportingMultipleReports() {
return isSupportingMultipleReports.getOrElse(Boolean.FALSE).booleanValue()
}

@Internal
String getBaseName() {
String prunedName = name.replaceFirst("spotbugs", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,11 @@ protected List<String> buildArguments(SpotBugsTask task) {
args.add("-progress");
}

if (task.isSupportingMultipleReports()) {
for (SpotBugsReport report : task.getEnabledReports()) {
File reportFile = report.getOutputLocation().getAsFile().get();
File dir = reportFile.getParentFile();
dir.mkdirs();
args.add(report.toCommandLineOption() + "=" + reportFile.getAbsolutePath());
}
} else {
SpotBugsReport report = task.getFirstEnabledReport();
if (report != null) {
File reportFile = report.getOutputLocation().getAsFile().get();
File dir = reportFile.getParentFile();
dir.mkdirs();
args.add(report.toCommandLineOption());
args.add("-outputFile");
args.add(reportFile.getAbsolutePath());
}
for (SpotBugsReport report : task.getEnabledReports()) {
File reportFile = report.getOutputLocation().getAsFile().get();
File dir = reportFile.getParentFile();
dir.mkdirs();
args.add(report.toCommandLineOption() + "=" + reportFile.getAbsolutePath());
}

if (task.getEffort().isPresent()) {
Expand Down

0 comments on commit 7b514e9

Please sign in to comment.