elharo commented on code in PR #1004:
URL: https://github.com/apache/maven-enforcer/pull/1004#discussion_r3813280134
##########
enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/BanDistributionManagement.java:
##########
@@ -72,12 +72,23 @@ public void execute() throws EnforcerRuleException {
getLog().debug("We are in the root of the execution and we
have a parent.");
DistributionManagementCheck check = new
DistributionManagementCheck(project);
- check.execute(isAllowRepository(),
isAllowSnapshotRepository(), isAllowSite());
+ executeCheck(check);
}
} else {
getLog().debug("We are in a deeper level.");
DistributionManagementCheck check = new
DistributionManagementCheck(project);
+ executeCheck(check);
+ }
+ }
+
+ private void executeCheck(DistributionManagementCheck check) throws
EnforcerRuleException {
+ try {
check.execute(isAllowRepository(), isAllowSnapshotRepository(),
isAllowSite());
+ } catch (EnforcerRuleException e) {
+ if (getMessage() != null) {
+ throw new EnforcerRuleException(getMessage() +
System.lineSeparator() + e.getMessage(), e);
Review Comment:
do not use System.lineSeparator() here as exception messages must be
platform independent. Use \n
##########
enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/BannedPlugins.java:
##########
@@ -78,7 +78,12 @@ public void execute() throws EnforcerRuleException {
(m1, m2) -> m1.append(m2.toString()))
.toString();
if (!result.isEmpty()) {
- throw new EnforcerRuleException(result);
+ StringBuilder buf = new StringBuilder();
+ if (getMessage() != null) {
+ buf.append(getMessage()).append(System.lineSeparator());
Review Comment:
do not use System.lineSeparator() here as exception messages must be
platform independent. Use \n
##########
enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/BanDuplicatePomDependencyVersions.java:
##########
@@ -119,6 +119,9 @@ private void maven2Validation(Model model) throws
EnforcerRuleException {
if (summary.length() > 0) {
StringBuilder message = new StringBuilder();
+ if (getMessage() != null) {
+ message.append(getMessage()).append(System.lineSeparator());
Review Comment:
do not use System.lineSeparator() here as exception messages must be
platform independent. Use \n
##########
enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/BannedRepositories.java:
##########
@@ -91,7 +91,12 @@ public void execute() throws EnforcerRuleException {
String errMsg = repoErrMsg + pluginRepoErrMsg;
if (!errMsg.isEmpty()) {
- throw new EnforcerRuleException(errMsg);
+ StringBuilder buf = new StringBuilder();
+ if (getMessage() != null) {
+ buf.append(getMessage()).append(System.lineSeparator());
Review Comment:
do not use System.lineSeparator() here as exception messages must be
platform independent. Use \n
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]