Browse Source

remove java resource support from URL resource in favor of JavaResource.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@351741 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 19 years ago
parent
commit
54be7a626d
4 changed files with 3 additions and 89 deletions
  1. +0
    -14
      docs/manual/CoreTypes/resources.html
  2. +1
    -17
      src/etc/testcases/types/resources/build.xml
  3. +2
    -54
      src/main/org/apache/tools/ant/types/resources/URLResource.java
  4. +0
    -4
      src/testcases/org/apache/tools/ant/types/ResourceCollectionsTest.java

+ 0
- 14
docs/manual/CoreTypes/resources.html View File

@@ -229,21 +229,7 @@ element.</p>
<td valign="top">file</td>
<td valign="top">The file to expose as a file: url</td>
</tr>
<tr>
<td valign="top">javaresource</td>
<td valign="top">The Java resource to expose as a jar: url</td>
</tr>
<tr>
<td valign="top">classpath</td>
<td valign="top">The classpath to use when establishing the URL
for a Java resource</td>
<td align="center" valign="top">No</td>
</tr>
</table>
<p>The classpath along which to search for a Java resource
can also be specified by means of one or more nested
<code><a href="../using.html#path">classpath</a></code> elements.
</p>

<h4><a name="string">string</a></h4>



+ 1
- 17
src/etc/testcases/types/resources/build.xml View File

@@ -346,24 +346,8 @@ depends="testfileset,testdirset,testfilelist,testpath,testzipfileset,testpropert
</fail>
</target>

<target name="testresourceurl" depends="createjar">
<!-- test ref while we're at it -->
<url id="resourceurl"
javaresource="foo/c/z" classpath="${jar}" />
<fail>
<condition>
<resourcecount count="0">
<restrict>
<url refid="resourceurl" />
<rsel:exists />
</restrict>
</resourcecount>
</condition>
</fail>
</target>

<target name="url"
depends="testfileurl,testfileurlref,testhttpurl1,testhttpurl2,testjarurl,testresourceurl" />
depends="testfileurl,testfileurlref,testhttpurl1,testhttpurl2,testjarurl" />

<target name="testfile" depends="init">
<echo file="${file}">This is a test.</echo>


+ 2
- 54
src/main/org/apache/tools/ant/types/resources/URLResource.java View File

@@ -43,9 +43,7 @@ public class URLResource extends Resource {
= Resource.getMagicNumber("null URL".getBytes());

private URL url;
private String javaResource;
private URLConnection conn;
private Path classpath;

/**
* Default constructor.
@@ -99,37 +97,6 @@ public class URLResource extends Resource {
}
}

/**
* Set the resource name with which to expose a Java resource.
* @param s the Java resource name.
* @see java.lang.ClassLoader#getResource(String)
*/
public synchronized void setJavaResource(String s) {
checkAttributesAllowed();
javaResource = s;
}

/**
* Set the classpath for this URLResource.
* @param p the Path against which to resolve Java resources.
*/
public synchronized void setClasspath(Path p) {
checkAttributesAllowed();
addConfiguredClasspath(p);
}

/**
* Create a nested classpath element.
* @return a Path object.
*/
public synchronized void addConfiguredClasspath(Path p) {
checkChildrenAllowed();
if (classpath == null) {
classpath = new Path(getProject());
}
classpath.add(p);
}

/**
* Get the URL used by this URLResource.
* @return a URL object.
@@ -138,25 +105,6 @@ public class URLResource extends Resource {
if (isReference()) {
return ((URLResource) getCheckedRef()).getURL();
}
if (url == null && javaResource != null) {
ClassLoader cl = null;
AntClassLoader acl = null;
if (classpath != null) {
acl = getProject().createClassLoader(classpath);
cl = acl;
} else {
cl = getClass().getClassLoader();
if (cl == null) {
cl = ClassLoader.getSystemClassLoader();
}
}
if (cl != null) {
setURL(cl.getResource(javaResource));
if (acl != null) {
acl.cleanup();
}
}
}
return url;
}

@@ -166,7 +114,7 @@ public class URLResource extends Resource {
*/
public synchronized void setRefid(Reference r) {
//not using the accessor in this case to avoid side effects
if (url != null || javaResource != null) {
if (url != null) {
throw tooManyAttributes();
}
super.setRefid(r);
@@ -370,4 +318,4 @@ public class URLResource extends Resource {
}
}

}
}

+ 0
- 4
src/testcases/org/apache/tools/ant/types/ResourceCollectionsTest.java View File

@@ -117,10 +117,6 @@ public class ResourceCollectionsTest extends BuildFileTest {
executeTarget("testresourcesref");
}

public void testresourceurl() {
executeTarget("testresourceurl");
}

public void teststring1() {
executeTarget("teststring1");
}


Loading…
Cancel
Save