From fa91bff92e65620d42f14454c465571f34a97ada Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Sun, 5 Sep 2021 10:40:42 +0530 Subject: [PATCH] Check for warnings in err stream too, to make javadoc task work on Java 17+ Discussed in dev list https://mail-archives.apache.org/mod_mbox/ant-dev/202106.mbox/%3c2e2ef67a-7d96-adfc-f050-efaccab7e6c2@apache.org%3e --- WHATSNEW | 3 +++ src/main/org/apache/tools/ant/taskdefs/Javadoc.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 7355945c3..4c825173a 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -27,6 +27,9 @@ Other changes: * Ant tries to avoid file name canonicalization when possible. Bugzilla Report 65499 + * javadoc task will now look for warning messages in the STDERR stream too + when "failonwarning" is set to true to account for changes in JDK 17+ + Changes from Ant 1.10.10 TO Ant 1.10.11 ======================================= diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index acc3a655e..efee9d322 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -1918,7 +1918,7 @@ public class Javadoc extends Task { throw new BuildException("Javadoc returned " + ret, getLocation()); } - if (out.sawWarnings() && failOnWarning) { + if (failOnWarning && (out.sawWarnings() || err.sawWarnings())) { throw new BuildException("Javadoc issued warnings.", getLocation()); } @@ -2623,7 +2623,7 @@ public class Javadoc extends Task { @Override protected void processLine(final String line, final int messageLevel) { - if (line.contains("warning")) { + if (line.matches("(\\d) warning[s]?$")) { sawWarnings = true; } if (messageLevel == Project.MSG_INFO