Skip to content

Commit 27b11b4

Browse files
authored
Merge pull request #750 from hazendaz/use-commons-io
[cleanup] Use commons io list files intead of plexus utils get files
2 parents 437e9f8 + cd99a1e commit 27b11b4

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2005-2023 the original author or authors.
4+
Copyright 2005-2024 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.

src/main/groovy/org/codehaus/mojo/spotbugs/BaseViolationCheckMojo.groovy

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2005-2023 the original author or authors.
2+
* Copyright 2005-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package org.codehaus.mojo.spotbugs
1717

1818
import groovy.xml.XmlParser
1919
import groovy.xml.XmlSlurper
20+
import org.apache.commons.io.FileUtils
2021

2122
import org.apache.maven.artifact.repository.ArtifactRepository
2223

@@ -40,7 +41,6 @@ import org.apache.maven.project.MavenProject
4041
import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver
4142

4243
import org.codehaus.plexus.resource.ResourceManager
43-
import org.codehaus.plexus.util.FileUtils
4444

4545
abstract class BaseViolationCheckMojo extends AbstractMojo {
4646

@@ -503,16 +503,19 @@ abstract class BaseViolationCheckMojo extends AbstractMojo {
503503
}
504504

505505
private boolean doSourceFilesExist() {
506-
List sourceFiles = new ArrayList()
506+
Collection<File> sourceFiles = new ArrayList<>()
507507

508508
if (this.classFilesDirectory.isDirectory()) {
509-
sourceFiles.addAll(FileUtils.getFiles(classFilesDirectory, SpotBugsInfo.JAVA_REGEX_PATTERN, null))
509+
log.debug("looking for class files with extensions: " + SpotBugsInfo.EXTENSIONS)
510+
sourceFiles.addAll(FileUtils.listFiles(classFilesDirectory, SpotBugsInfo.EXTENSIONS, true))
510511
}
511512

512513
if (this.includeTests && this.testClassFilesDirectory.isDirectory()) {
513-
sourceFiles.addAll(FileUtils.getFiles(testClassFilesDirectory, SpotBugsInfo.JAVA_REGEX_PATTERN, null))
514+
log.debug("looking for test class files: " + SpotBugsInfo.EXTENSIONS)
515+
sourceFiles.addAll(FileUtils.listFiles(testClassFilesDirectory, SpotBugsInfo.EXTENSIONS, true))
514516
}
515517

518+
log.debug("SourceFiles: " + Arrays.toString(sourceFiles));
516519
!sourceFiles.isEmpty()
517520
}
518521

src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsInfo.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2005-2023 the original author or authors.
2+
* Copyright 2005-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,9 +60,9 @@ interface SpotBugsInfo {
6060
static final String JAVA_SOURCES_KEY = "report.spotbugs.javasources"
6161

6262
/**
63-
* The regex pattern to search for java class files.
63+
* The extensions to search files for.
6464
*/
65-
static final String JAVA_REGEX_PATTERN = "**/*.class"
65+
static final String[] EXTENSIONS = [ "class" ]
6666

6767
static final String COMMA = ","
6868

0 commit comments

Comments
 (0)