+ * Set to: {@code rulesets/java/quickstart.xml}
*/
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 Collection The valid values are the standard character sets of {@link java.nio.charset.Charset Charset}.
+ * Default is: {@code true}
+ *
+ * Note: If only violations are found, see {@link #failOnViolation(boolean) failOnViolation}
+ *
+ * @param failOnError whether to exit and fail the build if recoverable errors occurred
+ * @return this operation
+ * @see #failOnViolation(boolean)
+ */
+ public PmdOperation failOnError(boolean failOnError) {
+ failOnError_ = failOnError;
+ return this;
+ }
+
+ /**
+ * Sets whether the build will continue on violations.
+ *
+ * Note: If additionally recoverable errors occurred, see {@link #failOnError(boolean) failOnError}
+ *
+ * @param failOnViolation whether to exit and fail the build if violations are found
+ * @return this operation
*/
public PmdOperation failOnViolation(boolean failOnViolation) {
failOnViolation_ = failOnViolation;
@@ -264,8 +525,11 @@ public class PmdOperation extends AbstractOperation
@@ -326,10 +615,22 @@ public class PmdOperation extends AbstractOperation
+ * Previous entries are disregarded.
+ *
+ * @param inputPath one or more paths
+ * @return this operation
+ * @see #addInputPaths(File...)
+ */
+ public PmdOperation inputPaths(File... inputPath) {
+ return inputPathsFiles(List.of(inputPath));
+ }
+
+ /**
+ * Sets paths to source files, or directories containing source files to analyze.
+ *
+ * Previous entries are disregarded.
+ *
+ * @param inputPath one or more paths
+ * @return this operation
+ * @see #addInputPaths(String...)
+ */
+ public PmdOperation inputPaths(String... inputPath) {
+ return inputPathsStrings(List.of(inputPath));
+ }
+
+ /**
+ * Sets paths to source files, or directories containing source files to analyze.
+ *
+ * Previous entries are disregarded.
+ *
+ * @param inputPath a collection of input paths
+ * @return this operation
+ * @see #addInputPaths(Collection)
*/
public PmdOperation inputPaths(Collection
+ * Previous entries are disregarded.
+ *
+ * @param inputPath a collection of input paths
+ * @return this operation
+ * @see #addInputPathsFiles(Collection)
+ */
+ public PmdOperation inputPathsFiles(Collection
+ * Previous entries are disregarded.
+ *
+ * @param inputPath a collection of input paths
+ * @return this operation
+ * @see #addInputPathsStrings(Collection)
+ */
+ public PmdOperation inputPathsStrings(Collection
+ * 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 relativizeRoots(Path... relativeRoot) {
- relativizeRoots_.clear();
- relativizeRoots_.addAll(List.of(relativeRoot));
+ public PmdOperation prependAuxClasspath(String... classpath) {
+ prependClasspath_ = String.join(File.pathSeparator, classpath);
return this;
}
/**
- * Sets several paths to shorten paths that are output in the report. Previous relative paths will be disregarded.
+ * 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
+ * @see #relativizeRoots(Collection)
+ */
+ public PmdOperation relativizeRoots(Path... relativeRoot) {
+ return relativizeRoots(List.of(relativeRoot));
+ }
+
+ /**
+ * Adds several paths to shorten paths that are output in the report.
+ *
+ * @param relativeRoot one or more relative root paths
+ * @return this operation
+ * @see #relativizeRootsFiles(Collection)
+ */
+ public PmdOperation relativizeRoots(File... relativeRoot) {
+ return relativizeRootsFiles(List.of(relativeRoot));
+ }
+
+ /**
+ * Adds several paths to shorten paths that are output in the report.
+ *
+ * @param relativeRoot one or more relative root paths
+ * @return this operation
+ * @see #relativizeRootsStrings(Collection)
+ */
+ public PmdOperation relativizeRoots(String... relativeRoot) {
+ return relativizeRootsStrings(List.of(relativeRoot));
+ }
+
+ /**
+ * Adds several paths to shorten paths that are output in the report.
+ *
+ * @param relativeRoot a collection of relative root paths
+ * @return this operation
+ * @see #relativizeRoots(Path...)
*/
public PmdOperation relativizeRoots(Collection
- * The built-in rule set paths are:
- *
* The built-in rule set paths are:
*
+ * The built-in rule set paths are:
+ *
- *
+ * Sets the Report properties. These are used to create the Renderer.
+ *
+ * @param reportProperties the report properties
+ * @return this operation
*/
- public PmdOperation ruleSets(String... ruleSet) {
- ruleSets_.clear();
- ruleSets_.addAll(Arrays.asList(ruleSet));
+ public PmdOperation reportProperties(Properties reportProperties) {
+ reportProperties_ = reportProperties;
return this;
}
/**
- * Sets the rule set path(s), disregarding any previously set paths.
+ * Sets new rule set paths, disregarding any previous entries.
*
@@ -523,15 +1086,55 @@ public class PmdOperation extends AbstractOperation
+ *
+ * @param ruleSet one or more rule set
+ * @return this operation
+ * @see #addRuleSet(String...)
*/
- public PmdOperation ruleSets(Collection
+ *
+ *
+ * @param ruleSet a collection of rule set paths
+ * @return this operation
+ * @see #addRuleSet(Collection)
+ */
+ public PmdOperation ruleSets(Collection