diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 508f6a5..bf43624 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -47,11 +47,11 @@ jobs: uses: actions/configure-pages@v3 - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v1 with: # Upload generated Javadocs repository path: "build/javadoc/" - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v1 diff --git a/src/bld/java/rife/bld/extension/PmdOperationBuild.java b/src/bld/java/rife/bld/extension/PmdOperationBuild.java index 616d5d5..eb43550 100644 --- a/src/bld/java/rife/bld/extension/PmdOperationBuild.java +++ b/src/bld/java/rife/bld/extension/PmdOperationBuild.java @@ -31,7 +31,7 @@ public class PmdOperationBuild extends Project { public PmdOperationBuild() { pkg = "rife.bld.extension"; name = "bld-pmd"; - version = version(1, 1, 11); + version = version(1, 1, 10); javaRelease = 17; @@ -40,7 +40,7 @@ public class PmdOperationBuild extends Project { repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS); - var pmd = version(7, 10, 0); + var pmd = version(7, 9, 0); scope(compile) .include(dependency("com.uwyn.rife2", "bld", version(2, 2, 0))) .include(dependency("net.sourceforge.pmd", "pmd-java", pmd)); @@ -49,7 +49,7 @@ public class PmdOperationBuild extends Project { scope(test) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4))) - .include(dependency("org.assertj", "assertj-core", version(3, 27, 3))); + .include(dependency("org.assertj", "assertj-core", version(3, 27, 2))); javadocOperation() .javadocOptions() diff --git a/src/main/java/rife/bld/extension/PmdOperation.java b/src/main/java/rife/bld/extension/PmdOperation.java index aa0a61d..0e5ef6f 100644 --- a/src/main/java/rife/bld/extension/PmdOperation.java +++ b/src/main/java/rife/bld/extension/PmdOperation.java @@ -49,10 +49,6 @@ public class PmdOperation extends AbstractOperation { public static final String RULE_SET_DEFAULT = "rulesets/java/quickstart.xml"; private static final Logger LOGGER = Logger.getLogger(PmdOperation.class.getName()); private static final String PMD_DIR = "pmd"; - /** - * The list of paths to exclude. - */ - private final List excludes_ = new ArrayList<>(); /** * The input paths (source) list. */ @@ -105,10 +101,6 @@ public class PmdOperation extends AbstractOperation { * The default language version(s). */ private Collection languageVersions_ = new ArrayList<>(); - /** - * The classpath to prepend. - */ - private String prependClasspath_; /** * The project reference. */ @@ -280,6 +272,7 @@ public class PmdOperation extends AbstractOperation { return cache(Path.of(cache)); } + /** * Sets the default language version to be used for all input files. * @@ -321,37 +314,6 @@ public class PmdOperation extends AbstractOperation { return this; } - /** - * Adds paths to exclude from the analysis. - * - * @param excludes one or more paths to exclude - * @return this operation - */ - public PmdOperation excludes(Path... excludes) { - excludes_.addAll(List.of(excludes)); - return this; - } - - /** - * Adds paths to exclude from the analysis. - * - * @param excludes paths to exclude - * @return this operation - */ - public PmdOperation excludes(Collection excludes) { - excludes_.addAll(excludes); - return this; - } - - /** - * Returns the paths to exclude from the analysis. - * - * @return the exclude paths - */ - public List excludes() { - return excludes_; - } - /** * Performs the PMD code analysis operation. */ @@ -494,17 +456,8 @@ public class PmdOperation extends AbstractOperation { * @return this operation */ public PMDConfiguration initConfiguration(String commandName) { - var config = new PMDConfiguration(); + PMDConfiguration config = new PMDConfiguration(); - // addRelativizeRoots - config.addRelativizeRoots(relativizeRoots_.stream().toList()); - - // prependAuxClasspath - if (prependClasspath_ != null) { - config.prependAuxClasspath(prependClasspath_); - } - - // setAnalysisCacheLocation if (cache_ == null && project_ != null && incrementalAnalysis_) { config.setAnalysisCacheLocation( Paths.get(project_.buildDirectory().getPath(), PMD_DIR, PMD_DIR + "-cache").toFile().getAbsolutePath()); @@ -512,50 +465,38 @@ public class PmdOperation extends AbstractOperation { config.setAnalysisCacheLocation(cache_.toFile().getAbsolutePath()); } - // setDefaultLanguageVersions + config.setFailOnError(failOnError_); + config.setFailOnViolation(failOnViolation_); + if (languageVersions_ != null) { config.setDefaultLanguageVersions(languageVersions_.stream().toList()); } - // setExcludes - if (!excludes_.isEmpty()) { - config.setExcludes(excludes_); - } - - // setFailOnError - config.setFailOnError(failOnError_); - // setFailOnViolation - config.setFailOnViolation(failOnViolation_); - - // setForceLanguageVersion if (forcedLanguageVersion_ != null) { config.setForceLanguageVersion(forcedLanguageVersion_); } - // setIgnoreFilePath if (ignoreFile_ != null) { config.setIgnoreFilePath(ignoreFile_); } - // setIgnoreIncrementalAnalysis config.setIgnoreIncrementalAnalysis(!incrementalAnalysis_); - // setInputPathList if (inputPaths_.isEmpty()) { throw new IllegalArgumentException(commandName + ": InputPaths required."); } else { config.setInputPathList(inputPaths_.stream().toList()); } + if (reportProperties_ != null) { + config.setReportProperties(reportProperties_); + } - // setInputUri if (inputUri_ != null) { config.setInputUri(inputUri_); } - // setMinimumPriority config.setMinimumPriority(rulePriority_); - // setReportFile if (project_ != null) { config.setReportFile(Objects.requireNonNullElseGet(reportFile_, () -> Paths.get(project_.buildDirectory().getPath(), @@ -564,25 +505,12 @@ public class PmdOperation extends AbstractOperation { config.setReportFile(reportFile_); } - // setReportFormat + config.addRelativizeRoots(relativizeRoots_.stream().toList()); config.setReportFormat(reportFormat_); - - // setReportProperties - if (reportProperties_ != null) { - config.setReportProperties(reportProperties_); - } - - // setRuleSets config.setRuleSets(ruleSets_.stream().toList()); - - // setShowSuppressedViolations config.setShowSuppressedViolations(showSuppressed_); - // setSourceEncoding config.setSourceEncoding(encoding_); - // setSuppressMarker config.setSuppressMarker(suppressedMarker_); - - // setThreads config.setThreads(threads_); return config; @@ -782,36 +710,11 @@ public class PmdOperation extends AbstractOperation { return numViolations; } - /** - * Prepend the specified classpath like string to the current ClassLoader of the configuration. If no ClassLoader - * is currently configured, the ClassLoader used to load the PMDConfiguration class will be used as the parent - * ClassLoader of the created ClassLoader. - *

