diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java index d521c2f97..4eb007520 100644 --- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java +++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java @@ -28,7 +28,7 @@ import org.apache.tools.ant.TargetGroup; import org.apache.tools.ant.Task; import org.apache.tools.ant.UnknownElement; import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.resources.URLResource; +import org.apache.tools.ant.types.resources.URLProvider; import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.JAXPUtils; import org.xml.sax.Attributes; @@ -94,16 +94,18 @@ public class ProjectHelper2 extends ProjectHelper { * content as something that can be turned into an Antlib task. * *

simply delegates to {@link #parseUnknownElement - * parseUnknownElement}.

+ * parseUnknownElement} if the resource provides an URL and throws + * an exceptipn otherwise.

* - * @since ant 1.8.0 + * @since Ant 1.8.0 */ public UnknownElement parseAntlibDescriptor(Project containingProject, Resource resource) { - if (!(resource instanceof URLResource)) { + URLProvider up = (URLProvider) resource.as(URLProvider.class); + if (up == null) { throw new BuildException("Unsupported resource type: " + resource); } - return parseUnknownElement(containingProject, ((URLResource)resource).getURL()); + return parseUnknownElement(containingProject, up.getURL()); } /**