diff --git a/docs/pages/pmd/userdocs/cpd/cpd.md b/docs/pages/pmd/userdocs/cpd/cpd.md
index 2457b13c0f..0be9c12cac 100644
--- a/docs/pages/pmd/userdocs/cpd/cpd.md
+++ b/docs/pages/pmd/userdocs/cpd/cpd.md
@@ -402,7 +402,7 @@ Andy Glover wrote an Ant task for CPD; here's how to use it:
If not specified, CPD uses the system default encoding."
%}
{% include custom/cli_option_row.html options="failOnError"
- description="Whether to fail the build if any errors occur while processing the files. Since PMD 7.2.0."
+ description="Whether to fail the build if any errors occurred while processing the files. Since PMD 7.2.0."
default="true"
%}
{% include custom/cli_option_row.html options="format"
diff --git a/docs/pages/pmd/userdocs/tools/ant.md b/docs/pages/pmd/userdocs/tools/ant.md
index f2e33a330e..f81e1aa546 100644
--- a/docs/pages/pmd/userdocs/tools/ant.md
+++ b/docs/pages/pmd/userdocs/tools/ant.md
@@ -65,7 +65,7 @@ The examples below won't repeat this taskdef element, as this is always required
failOnError |
- Whether or not to fail the build if any processing errors occur while analyzing files. |
+ Whether or not to fail the build if any recoverable errors occurred while analyzing files. |
No |
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index fd4c83473a..78bf29e02f 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -65,19 +65,27 @@ Since this release, PMD will also expose any getter returning a collection of an
a build with errors will now fail and with that parameter, the previous behavior can be restored.
This parameter is available for both PMD and CPD.
-* The CLI parameter `--skip-lexical-errors` is deprecated. Use the new parameter `--[no-]--fail-on-error` instead.
+* The CLI parameter `--skip-lexical-errors` is deprecated. By default, lexical errors are skipped but the
+ build is failed. Use the new parameter `--[no-]fail-on-error` instead to control whether to fail the build or not.
##### Ant
-* CPDTask has a new parameter `failOnError`. In controls, whether to fail the build if any recoverable errors occurred.
+* CPDTask has a new parameter `failOnError`. It controls, whether to fail the build if any recoverable error occurred.
By default, the build will fail. CPD will still create a report with all detected duplications, but the report might
be incomplete.
-* The parameter `skipLexicalError` in CPDTask is deprecated. Use the new parameter `failOnError` instead.
+* The parameter `skipLexicalError` in CPDTask is deprecated and ignored. Lexical errors are now always skipped.
+ Use the new parameter `failOnError` instead to control whether to fail the build or not.
#### Deprecated API
+* pmd-ant
+ * {% jdoc !!ant::ant.CPDTask#setSkipLexicalErrors(boolean) %}: Use {% jdoc ant::ant.CPDTask#setFailOnError(boolean) %}
+ instead to control, whether to ignore errors or fail the build.
+* pmd-core
+ * {% jdoc !!core::cpd.CPDConfiguration#isSkipLexicalErrors() %} and {% jdoc core::cpd.CPDConfiguration#setSkipLexicalErrors(boolean) %}:
+ Use {%jdoc core::AbstractConfiguration#setFailOnError(boolean) %} to control whether to ignore errors or fail the build.
* pmd-java
- * {% jdoc !!java::lang.java.ast.ASTResource#getStableName() %} and the corresponding attribute `@StableName`
+ * {% jdoc !!java::lang.java.ast.ASTResource#getStableName() %} and the corresponding attribute `@StableName`.
### ✨ External Contributions
diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java
index 423f48d41c..b82671c22f 100644
--- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java
+++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java
@@ -103,8 +103,9 @@ public class CPDTask extends Task {
config.setSkipDuplicates(skipDuplicateFiles);
if (skipLexicalErrors) {
- log("skipLexicalErrors is deprecated and ignored. Lexical errors are now by default skipped. Use failOnError=\"false\" to not fail the build.", Project.MSG_WARN);
- failOnError = false;
+ log("skipLexicalErrors is deprecated since 7.2.0 and the property is ignored. "
+ + "Lexical errors are now skipped by default and the build is failed. "
+ + "Use failOnError=\"false\" to not fail the build.", Project.MSG_WARN);
}
// implicitly enable skipLexicalErrors, so that we can fail the build at the end. A report is created in any case.
@@ -129,10 +130,11 @@ public class CPDTask extends Task {
int errors = config.getReporter().numErrors();
if (errors > 0) {
+ String message = String.format("There were %d recovered errors during analysis.", errors);
if (failOnError) {
- throw new BuildException("There were " + errors + " recovered errors during analysis. Ignore these with failOnError=\"true\".");
+ throw new BuildException(message + " Ignore these with failOnError=\"true\".");
} else {
- log("There were " + errors + " recovered errors during analysis. Not failing build, because failOnError=\"false\".", Project.MSG_WARN);
+ log(message + " Not failing build, because failOnError=\"false\".", Project.MSG_WARN);
}
}
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java
index 35261b1357..567917a98f 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java
@@ -390,7 +390,7 @@ public abstract class AbstractConfiguration {
* @return failOnViolation
*
* @see #isFailOnError()
- * @since 7.2.0
+ * @since 6.0.0
*/
public boolean isFailOnViolation() {
return failOnViolation;
@@ -422,7 +422,7 @@ public abstract class AbstractConfiguration {
* @return failOnError
*
* @see #isFailOnViolation()
- * @since 6.0.0
+ * @since 7.2.0
*/
public boolean isFailOnError() {
return failOnError;