- * If the classpath String looks like a URL to a file (i.e. starts with {@code file://}) the file will be read with - * each line representing an entry on the classpath. - * - * @param classpath one or more classpath - * @return this operation - */ - public PmdOperation prependAuxClasspath(String... classpath) { - prependClasspath_ = String.join(File.pathSeparator, classpath); - return this; - } - - /** - * Returns the prepended classpath. - * - * @return the classpath - */ - public String prependAuxClasspath() { - return prependClasspath_; - } - /** * Adds several paths to shorten paths that are output in the report. * * @param relativeRoot one or more relative root paths - * @return this operation + * @return this operations * @see #relativizeRoots(Collection) */ public PmdOperation relativizeRoots(Path... relativeRoot) { @@ -822,7 +725,7 @@ public class PmdOperation extends AbstractOperation { * Adds several paths to shorten paths that are output in the report. * * @param relativeRoot one or more relative root paths - * @return this operation + * @return this operations * @see #relativizeRootsFiles(Collection) */ public PmdOperation relativizeRoots(File... relativeRoot) { @@ -833,7 +736,7 @@ public class PmdOperation extends AbstractOperation { * Adds several paths to shorten paths that are output in the report. * * @param relativeRoot one or more relative root paths - * @return this operation + * @return this operations * @see #relativizeRootsStrings(Collection) */ public PmdOperation relativizeRoots(String... relativeRoot) { @@ -844,7 +747,7 @@ public class PmdOperation extends AbstractOperation { * Adds several paths to shorten paths that are output in the report. * * @param relativeRoot a collection of relative root paths - * @return this operation + * @return this operations * @see #relativizeRoots(Path...) */ public PmdOperation relativizeRoots(Collection relativeRoot) { @@ -865,7 +768,7 @@ public class PmdOperation extends AbstractOperation { * Adds several paths to shorten paths that are output in the report. * * @param relativeRoot a collection of relative root paths - * @return this operation + * @return this operations * @see #relativizeRoots(File...) */ public PmdOperation relativizeRootsFiles(Collection relativeRoot) { @@ -876,7 +779,7 @@ public class PmdOperation extends AbstractOperation { * Adds several paths to shorten paths that are output in the report. * * @param relativeRoot a collection of relative root paths - * @return this operation + * @return this operations * @see #relativizeRoots(String...) */ public PmdOperation relativizeRootsStrings(Collection relativeRoot) { diff --git a/src/test/java/rife/bld/extension/PmdOperationTest.java b/src/test/java/rife/bld/extension/PmdOperationTest.java index 48545e5..08df70f 100644 --- a/src/test/java/rife/bld/extension/PmdOperationTest.java +++ b/src/test/java/rife/bld/extension/PmdOperationTest.java @@ -166,24 +166,6 @@ class PmdOperationTest { assertThat(config.getSourceEncoding()).as("ISO_8859").isEqualTo(StandardCharsets.ISO_8859_1); } - @Test - void testExcludes() { - var foo = Path.of("foo/bar"); - var bar = Path.of("bar/foo"); - var foz = Path.of("foz/baz"); - var baz = Path.of("baz/foz"); - - var excludes = List.of(foo, bar); - var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).excludes(excludes); - var config = pmd.initConfiguration(COMMAND_NAME); - assertThat(config.getExcludes()).containsExactly(excludes.toArray(new Path[0])); - - pmd = pmd.excludes(baz, foz); - assertThat(pmd.excludes()).hasSize(4); - config = pmd.initConfiguration(COMMAND_NAME); - assertThat(config.getExcludes()).hasSize(4).contains(bar, foz); - } - @Test void testExecute() throws ExitStatusException { var pmd = new PmdOperation().fromProject(new BaseProject()); @@ -386,12 +368,6 @@ class PmdOperationTest { assertThat(pmd).isEqualTo(0); } - @Test - void testPrependAuxClasspath() { - var pmd = newPmdOperation().ruleSets(CATEGORY_FOO).prependAuxClasspath("foo", "bar"); - assertThat(pmd.prependAuxClasspath()).isEqualTo("foo" + File.pathSeparator + "bar"); - } - @Test void testPriority() throws ExitStatusException { var pmd = newPmdOperation().inputPaths(CODE_STYLE_SAMPLE).minimumPriority(RulePriority.HIGH);