Author: bodewig
Date: Mon Dec 8 08:30:32 2008
New Revision: 724397
URL: http://svn.apache.org/viewvc?rev=724397&view=rev
Log:
two propertyhelpers useable for Resource-valued attributes
Added:
ant/core/trunk/src/tests/antunit/propertyhelpers.xml (with props)
Added: ant/core/trunk/src/tests/antunit/propertyhelpers.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/propertyhelpers.xml?rev=724397&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/propertyhelpers.xml (added)
+++ ant/core/trunk/src/tests/antunit/propertyhelpers.xml Mon Dec 8 08:30:32
2008
@@ -0,0 +1,96 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project>
+ <property name="propin" location="${java.io.tmpdir}/propertyhelperinput"/>
+ <property name="propout" location="${java.io.tmpdir}/propertyhelperoutput"/>
+
+ <target name="compileHelpers">
+ <mkdir dir="${propin}/org/apache/ant/propertyhelper"/>
+ <mkdir dir="${propout}/org/apache/ant/propertyhelper"/>
+
+ <echo
file="${propin}/org/apache/ant/propertyhelper/URLHelper.java"><![CDATA[
+package org.apache.ant.propertyhelper;
+
+import org.apache.tools.ant.PropertyHelper;
+import org.apache.tools.ant.types.resources.URLResource;
+
+public class URLHelper implements PropertyHelper.PropertyEvaluator {
+ private String prefix = "url:";
+ public Object evaluate(String property, PropertyHelper propertyHelper) {
+ if (property.startsWith(prefix)) {
+ String s = property.substring(prefix.length());
+ return new URLResource(s);
+ }
+ return null;
+ }
+}
+]]></echo>
+ <echo
file="${propin}/org/apache/ant/propertyhelper/JavaHelper.java"><![CDATA[
+package org.apache.ant.propertyhelper;
+
+import java.io.File;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.PropertyHelper;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.resources.JavaResource;
+
+public class JavaHelper extends ProjectComponent
+ implements PropertyHelper.PropertyEvaluator {
+
+ private String prefix = "java:";
+ public Object evaluate(String property, PropertyHelper propertyHelper) {
+ if (property.startsWith(prefix)) {
+ String s = property.substring(prefix.length());
+ int index = s.indexOf("!");
+
+ Path p = new Path(getProject());
+ p.setPath(s.substring(0, index));
+
+ JavaResource r = new JavaResource(s.substring(index + 1), p);
+ r.setProject(getProject());
+ return r;
+ }
+ return null;
+ }
+}
+]]></echo>
+ <javac srcdir="${propin}" destdir="${propout}"/>
+ </target>
+
+ <target name="defineHelpers" depends="compileHelpers">
+ <typedef name="urlhelper"
+ classname="org.apache.ant.propertyhelper.URLHelper">
+ <classpath location="${propout}"/>
+ </typedef>
+ <urlhelper id="url"/>
+ <typedef name="javahelper"
+ classname="org.apache.ant.propertyhelper.JavaHelper">
+ <classpath location="${propout}"/>
+ </typedef>
+ <javahelper id="java"/>
+ <propertyhelper>
+ <delegate refid="url"/>
+ <delegate refid="java"/>
+ </propertyhelper>
+ </target>
+
+ <target name="tearDown">
+ <delete dir="${propin}"/>
+ <delete dir="${propout}"/>
+ </target>
+</project>
Propchange: ant/core/trunk/src/tests/antunit/propertyhelpers.xml
------------------------------------------------------------------------------
svn:eol-style = native