|
23 | 23 | import java.io.File;
|
24 | 24 | import java.io.IOException;
|
25 | 25 | import java.io.InputStream;
|
| 26 | +import java.util.ArrayList; |
26 | 27 | import java.util.Collection;
|
27 | 28 | import java.util.EnumSet;
|
28 | 29 | import java.util.Iterator;
|
29 |
| -import java.util.LinkedHashSet; |
30 | 30 | import java.util.Locale;
|
31 | 31 |
|
32 | 32 | import org.apache.tools.ant.AntClassLoader;
|
@@ -60,10 +60,9 @@ public class AntTask extends Task implements Constants {
|
60 | 60 |
|
61 | 61 | private final Union classFiles = new Union();
|
62 | 62 | private final Union apiSignatures = new Union();
|
63 |
| - private final Collection<BundledSignaturesType> bundledSignatures = new LinkedHashSet<>(); |
64 |
| - private final Collection<SuppressAnnotationType> suppressAnnotations = new LinkedHashSet<>(); |
65 |
| - private final Collection<String> signaturesWithSeverityWarn = new LinkedHashSet<>();; |
66 |
| - private final Collection<String> signaturesWithSeveritySuppress = new LinkedHashSet<>();; |
| 63 | + private final Collection<BundledSignaturesType> bundledSignatures = new ArrayList<>(); |
| 64 | + private final Collection<SuppressAnnotationType> suppressAnnotations = new ArrayList<>(); |
| 65 | + private final Collection<SeverityOverrideType> severityOverrides = new ArrayList<>(); |
67 | 66 |
|
68 | 67 | private Path classpath = null;
|
69 | 68 |
|
@@ -178,11 +177,12 @@ public void debug(String msg) {
|
178 | 177 | checker.parseSignaturesFile(r.getInputStream(), r.toString());
|
179 | 178 | }
|
180 | 179 | }
|
181 |
| - if (!signaturesWithSeverityWarn.isEmpty()) { |
182 |
| - checker.setSignaturesSeverity(signaturesWithSeverityWarn, Checker.ViolationSeverity.WARNING); |
183 |
| - } |
184 |
| - if (!signaturesWithSeveritySuppress.isEmpty()) { |
185 |
| - checker.setSignaturesSeverity(signaturesWithSeveritySuppress, Checker.ViolationSeverity.SUPPRESS); |
| 180 | + |
| 181 | + for (SeverityOverrideType override : severityOverrides) { |
| 182 | + if (override.severity == null) { |
| 183 | + throw new BuildException("Severity must be given as argument of <severityOverride/> element."); |
| 184 | + } |
| 185 | + checker.setSignaturesSeverity(override.getSignatures(), override.severity); |
186 | 186 | }
|
187 | 187 | } catch (IOException ioe) {
|
188 | 188 | throw new BuildException("IO problem while reading files with API signatures: " + ioe.getMessage(), ioe);
|
@@ -302,20 +302,18 @@ public void setBundledSignatures(String name) {
|
302 | 302 | }
|
303 | 303 |
|
304 | 304 | /**
|
305 |
| - * A list of forbidden API signatures for which violations should not be reported at all (i.e. neither fail the build nor appear in the logs). This takes precedence over {@link #failOnViolation} and {@link #signaturesWithSeverityWarn}. |
306 |
| - * In order to be effective the signature must be given in either {@link #bundledSignatures}, {@link #signaturesFiles}, {@link #signaturesArtifacts}, or {@link #signatures}. |
| 305 | + * Adds an override for forbidden API signatures for which violations should not be reported at all (i.e. neither fail the build nor appear in the logs). |
| 306 | + * Each signature must be listed in a separate XML element (in text) and a {@code priority} attribute. |
| 307 | + * This takes precedence over {@link #failOnViolation}. |
| 308 | + * In order to be effective the signature must be given in one of the signatures elements (e.g., it can be used to disable a bundled signature which |
| 309 | + * is not yet ready to be enforced). |
307 | 310 | * @since 3.9
|
308 | 311 | */
|
309 |
| - public void setSignaturesWithSeverityWarn(String signature) { |
310 |
| - signaturesWithSeverityWarn.add(signature); |
311 |
| - } |
312 |
| - |
313 |
| - /** A list of forbidden API signatures for which violations should not be reported at all (i.e. neither fail the build nor appear in the logs). This takes precedence over {@link #failOnViolation} and {@link #signaturesWithSeverityWarn}. |
314 |
| - * In order to be effective the signature must be given in either {@link #bundledSignatures}, {@link #signaturesFiles}, {@link #signaturesArtifacts}, or {@link #signatures}. |
315 |
| - * @since 3.9 |
316 |
| - */ |
317 |
| - public void setSignaturesWithSeveritySuppress(String signature) { |
318 |
| - signaturesWithSeveritySuppress.add(signature); |
| 312 | + public SeverityOverrideType createSeverityOverride() { |
| 313 | + final SeverityOverrideType s = new SeverityOverrideType(); |
| 314 | + s.setProject(getProject()); |
| 315 | + severityOverrides.add(s); |
| 316 | + return s; |
319 | 317 | }
|
320 | 318 |
|
321 | 319 | /** Creates a instance of an annotation class name that suppresses error reporting in classes/methods/fields. */
|
|
0 commit comments