diff --git a/src/main/docs/ant-task.html b/src/main/docs/ant-task.html index 19900147..24950040 100644 --- a/src/main/docs/ant-task.html +++ b/src/main/docs/ant-task.html @@ -165,7 +165,8 @@

Parameters specified as nested elements

diff --git a/src/main/java/de/thetaphi/forbiddenapis/ant/AntTask.java b/src/main/java/de/thetaphi/forbiddenapis/ant/AntTask.java index 97358099..05cbc2c0 100644 --- a/src/main/java/de/thetaphi/forbiddenapis/ant/AntTask.java +++ b/src/main/java/de/thetaphi/forbiddenapis/ant/AntTask.java @@ -34,6 +34,7 @@ import org.apache.tools.ant.types.resources.FileResource; import org.apache.tools.ant.types.resources.Resources; import org.apache.tools.ant.types.resources.StringResource; +import org.apache.tools.ant.types.resources.Union; import de.thetaphi.forbiddenapis.Checker; import de.thetaphi.forbiddenapis.ForbiddenApiException; @@ -42,10 +43,10 @@ import java.io.IOException; import java.io.File; -import java.util.ArrayList; +import java.util.Collection; import java.util.EnumSet; import java.util.Iterator; -import java.util.List; +import java.util.LinkedHashSet; import java.util.Locale; /** @@ -56,10 +57,10 @@ */ public class AntTask extends Task { - private final Resources classFiles = new Resources(); - private final Resources apiSignatures = new Resources(); - private final List bundledSignatures = new ArrayList(); - private final List suppressAnnotations = new ArrayList(); + private final Union classFiles = new Union(); + private final Union apiSignatures = new Union(); + private final Collection bundledSignatures = new LinkedHashSet(); + private final Collection suppressAnnotations = new LinkedHashSet(); private Path classpath = null; private boolean failOnUnsupportedJava = false; @@ -155,7 +156,7 @@ public void info(String msg) { } if (checker.hasNoSignatures()) { - throw new BuildException("No API signatures found; use signaturesFile=, , or inner text to define those!"); + throw new BuildException("No API signatures found; use signaturesFile=, , or inner text to define those!"); } log.info("Loading classes to check..."); @@ -210,8 +211,8 @@ public void setDir(File dir) { classFiles.add(fs); } - private T addSignaturesResource(T res) { - ((ProjectComponent) res).setProject(getProject()); + private T addSignaturesResource(T res) { + res.setProject(getProject()); apiSignatures.add(res); return res; } @@ -236,6 +237,11 @@ public void setSignaturesFile(File file) { createSignaturesFile().setFile(file); } + /** Creates a collection of arbitrary Ant resources */ + public Resources createSignaturesResources() { + return addSignaturesResource(new Resources()); + } + /** Support for API signatures list as nested text */ public void addText(String text) { addSignaturesResource(new StringResource(text)); diff --git a/src/test/antunit/TestFileSignatures.xml b/src/test/antunit/TestFileSignatures.xml index b6a5e907..6e1dcc56 100644 --- a/src/test/antunit/TestFileSignatures.xml +++ b/src/test/antunit/TestFileSignatures.xml @@ -57,4 +57,18 @@ + + + + + + + java.util.Locale#ENGLISH @ We are speaking chinese here! + + + + + + + \ No newline at end of file