Skip to content

Commit

Permalink
Merge pull request #750 from hazendaz/use-commons-io
Browse files Browse the repository at this point in the history
[cleanup] Use commons io list files intead of plexus utils get files
  • Loading branch information
hazendaz committed Jan 6, 2024
2 parents 437e9f8 + cd99a1e commit 27b11b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2005-2023 the original author or authors.
Copyright 2005-2024 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2005-2023 the original author or authors.
* Copyright 2005-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@ package org.codehaus.mojo.spotbugs

import groovy.xml.XmlParser
import groovy.xml.XmlSlurper
import org.apache.commons.io.FileUtils

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

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

import org.codehaus.plexus.resource.ResourceManager
import org.codehaus.plexus.util.FileUtils

abstract class BaseViolationCheckMojo extends AbstractMojo {

Expand Down Expand Up @@ -503,16 +503,19 @@ abstract class BaseViolationCheckMojo extends AbstractMojo {
}

private boolean doSourceFilesExist() {
List sourceFiles = new ArrayList()
Collection<File> sourceFiles = new ArrayList<>()

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

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2005-2023 the original author or authors.
* Copyright 2005-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,9 +60,9 @@ interface SpotBugsInfo {
static final String JAVA_SOURCES_KEY = "report.spotbugs.javasources"

/**
* The regex pattern to search for java class files.
* The extensions to search files for.
*/
static final String JAVA_REGEX_PATTERN = "**/*.class"
static final String[] EXTENSIONS = [ "class" ]

static final String COMMA = ","

Expand Down

0 comments on commit 27b11b4

Please sign in to comment.