Return-Path:
Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org
Received: (qmail 33481 invoked from network); 16 Nov 2009 05:33:10 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3)
by minotaur.apache.org with SMTP; 16 Nov 2009 05:33:10 -0000
Received: (qmail 98511 invoked by uid 500); 16 Nov 2009 05:33:10 -0000
Delivered-To: apmail-ant-notifications-archive@ant.apache.org
Received: (qmail 98465 invoked by uid 500); 16 Nov 2009 05:33:09 -0000
Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@ant.apache.org
Delivered-To: mailing list notifications@ant.apache.org
Received: (qmail 98456 invoked by uid 99); 16 Nov 2009 05:33:09 -0000
Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Nov 2009 05:33:09 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=10.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Nov 2009 05:33:06 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id EE614238899B; Mon, 16 Nov 2009 05:32:44 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r880590 - in /ant/core/trunk: docs/manual/CoreTasks/
docs/manual/CoreTypes/ src/main/org/apache/tools/ant/helper/
src/main/org/apache/tools/ant/types/resources/ src/tests/antunit/taskdefs/
Date: Mon, 16 Nov 2009 05:32:44 -0000
To: notifications@ant.apache.org
From: bodewig@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20091116053244.EE614238899B@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
Author: bodewig
Date: Mon Nov 16 05:32:43 2009
New Revision: 880590
URL: http://svn.apache.org/viewvc?rev=880590&view=rev
Log:
support creating url resources relative to other URLs
Modified:
ant/core/trunk/docs/manual/CoreTasks/import.html
ant/core/trunk/docs/manual/CoreTasks/include.html
ant/core/trunk/docs/manual/CoreTypes/resources.html
ant/core/trunk/src/main/org/apache/tools/ant/helper/AntXMLContext.java
ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/URLResource.java
ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml
Modified: ant/core/trunk/docs/manual/CoreTasks/import.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/import.html?rev=880590&r1=880589&r2=880590&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/import.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/import.html Mon Nov 16 05:32:43 2009
@@ -150,9 +150,9 @@
To create a relative resource you'd use something like:
- <url id="imported.basedir" url="${ant.file.imported}/."/>
<loadproperties>
- <url url="${toString:imported.basedir}/imported.properties"/>
+ <url baseUrl="${ant.file.imported}"
+ relativePath="imported.properties"/>
</loadproperties>
Modified: ant/core/trunk/docs/manual/CoreTasks/include.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/include.html?rev=880590&r1=880589&r2=880590&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/include.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/include.html Mon Nov 16 05:32:43 2009
@@ -153,9 +153,9 @@
To create a relative resource you'd use something like:
- <url id="included.basedir" url="${ant.file.included}/."/>
<loadproperties>
- <url url="${toString:included.basedir}/included.properties"/>
+ <url baseUrl="${ant.file.included}"
+ relativePath="included.properties"/>
</loadproperties>
Modified: ant/core/trunk/docs/manual/CoreTypes/resources.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/resources.html?rev=880590&r1=880589&r2=880590&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTypes/resources.html (original)
+++ ant/core/trunk/docs/manual/CoreTypes/resources.html Mon Nov 16 05:32:43 2009
@@ -254,6 +254,16 @@
file |
The file to expose as a file: url |
+
+ baseUrl |
+ The base URL which must be combined with relativePath |
+
+
+ relativePath |
+ Relative path that defines the url combined with
+ baseUrl |
+ If using baseUrl |
+
Modified: ant/core/trunk/src/main/org/apache/tools/ant/helper/AntXMLContext.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/helper/AntXMLContext.java?rev=880590&r1=880589&r2=880590&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/helper/AntXMLContext.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/helper/AntXMLContext.java Mon Nov 16 05:32:43 2009
@@ -124,12 +124,16 @@
*/
public void setBuildFile(File buildFile) {
this.buildFile = buildFile;
- this.buildFileParent = new File(buildFile.getParent());
- implicitTarget.setLocation(new Location(buildFile.getAbsolutePath()));
- try {
- setBuildFile(FileUtils.getFileUtils().getFileURL(buildFile));
- } catch (MalformedURLException ex) {
- throw new BuildException(ex);
+ if (buildFile != null) {
+ this.buildFileParent = new File(buildFile.getParent());
+ implicitTarget.setLocation(new Location(buildFile.getAbsolutePath()));
+ try {
+ setBuildFile(FileUtils.getFileUtils().getFileURL(buildFile));
+ } catch (MalformedURLException ex) {
+ throw new BuildException(ex);
+ }
+ } else {
+ this.buildFileParent = null;
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java?rev=880590&r1=880589&r2=880590&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java Mon Nov 16 05:32:43 2009
@@ -219,6 +219,7 @@
buildFileName = buildFile.toString();
} else if (url != null) {
try {
+ context.setBuildFile((File) null);
context.setBuildFile(url);
} catch (java.net.MalformedURLException ex) {
throw new BuildException(ex);
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/URLResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/URLResource.java?rev=880590&r1=880589&r2=880590&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/URLResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/URLResource.java Mon Nov 16 05:32:43 2009
@@ -46,6 +46,8 @@
private URL url;
private URLConnection conn;
+ private URL baseURL;
+ private String relPath;
/**
* Default constructor.
@@ -108,6 +110,34 @@
}
/**
+ * Base URL which combined with the relativePath attribute defines
+ * the URL.
+ * @since Ant 1.8.0
+ */
+ public synchronized void setBaseURL(URL base) {
+ checkAttributesAllowed();
+ if (url != null) {
+ throw new BuildException("can't define URL and baseURL attribute");
+ }
+ baseURL = base;
+ }
+
+ /**
+ * Relative path which combined with the baseURL attribute defines
+ * the URL.
+ * @since Ant 1.8.0
+ */
+ public synchronized void setRelativePath(String r) {
+ checkAttributesAllowed();
+ if (url != null) {
+ throw new BuildException("can't define URL and relativePath"
+ + " attribute");
+ }
+ relPath = r;
+ }
+
+
+ /**
* Get the URL used by this URLResource.
* @return a URL object.
*/
@@ -115,6 +145,19 @@
if (isReference()) {
return ((URLResource) getCheckedRef()).getURL();
}
+ if (url == null) {
+ if (baseURL != null) {
+ if (relPath == null) {
+ throw new BuildException("must provide relativePath"
+ + " attribute when using baseURL.");
+ }
+ try {
+ url = new URL(baseURL, relPath);
+ } catch (MalformedURLException e) {
+ throw new BuildException(e);
+ }
+ }
+ }
return url;
}
@@ -124,7 +167,7 @@
*/
public synchronized void setRefid(Reference r) {
//not using the accessor in this case to avoid side effects
- if (url != null) {
+ if (url != null || baseURL != null || relPath != null) {
throw tooManyAttributes();
}
super.setRefid(r);
Modified: ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml?rev=880590&r1=880589&r2=880590&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml Mon Nov 16 05:32:43 2009
@@ -21,16 +21,25 @@
+
]]>
+
In inner
+ ant.file.inner is ${ant.file.inner}
+ type is ${ant.file.type.inner}
+
+
+
+ foo is ${foo}
]]>
+
@@ -45,5 +54,7 @@
+
+