git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@896785 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,2 +0,0 @@ | |||
| Copy the files in o.a.t.ant, recompile. | |||
| @@ -1,98 +0,0 @@ | |||
| <project name="embed" default="main" basedir="."> | |||
| <description>Embed proposal</description> | |||
| <property file="${user.home}/build.properties" /> | |||
| <property file="user.properties" /> | |||
| <property name="base.path" location="/usr/share/java"/> | |||
| <property name="ant.src" location="../.."/> | |||
| <property name="commons.src" location="${ant.src}/../jakarta-commons"/> | |||
| <property name="sandbox.src" location="${ant.src}/../jakarta-commons-sandbox"/> | |||
| <property name="embed.build" location="build"/> | |||
| <property name="debug" value="true"/> | |||
| <!-- Those 2 should be moved to JXPath and velocity. --> | |||
| <property name="commons-logging.jar" location="${commons.src}/logging/dist/commons-logging.jar" /> | |||
| <property name="jxpath.jar" location="${commons.src}/jxpath/dist/commons-jxpath.jar" /> | |||
| <property name="velocity.jar" location="${base.path}/velocity/velocity-20020220.jar" /> | |||
| <property name="velocity-dep.jar" location="${base.path}/velocity/velocity-dep-20020220.jar" /> | |||
| <property name="jexl.jar" location="${sandbox.src}/jexl/dist/commons-jexl.jar" /> | |||
| <property name="commons-discovery.jar" location="${commons.src}/discovery/dist/commons-discovery.jar" /> | |||
| <target name="init"> | |||
| <mkdir dir="build/classes" /> | |||
| </target> | |||
| <target name="build" depends="main" /> | |||
| <target name="main" depends="init,main-ant15" > | |||
| </target> | |||
| <target name="main-ant15" depends="init" | |||
| description="Build hacks into ant1.5 to support some 1.6 features" > | |||
| <echo>Embed is no longer supported with ant1.6. It is only used with ant1.5 ! The dynamic properties work with both, use embed-optional target</echo> | |||
| <javac srcdir="src/java" | |||
| debug="${debug}" | |||
| destdir="${embed.build}/classes" > | |||
| <include name="**" /> | |||
| <exclude name="org/apache/tools/ant/taskdefs/optional/**" /> | |||
| </javac> | |||
| <copy toDir="${embed.build}/classes"> | |||
| <fileset dir="src/java" includes="META-INF/**" /> | |||
| </copy> | |||
| <jar file="${embed.build}/ant-sax2.jar" basedir="${embed.build}/classes"> | |||
| <include name="**" /> | |||
| </jar> | |||
| </target> | |||
| <target name="embed-optional" depends="init" > | |||
| <javac srcdir="src/java" | |||
| debug="${debug}" | |||
| destdir="${embed.build}/classes" > | |||
| <include name="org/apache/tools/ant/taskdefs/optional/**" /> | |||
| <include name="org/apache/tools/ant/taskdefs/XMLDOM**" /> | |||
| <classpath> | |||
| <!-- all this will move to their package --> | |||
| <pathelement location="build/classes" /> | |||
| <pathelement location="${jxpath.jar}" /> | |||
| <pathelement location="${velocity.jar}" /> | |||
| <pathelement location="${jexl.jar}" /> | |||
| <pathelement location="${commons-discovery.jar}" /> | |||
| <pathelement location="${commons-logging.jar}" /> | |||
| </classpath> | |||
| </javac> | |||
| <copy toDir="${embed.build}/classes"> | |||
| <fileset dir="src/java" includes="META-INF/**" /> | |||
| </copy> | |||
| <jar file="${embed.build}/optional-dynprop.jar" basedir="${embed.build}/classes"> | |||
| <include name="org/apache/tools/ant/taskdefs/optional/**" /> | |||
| <include name="org/apache/tools/ant/taskdefs/XMLDOM**" /> | |||
| </jar> | |||
| </target> | |||
| <target name="gump" description="Patch gump bootstrap ant" depends="main" > | |||
| </target> | |||
| <target name="install" description="Installs built jars"> | |||
| <echo message="Copy ${embed.build}/ant-sax2.jar toDir=${ant.home}/lib"/> | |||
| <mkdir dir="${ant.home}/lib" /> | |||
| <copy file="${embed.build}/ant-sax2.jar" toDir="${ant.home}/lib"/> | |||
| </target> | |||
| <target name="install-embed" depends="main, install" | |||
| description="Builds and installs embed without optional"/> | |||
| <target name="install-embed-optional" depends="embed-optional, install" | |||
| description="Installs extra built jars" > | |||
| <copy file="${embed.build}/optional-dynprop.jar" toDir="${ant.home}/lib"/> | |||
| </target> | |||
| </project> | |||
| @@ -1 +0,0 @@ | |||
| org.apache.tools.ant.helper.ProjectHelperImpl2 | |||
| @@ -1,116 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant; | |||
| import java.io.File; | |||
| import java.io.InputStream; | |||
| import java.io.IOException; | |||
| import java.util.Hashtable; | |||
| import java.util.Vector; | |||
| import java.util.Properties; | |||
| import java.util.Enumeration; | |||
| import java.util.Stack; | |||
| import java.lang.reflect.Modifier; | |||
| import org.apache.tools.ant.types.FilterSet; | |||
| import org.apache.tools.ant.types.FilterSetCollection; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| // XXX It would be a good idea to merge all 'hooks' into one AntInterceptor | |||
| // mechanism. That would make it much easier to read and extend. | |||
| /** | |||
| * Abstract component creation and configuration. | |||
| * | |||
| * TODO: Multiple ComponentHelpers can be registered in a project, either by an | |||
| * embedding application or by taskdef-like tasks. | |||
| * | |||
| * After a ProjectComponentHelper is registered, it'll manage the construction and | |||
| * configuration of tasks/types/etc. It has full control over how the | |||
| * component is created - and may provide runtime wrapping for components | |||
| * not implementing the Task/DataType interfaces. | |||
| * It works in close relation with TaskAdapter and RuntimeConfigurable | |||
| * to handle delayed evaluation of tasks or custom attribute->task mapping. | |||
| * If it returns a wrapper for Task, the wrapper is required to extend | |||
| * TaskAdapter. | |||
| * | |||
| * The common 'Chain' pattern is used to construct | |||
| * tasks, with the original behavior ( Class registry ) tried last, by the | |||
| * default helper implementation. | |||
| * | |||
| * Note that 'delayed' construction of tasks is used. | |||
| * | |||
| */ | |||
| public interface ProjectComponentFactory { | |||
| /** Creates an ant component.. | |||
| * | |||
| * A factory may have knowledge about the tasks it creates. It can return | |||
| * an object extending TaskAdapter that emulates Task/DataType. If null is returned, | |||
| * the next helper is tried. | |||
| * | |||
| * @param project the context for task creation. | |||
| * @param role Class name for the expected role ( Task, Type, Filter, etc ). Null for 'any' | |||
| * @param ns namespace if a SAX2 parser is used, null for 'classical' ant | |||
| * @param taskName the (local) name of the task. | |||
| */ | |||
| public Object createProjectComponent( Project project, | |||
| String ns, | |||
| String taskName ) | |||
| throws BuildException; | |||
| // XXX class loader ? Can use the ns, but additional hints may be available in taskdef | |||
| // | |||
| } | |||
| @@ -1,138 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant; | |||
| import java.io.File; | |||
| import java.io.InputStream; | |||
| import java.io.IOException; | |||
| import java.util.Hashtable; | |||
| import java.util.Vector; | |||
| import java.util.Properties; | |||
| import java.util.Enumeration; | |||
| import java.util.Stack; | |||
| import java.lang.reflect.Modifier; | |||
| import org.apache.tools.ant.types.FilterSet; | |||
| import org.apache.tools.ant.types.FilterSetCollection; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Component creation and configuration. | |||
| * | |||
| * After a ProjectComponentFactory is registered, it'll manage the construction and | |||
| * configuration of tasks/types/etc. It has full control over how the | |||
| * component is created - and may provide runtime wrapping for components | |||
| * not implementing the Task/DataType interfaces. | |||
| * It works in close relation with TaskAdapter and RuntimeConfigurable | |||
| * to handle delayed evaluation of tasks or custom attribute->task mapping. | |||
| * If it returns a wrapper for Task, the wrapper is required to extend | |||
| * TaskAdapter. | |||
| * | |||
| * The common 'Chain' pattern is used to construct | |||
| * tasks, with the original behavior ( Class registry ) tried last, by the | |||
| * default helper implementation. | |||
| * | |||
| * Note that 'delayed' construction of tasks is used. | |||
| * | |||
| */ | |||
| public class ProjectComponentHelper { | |||
| static private ProjectComponentHelper singleton=new ProjectComponentHelper(); | |||
| Vector factories=new Vector(); | |||
| /** | |||
| */ | |||
| public static ProjectComponentHelper getProjectComponentHelper() { | |||
| // Singleton for now, it may change ( per/classloader ) | |||
| return singleton; | |||
| } | |||
| public void addComponentFactory( ProjectComponentFactory fact ) { | |||
| factories.addElement( fact ); | |||
| } | |||
| public Object createProjectComponent( UnknownElement ue, Project project, | |||
| String ns, | |||
| String taskName ) | |||
| throws BuildException | |||
| { | |||
| Object component=null; | |||
| for( int i=0; i< factories.size(); i++ ) { | |||
| ProjectComponentFactory fact=(ProjectComponentFactory)factories.elementAt(i); | |||
| component=fact.createProjectComponent( project, ns, taskName ); | |||
| if( component!=null ) return component; | |||
| } | |||
| // System.out.println("Fallback to project default " + taskName ); | |||
| // Can't create component. Default is to use the old methods in project. | |||
| // This policy is taken from 1.5 ProjectHelper. In future the difference between | |||
| // task and type should disapear. | |||
| if( project.getDataTypeDefinitions().get(taskName) != null ) { | |||
| // This is the original policy in ProjectHelper. The 1.5 version of UnkwnonwElement | |||
| // used to try first to create a task, and if it failed tried a type. In 1.6 the diff | |||
| // should disapear. | |||
| component = project.createDataType(taskName); | |||
| if( component!=null ) return component; | |||
| } | |||
| // from UnkwnonwElement.createTask. The 'top level' case is removed, we're | |||
| // allways lazy | |||
| component = project.createTask(taskName); | |||
| return component; | |||
| } | |||
| } | |||
| @@ -1,627 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant; | |||
| import org.apache.tools.ant.helper.*; | |||
| import java.util.*; | |||
| import org.xml.sax.AttributeList; | |||
| import org.xml.sax.Attributes; | |||
| import org.xml.sax.helpers.AttributeListImpl; | |||
| import org.xml.sax.helpers.AttributesImpl; | |||
| /* ISSUES: | |||
| - ns param. It could be used to provide "namespaces" for properties, which | |||
| may be more flexible. | |||
| - Object value. In ant1.5 String is used for Properties - but it would be nice | |||
| to support generic Objects ( the property remains imutable - you can't change | |||
| the associated object ). This will also allow JSP-EL style setting using the | |||
| Object if an attribute contains only the property ( name="${property}" could | |||
| avoid Object->String->Object conversion ) | |||
| - Currently we "chain" only for get and set property ( probably most users | |||
| will only need that - if they need more they can replace the top helper ). | |||
| Need to discuss this and find if we need more. | |||
| */ | |||
| /** NOT FINAL. API MAY CHANGE | |||
| * | |||
| * Deals with properties - substitution, dynamic properties, etc. | |||
| * | |||
| * This is the same code as in Ant1.5. The main addition is the ability | |||
| * to chain multiple PropertyHelpers and to replace the default. | |||
| * | |||
| * @since Ant 1.6 | |||
| */ | |||
| public class PropertyHelper { | |||
| protected Project project; | |||
| protected PropertyHelper next; | |||
| /** Project properties map (usually String to String). */ | |||
| protected Hashtable properties = new Hashtable(); | |||
| /** | |||
| * Map of "user" properties (as created in the Ant task, for example). | |||
| * Note that these key/value pairs are also always put into the | |||
| * project properties, so only the project properties need to be queried. | |||
| * Mapping is String to String. | |||
| */ | |||
| protected Hashtable userProperties = new Hashtable(); | |||
| /** | |||
| * Map of inherited "user" properties - that are those "user" | |||
| * properties that have been created by tasks and not been set | |||
| * from the command line or a GUI tool. | |||
| * Mapping is String to String. | |||
| */ | |||
| protected Hashtable inheritedProperties = new Hashtable(); | |||
| protected PropertyHelper() { | |||
| } | |||
| // -------------------- Hook management -------------------- | |||
| public void setProject(Project p ) { | |||
| this.project=p; | |||
| } | |||
| /** There are 2 ways to hook into property handling: | |||
| * - you can replace the main PropertyHelper. The replacement is required | |||
| * to support the same semantics ( of course :-) | |||
| * | |||
| * - you can chain a property helper capable of storing some properties. | |||
| * Again, you are required to respect the immutability semantics ( at | |||
| * least for non-dynamic properties ) | |||
| * | |||
| * @param next | |||
| */ | |||
| public void setNext( PropertyHelper next ) { | |||
| this.next=next; | |||
| } | |||
| public PropertyHelper getNext() { | |||
| return next; | |||
| } | |||
| /** Factory method to create a property processor. | |||
| * Users can provide their own or replace it using "ant.PropertyHelper" | |||
| * reference. User tasks can also add themself to the chain, and provide | |||
| * dynamic properties. | |||
| */ | |||
| public static PropertyHelper getPropertyHelper(Project project) { | |||
| PropertyHelper ph=(PropertyHelper)project.getReference( "ant.PropertyHelper" ); | |||
| if( ph!=null ) return ph; | |||
| ph=new PropertyHelper(); | |||
| ph.setProject( project ); | |||
| project.addReference( "ant.PropertyHelper",ph ); | |||
| return ph; | |||
| } | |||
| // -------------------- Methods to override -------------------- | |||
| /** | |||
| * Sets a property. Any existing property of the same name | |||
| * is overwritten, unless it is a user property. Will be called | |||
| * from setProperty(). | |||
| * | |||
| * If all helpers return false, the property will be saved in | |||
| * the default properties table by setProperty. | |||
| * | |||
| * @param name The name of property to set. | |||
| * Must not be <code>null</code>. | |||
| * @param value The new value of the property. | |||
| * Must not be <code>null</code>. | |||
| * @return true if this helper has stored the property, false if it | |||
| * couldn't. Each helper should delegate to the next one ( unless it | |||
| * has a good reason not to ). | |||
| */ | |||
| public boolean setPropertyHook(String ns, String name, | |||
| Object value, | |||
| boolean inherited, boolean user, | |||
| boolean isNew) | |||
| { | |||
| if( getNext()!=null ) { | |||
| boolean subst=getNext().setPropertyHook(ns, name, value, | |||
| inherited, user, isNew); | |||
| // If next has handled the property | |||
| if( subst ) { | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| /** Get a property. If all hooks return null, the default | |||
| * tables will be used. | |||
| * | |||
| * @param ns | |||
| * @param name | |||
| * @return | |||
| */ | |||
| public Object getPropertyHook(String ns, String name, boolean user) { | |||
| if( getNext() != null ) { | |||
| Object o=getNext().getPropertyHook(ns, name, user); | |||
| if( o!= null ) return o; | |||
| } | |||
| // Experimental/Testing, will be removed | |||
| if( name.startsWith( "toString:" )) { | |||
| name=name.substring( "toString:".length()); | |||
| Object v=project.getReference( name ); | |||
| if( v==null ) return null; | |||
| return v.toString(); | |||
| } | |||
| return null; | |||
| } | |||
| // -------------------- Optional methods -------------------- | |||
| // You can override those methods if you want to optimize or | |||
| // do advanced things ( like support a special syntax ). | |||
| // The methods do not chain - you should use them when embedding ant | |||
| // ( by replacing the main helper ) | |||
| /** | |||
| * Parses a string containing <code>${xxx}</code> style property | |||
| * references into two lists. The first list is a collection | |||
| * of text fragments, while the other is a set of string property names. | |||
| * <code>null</code> entries in the first list indicate a property | |||
| * reference from the second list. | |||
| * | |||
| * It can be overriden with a more efficient or customized version. | |||
| * | |||
| * @param value Text to parse. Must not be <code>null</code>. | |||
| * @param fragments List to add text fragments to. | |||
| * Must not be <code>null</code>. | |||
| * @param propertyRefs List to add property names to. | |||
| * Must not be <code>null</code>. | |||
| * | |||
| * @exception BuildException if the string contains an opening | |||
| * <code>${</code> without a closing | |||
| * <code>}</code> | |||
| */ | |||
| public void parsePropertyString(String value, Vector fragments, | |||
| Vector propertyRefs) | |||
| throws BuildException | |||
| { | |||
| parsePropertyStringDefault(value, fragments, propertyRefs); | |||
| } | |||
| /** | |||
| * Replaces <code>${xxx}</code> style constructions in the given value | |||
| * with the string value of the corresponding data types. | |||
| * | |||
| * @param value The string to be scanned for property references. | |||
| * May be <code>null</code>, in which case this | |||
| * method returns immediately with no effect. | |||
| * @param keys Mapping (String to String) of property names to their | |||
| * values. If <code>null</code>, only project properties will | |||
| * be used. | |||
| * | |||
| * @exception BuildException if the string contains an opening | |||
| * <code>${</code> without a closing | |||
| * <code>}</code> | |||
| * @return the original string with the properties replaced, or | |||
| * <code>null</code> if the original string is <code>null</code>. | |||
| */ | |||
| public String replaceProperties(String ns, String value, | |||
| Hashtable keys) | |||
| throws BuildException | |||
| { | |||
| if (value == null) { | |||
| return null; | |||
| } | |||
| Vector fragments = new Vector(); | |||
| Vector propertyRefs = new Vector(); | |||
| parsePropertyString(value, fragments, propertyRefs); | |||
| StringBuffer sb = new StringBuffer(); | |||
| Enumeration i = fragments.elements(); | |||
| Enumeration j = propertyRefs.elements(); | |||
| while (i.hasMoreElements()) { | |||
| String fragment = (String) i.nextElement(); | |||
| if (fragment == null) { | |||
| String propertyName = (String) j.nextElement(); | |||
| Object replacement=null; | |||
| // try to get it from the project or keys | |||
| // Backward compatibility | |||
| if( keys!=null ) { | |||
| replacement=keys.get(propertyName); | |||
| } | |||
| if( replacement==null ) { | |||
| replacement=getProperty(ns, propertyName); | |||
| } | |||
| if (replacement == null ) { | |||
| project.log("Property ${" + propertyName | |||
| + "} has not been set", Project.MSG_VERBOSE); | |||
| } | |||
| fragment = (replacement!=null) | |||
| ? replacement.toString() | |||
| : "${" + propertyName + "}"; | |||
| } | |||
| sb.append(fragment); | |||
| } | |||
| return sb.toString(); | |||
| } | |||
| // -------------------- Default implementation -------------------- | |||
| // Methods used to support the default behavior and provide backward | |||
| // compatibility. Some will be deprecated, you should avoid calling them. | |||
| /** Default implementation of setProperty. Will be called from Project. | |||
| * This is the original 1.5 implementation, with calls to the hook | |||
| * added. | |||
| */ | |||
| public synchronized boolean setProperty(String ns, String name, | |||
| Object value, boolean verbose) | |||
| { | |||
| // user ( CLI ) properties take precedence | |||
| if (null != userProperties.get(name)) { | |||
| if( verbose ) { | |||
| project.log("Override ignored for user property " + name, | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| return false; | |||
| } | |||
| boolean done=this.setPropertyHook(ns, name, value, false, false, false); | |||
| if( done ) { | |||
| return true; | |||
| } | |||
| if (null != properties.get(name) && verbose) { | |||
| project.log("Overriding previous definition of property " + name, | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| if( verbose ) { | |||
| project.log("Setting project property: " + name + " -> " + | |||
| value, Project.MSG_DEBUG); | |||
| } | |||
| properties.put(name, value); | |||
| return true; | |||
| } | |||
| /** | |||
| * Sets a property if no value currently exists. If the property | |||
| * exists already, a message is logged and the method returns with | |||
| * no other effect. | |||
| * | |||
| * @param name The name of property to set. | |||
| * Must not be <code>null</code>. | |||
| * @param value The new value of the property. | |||
| * Must not be <code>null</code>. | |||
| * @since Ant 1.6 | |||
| */ | |||
| public synchronized void setNewProperty(String ns, String name, | |||
| Object value) | |||
| { | |||
| if (null != properties.get(name)) { | |||
| project.log("Override ignored for property " + name, | |||
| Project.MSG_VERBOSE); | |||
| return; | |||
| } | |||
| boolean done=this.setPropertyHook(ns, name, value, false, true, false); | |||
| if( done ) { | |||
| return; | |||
| } | |||
| project.log("Setting project property: " + name + " -> " + | |||
| value, Project.MSG_DEBUG); | |||
| properties.put(name, value); | |||
| } | |||
| /** | |||
| * Sets a user property, which cannot be overwritten by | |||
| * set/unset property calls. Any previous value is overwritten. | |||
| * @param name The name of property to set. | |||
| * Must not be <code>null</code>. | |||
| * @param value The new value of the property. | |||
| * Must not be <code>null</code>. | |||
| */ | |||
| public synchronized void setUserProperty(String ns, String name, | |||
| Object value) | |||
| { | |||
| project.log("Setting ro project property: " + name + " -> " + | |||
| value, Project.MSG_DEBUG); | |||
| userProperties.put(name, value); | |||
| boolean done=this.setPropertyHook(ns, name, value, false, false, true); | |||
| if( done ) { | |||
| return; | |||
| } | |||
| properties.put(name, value); | |||
| } | |||
| /** | |||
| * Sets a user property, which cannot be overwritten by set/unset | |||
| * property calls. Any previous value is overwritten. Also marks | |||
| * these properties as properties that have not come from the | |||
| * command line. | |||
| * | |||
| * @param name The name of property to set. | |||
| * Must not be <code>null</code>. | |||
| * @param value The new value of the property. | |||
| * Must not be <code>null</code>. | |||
| */ | |||
| public synchronized void setInheritedProperty(String ns, String name, | |||
| Object value) | |||
| { | |||
| inheritedProperties.put(name, value); | |||
| project.log("Setting ro project property: " + name + " -> " + | |||
| value, Project.MSG_DEBUG); | |||
| userProperties.put(name, value); | |||
| boolean done=this.setPropertyHook(ns, name, value, true, false, false); | |||
| if( done ) { | |||
| return; | |||
| } | |||
| properties.put(name, value); | |||
| } | |||
| // -------------------- Getting properties -------------------- | |||
| /** | |||
| * Returns the value of a property, if it is set. You can override | |||
| * this method in order to plug your own storage. | |||
| * | |||
| * @param name The name of the property. | |||
| * May be <code>null</code>, in which case | |||
| * the return value is also <code>null</code>. | |||
| * @return the property value, or <code>null</code> for no match | |||
| * or if a <code>null</code> name is provided. | |||
| */ | |||
| public Object getProperty(String ns, String name) { | |||
| if (name == null) { | |||
| return null; | |||
| } | |||
| Object o=getPropertyHook(ns, name, false); | |||
| if( o!= null ) { | |||
| return o; | |||
| } | |||
| return properties.get(name); | |||
| } | |||
| /** | |||
| * Returns the value of a user property, if it is set. | |||
| * | |||
| * @param name The name of the property. | |||
| * May be <code>null</code>, in which case | |||
| * the return value is also <code>null</code>. | |||
| * @return the property value, or <code>null</code> for no match | |||
| * or if a <code>null</code> name is provided. | |||
| */ | |||
| public Object getUserProperty(String ns, String name) { | |||
| if (name == null) { | |||
| return null; | |||
| } | |||
| Object o=getPropertyHook(ns, name, true); | |||
| if( o!= null ) { | |||
| return o; | |||
| } | |||
| return userProperties.get(name); | |||
| } | |||
| // -------------------- Access to property tables -------------------- | |||
| // This is used to support ant call and similar tasks. It should be | |||
| // deprecated, it is possible to use a better ( more efficient ) | |||
| // mechanism to preserve the context. | |||
| // TODO: do we need to delegate ? | |||
| /** | |||
| * Returns a copy of the properties table. | |||
| * @return a hashtable containing all properties | |||
| * (including user properties). | |||
| */ | |||
| public Hashtable getProperties() { | |||
| Hashtable propertiesCopy = new Hashtable(); | |||
| Enumeration e = properties.keys(); | |||
| while (e.hasMoreElements()) { | |||
| Object name = e.nextElement(); | |||
| Object value = properties.get(name); | |||
| propertiesCopy.put(name, value); | |||
| } | |||
| // There is a better way to save the context. This shouldn't | |||
| // delegate to next, it's for backward compat only. | |||
| return propertiesCopy; | |||
| } | |||
| /** | |||
| * Returns a copy of the user property hashtable | |||
| * @return a hashtable containing just the user properties | |||
| */ | |||
| public Hashtable getUserProperties() { | |||
| Hashtable propertiesCopy = new Hashtable(); | |||
| Enumeration e = userProperties.keys(); | |||
| while (e.hasMoreElements()) { | |||
| Object name = e.nextElement(); | |||
| Object value = properties.get(name); | |||
| propertiesCopy.put(name, value); | |||
| } | |||
| return propertiesCopy; | |||
| } | |||
| /** | |||
| * Copies all user properties that have not been set on the | |||
| * command line or a GUI tool from this instance to the Project | |||
| * instance given as the argument. | |||
| * | |||
| * <p>To copy all "user" properties, you will also have to call | |||
| * {@link #copyUserProperties copyUserProperties}.</p> | |||
| * | |||
| * @param other the project to copy the properties to. Must not be null. | |||
| * | |||
| * @since Ant 1.6 | |||
| */ | |||
| public void copyInheritedProperties(Project other) { | |||
| Enumeration e = inheritedProperties.keys(); | |||
| while (e.hasMoreElements()) { | |||
| String arg = e.nextElement().toString(); | |||
| if (other.getUserProperty(arg) != null) { | |||
| continue; | |||
| } | |||
| Object value = inheritedProperties.get(arg); | |||
| other.setInheritedProperty(arg, value.toString()); | |||
| } | |||
| } | |||
| /** | |||
| * Copies all user properties that have been set on the command | |||
| * line or a GUI tool from this instance to the Project instance | |||
| * given as the argument. | |||
| * | |||
| * <p>To copy all "user" properties, you will also have to call | |||
| * {@link #copyInheritedProperties copyInheritedProperties}.</p> | |||
| * | |||
| * @param other the project to copy the properties to. Must not be null. | |||
| * | |||
| * @since Ant 1.6 | |||
| */ | |||
| public void copyUserProperties(Project other) { | |||
| Enumeration e = userProperties.keys(); | |||
| while (e.hasMoreElements()) { | |||
| Object arg = e.nextElement(); | |||
| if (inheritedProperties.containsKey(arg)) { | |||
| continue; | |||
| } | |||
| Object value = userProperties.get(arg); | |||
| other.setUserProperty(arg.toString(), value.toString()); | |||
| } | |||
| } | |||
| // -------------------- Property parsing -------------------- | |||
| // Moved from ProjectHelper. You can override the static method - | |||
| // this is used for backward compatibility ( for code that calls | |||
| // the parse method in ProjectHelper ). | |||
| /** Default parsing method. It is here only to support backward compat | |||
| * for the static ProjectHelper.parsePropertyString(). | |||
| */ | |||
| static void parsePropertyStringDefault(String value, Vector fragments, | |||
| Vector propertyRefs) | |||
| throws BuildException | |||
| { | |||
| int prev = 0; | |||
| int pos; | |||
| //search for the next instance of $ from the 'prev' position | |||
| while ((pos = value.indexOf("$", prev)) >= 0) { | |||
| //if there was any text before this, add it as a fragment | |||
| //TODO, this check could be modified to go if pos>prev; | |||
| //seems like this current version could stick empty strings | |||
| //into the list | |||
| if (pos > 0) { | |||
| fragments.addElement(value.substring(prev, pos)); | |||
| } | |||
| //if we are at the end of the string, we tack on a $ | |||
| //then move past it | |||
| if (pos == (value.length() - 1)) { | |||
| fragments.addElement("$"); | |||
| prev = pos + 1; | |||
| } else if (value.charAt(pos + 1) != '{') { | |||
| //peek ahead to see if the next char is a property or not | |||
| //not a property: insert the char as a literal | |||
| /* | |||
| fragments.addElement(value.substring(pos + 1, pos + 2)); | |||
| prev = pos + 2; | |||
| */ | |||
| if (value.charAt(pos + 1) == '$') { | |||
| //backwards compatibility two $ map to one mode | |||
| fragments.addElement("$"); | |||
| prev = pos + 2; | |||
| } else { | |||
| //new behaviour: $X maps to $X for all values of X!='$' | |||
| fragments.addElement(value.substring(pos, pos + 2)); | |||
| prev = pos + 2; | |||
| } | |||
| } else { | |||
| //property found, extract its name or bail on a typo | |||
| int endName = value.indexOf('}', pos); | |||
| if (endName < 0) { | |||
| throw new BuildException("Syntax error in property: " | |||
| + value); | |||
| } | |||
| String propertyName = value.substring(pos + 2, endName); | |||
| fragments.addElement(null); | |||
| propertyRefs.addElement(propertyName); | |||
| prev = endName + 1; | |||
| } | |||
| } | |||
| //no more $ signs found | |||
| //if there is any tail to the file, append it | |||
| if (prev < value.length()) { | |||
| fragments.addElement(value.substring(prev)); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,348 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant; | |||
| import org.apache.tools.ant.helper.*; | |||
| import java.util.Enumeration; | |||
| import java.util.Locale; | |||
| import java.util.Vector; | |||
| import java.util.Hashtable; | |||
| import org.xml.sax.AttributeList; | |||
| import org.xml.sax.Attributes; | |||
| import org.xml.sax.helpers.AttributeListImpl; | |||
| import org.xml.sax.helpers.AttributesImpl; | |||
| /** | |||
| * Wrapper class that holds the attributes of an element, its children, and | |||
| * any text within it. It then takes care of configuring that element at | |||
| * runtime. | |||
| * | |||
| * This uses SAX2 and a more flexible substitution mechansim, based on | |||
| * o.a.tomcat.util.IntrospectionUtil. | |||
| * | |||
| */ | |||
| public class RuntimeConfigurable2 extends RuntimeConfigurable { | |||
| /** Name of the element to configure. elementName in UE */ | |||
| private String elementTag = null; | |||
| /** List of child element wrappers. */ | |||
| private Vector children = new Vector(); | |||
| /** The element to configure. realThing in UE */ | |||
| private Object wrappedObject = null; | |||
| /** XML attributes for the element. */ | |||
| private Attributes attributes; | |||
| /** Text appearing within the element. */ | |||
| private StringBuffer characters = new StringBuffer(); | |||
| /** Indicates if the wrapped object has been configured */ | |||
| private boolean proxyConfigured = false; | |||
| Project project; | |||
| protected Location location = Location.UNKNOWN_LOCATION; | |||
| /** | |||
| * Sole constructor creating a wrapper for the specified object. | |||
| * | |||
| * @param proxy The element to configure. Must not be <code>null</code>. | |||
| * @param elementTag The tag name generating this element. | |||
| * Should not be <code>null</code>. | |||
| */ | |||
| public RuntimeConfigurable2(Project project, Location location, Object proxy, String elementTag) { | |||
| super( proxy, elementTag ); | |||
| wrappedObject = proxy; | |||
| this.elementTag = elementTag; | |||
| // This should never happen - all objects are lazy | |||
| if( proxy instanceof Task ) | |||
| ((Task)proxy).setRuntimeConfigurableWrapper( this ); | |||
| proxyConfigured=false; | |||
| } | |||
| Project getProject() { | |||
| return project; | |||
| } | |||
| Location getLocation() { | |||
| return location; | |||
| } | |||
| /** | |||
| * Sets the element to configure. This is used when the real type of | |||
| * an element isn't known at the time of wrapper creation. | |||
| * | |||
| * @param proxy The element to configure. Must not be <code>null</code>. | |||
| */ | |||
| public void setProxy(Object proxy) { | |||
| wrappedObject = proxy; | |||
| proxyConfigured=false; | |||
| } | |||
| public Object getProxy() { | |||
| return wrappedObject; | |||
| } | |||
| /** | |||
| * Sets the attributes for the wrapped element. | |||
| * | |||
| * @param attributes List of attributes defined in the XML for this | |||
| * element. May be <code>null</code>. | |||
| * @deprecated It shouldn't be called by anyone except ProjectHelper | |||
| */ | |||
| public void setAttributes(AttributeList attributes) { | |||
| // this.attributes = new AttributeListImpl(attributes); | |||
| } | |||
| public void setAttributes2(Attributes attributes) { | |||
| this.attributes=new AttributesImpl( attributes ); | |||
| } | |||
| /** | |||
| * Returns the list of attributes for the wrapped element. | |||
| * | |||
| * @return An AttributeList representing the attributes defined in the | |||
| * XML for this element. May be <code>null</code>. | |||
| * @deprecated only for bkwd compatibility | |||
| */ | |||
| public AttributeList getAttributes() { | |||
| return sax1Attributes( attributes ); | |||
| } | |||
| public Attributes getAttributes2() { | |||
| return attributes; | |||
| } | |||
| public static AttributeList sax1Attributes( Attributes sax2Att ) { | |||
| AttributeListImpl sax1Att=new AttributeListImpl(); | |||
| int length = sax2Att.getLength(); | |||
| if (length > 0) { | |||
| for (int i = 0; i < length; i++) { | |||
| // System.out.println("Attributes: " + sax2Att.getQName(i) + " " + | |||
| // sax2Att.getValue(i)); | |||
| sax1Att.addAttribute( sax2Att.getQName(i), | |||
| sax2Att.getType(i), | |||
| sax2Att.getValue(i)); | |||
| } | |||
| } | |||
| return sax1Att; | |||
| } | |||
| /** | |||
| * Adds a child element to the wrapped element. | |||
| * | |||
| * @param child The child element wrapper to add to this one. | |||
| * Must not be <code>null</code>. | |||
| */ | |||
| public void addChild(RuntimeConfigurable child) { | |||
| // addChild( UnknownElement ) in UE | |||
| children.addElement(child); | |||
| } | |||
| /** | |||
| * Returns the child wrapper at the specified position within the list. | |||
| * | |||
| * @param index The index of the child to return. | |||
| * | |||
| * @return The child wrapper at position <code>index</code> within the | |||
| * list. | |||
| */ | |||
| public RuntimeConfigurable getChild(int index) { | |||
| return (RuntimeConfigurable) children.elementAt(index); | |||
| } | |||
| /** | |||
| * Adds characters from #PCDATA areas to the wrapped element. | |||
| * | |||
| * @param data Text to add to the wrapped element. | |||
| * Should not be <code>null</code>. | |||
| */ | |||
| public void addText(String data) { | |||
| characters.append(data); | |||
| } | |||
| /** | |||
| * Adds characters from #PCDATA areas to the wrapped element. | |||
| * | |||
| * @param buf A character array of the text within the element. | |||
| * Must not be <code>null</code>. | |||
| * @param start The start element in the array. | |||
| * @param count The number of characters to read from the array. | |||
| * | |||
| */ | |||
| public void addText(char[] buf, int start, int count) { | |||
| addText(new String(buf, start, count)); | |||
| } | |||
| /** | |||
| * Returns the tag name of the wrapped element. | |||
| * | |||
| * @return The tag name of the wrapped element. This is unlikely | |||
| * to be <code>null</code>, but may be. | |||
| */ | |||
| public String getElementTag() { | |||
| // getTag in UE | |||
| return elementTag; | |||
| } | |||
| /** | |||
| * Configures the wrapped element and all its children. | |||
| * The attributes and text for the wrapped element are configured, | |||
| * and then each child is configured and added. Each time the | |||
| * wrapper is configured, the attributes and text for it are | |||
| * reset. | |||
| * | |||
| * If the element has an <code>id</code> attribute, a reference | |||
| * is added to the project as well. | |||
| * | |||
| * @param p The project containing the wrapped element. | |||
| * Must not be <code>null</code>. | |||
| * | |||
| * @exception BuildException if the configuration fails, for instance due | |||
| * to invalid attributes or children, or text being added to | |||
| * an element which doesn't accept it. | |||
| */ | |||
| public void maybeConfigure(Project p) throws BuildException { | |||
| maybeConfigure(p, true); | |||
| } | |||
| /** | |||
| * Configures the wrapped element. The attributes and text for | |||
| * the wrapped element are configured. Each time the wrapper is | |||
| * configured, the attributes and text for it are reset. | |||
| * | |||
| * If the element has an <code>id</code> attribute, a reference | |||
| * is added to the project as well. | |||
| * | |||
| * @param p The project containing the wrapped element. | |||
| * Must not be <code>null</code>. | |||
| * | |||
| * @param configureChildren Whether to configure child elements as | |||
| * well. if true, child elements will be configured after the | |||
| * wrapped element. | |||
| * | |||
| * @exception BuildException if the configuration fails, for instance due | |||
| * to invalid attributes or children, or text being added to | |||
| * an element which doesn't accept it. | |||
| */ | |||
| public void maybeConfigure(Project p, boolean configureChildren) | |||
| throws BuildException { | |||
| String id = null; | |||
| if( proxyConfigured ) { | |||
| return; | |||
| } | |||
| PropertyHelper ph=PropertyHelper.getPropertyHelper(p); | |||
| Object target=(wrappedObject instanceof TaskAdapter) ? | |||
| ((TaskAdapter)wrappedObject).getProxy() : wrappedObject; | |||
| if (attributes != null) { | |||
| IntrospectionHelper ih = | |||
| IntrospectionHelper.getHelper(target.getClass()); | |||
| p.addBuildListener( ih ); | |||
| for (int i = 0; i < attributes.getLength(); i++) { | |||
| String name= attributes.getQName(i); | |||
| String value= attributes.getValue(i); | |||
| // reflect these into the target | |||
| value = ph.replaceProperties(null, value, p.getProperties()); | |||
| try { | |||
| ih.setAttribute(p, target, | |||
| name.toLowerCase(Locale.US), value); | |||
| } catch (BuildException be) { | |||
| // id attribute must be set externally | |||
| if (!name.equals("id")) { | |||
| throw be; | |||
| } | |||
| } | |||
| } | |||
| id = attributes.getValue("id"); | |||
| // No way - this will be used on future calls ( if the task is used | |||
| // multiple times: attributes = null; | |||
| } | |||
| if (characters.length() != 0) { | |||
| ProjectHelper.addText(p, wrappedObject, characters.toString()); | |||
| } | |||
| Enumeration enum = children.elements(); | |||
| while (enum.hasMoreElements()) { | |||
| RuntimeConfigurable2 child | |||
| = (RuntimeConfigurable2) enum.nextElement(); | |||
| if (child.wrappedObject instanceof Task) { | |||
| Task childTask = (Task) child.wrappedObject; | |||
| childTask.setRuntimeConfigurableWrapper(child); | |||
| } | |||
| if (configureChildren) { | |||
| if (child.wrappedObject instanceof Task) { | |||
| Task childTask = (Task) child.wrappedObject; | |||
| childTask.maybeConfigure(); | |||
| } else { | |||
| child.maybeConfigure(p); | |||
| } | |||
| ProjectHelper.storeChild(p, wrappedObject, child.wrappedObject, | |||
| child.getElementTag() | |||
| .toLowerCase(Locale.US)); | |||
| } | |||
| } | |||
| if (id != null) { | |||
| // p.addReference(id, wrappedObject); | |||
| p.getReferences().put( id, wrappedObject ); | |||
| //System.out.println("XXX updating reference " + this + " " + id + " " + wrappedObject ); | |||
| } | |||
| proxyConfigured = true; | |||
| } | |||
| } | |||
| @@ -1,332 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant; | |||
| import org.apache.tools.ant.*; | |||
| import java.util.Vector; | |||
| // XXX Use this as a replacement for the adapter ! | |||
| /** | |||
| * Wrapper class that holds all the information necessary to create a task | |||
| * or data type. | |||
| * | |||
| * With PH2, all components will be wrapped. Long term we should consolidate | |||
| * UnkndownElement and RuntimeConfigurable. | |||
| * | |||
| * | |||
| * @deprecated All tasks will be lazily created and configured before execution. | |||
| * The xml reader will create a tree of RuntimeConfigurable, and tasks will | |||
| * be constructed ( and reconstructed for loops ) just before execution. The | |||
| * UnknonwnElement construct is no longer needed. | |||
| */ | |||
| public class UnknownElement2 extends UnknownElement { | |||
| /** | |||
| * Holds the name of the task/type or nested child element of a | |||
| * task/type that hasn't been defined at parser time or has | |||
| * been redefined since original creation. | |||
| */ | |||
| private String elementName; | |||
| /** | |||
| * The real object after it has been loaded. | |||
| */ | |||
| private Object realThing; | |||
| /** | |||
| * List of child elements (UnknownElements). | |||
| */ | |||
| private Vector children = new Vector(); | |||
| /** | |||
| * Creates an UnknownElement for the given element name. | |||
| * | |||
| * @param elementName The name of the unknown element. | |||
| * Must not be <code>null</code>. | |||
| */ | |||
| public UnknownElement2(String elementName) { | |||
| super( elementName ); | |||
| this.elementName = elementName; | |||
| } | |||
| /** | |||
| * Returns the name of the XML element which generated this unknown | |||
| * element. | |||
| * | |||
| * @return the name of the XML element which generated this unknown | |||
| * element. | |||
| */ | |||
| public String getTag() { | |||
| return elementName; | |||
| } | |||
| public RuntimeConfigurable getWrapper() { | |||
| return wrapper; | |||
| } | |||
| protected RuntimeConfigurable2 getWrapper2() { | |||
| return (RuntimeConfigurable2)wrapper; | |||
| } | |||
| /** | |||
| * Creates the real object instance and child elements, then configures | |||
| * the attributes and text of the real object. This unknown element | |||
| * is then replaced with the real object in the containing target's list | |||
| * of children. | |||
| * | |||
| * @exception BuildException if the configuration fails | |||
| */ | |||
| public void maybeConfigure() throws BuildException { | |||
| ProjectComponentHelper helper=ProjectComponentHelper.getProjectComponentHelper(); | |||
| // Used to be: makeObject(this, getWrapper2()); | |||
| realThing = helper.createProjectComponent( this, getProject(), null, | |||
| this.getTag()); | |||
| if (realThing == null) { | |||
| throw getNotFoundException("task or type", this.getTag()); | |||
| } | |||
| getWrapper2().setProxy(realThing); | |||
| if (realThing instanceof Task) { | |||
| Task task=(Task)realThing; | |||
| task.setLocation(this.getLocation()); | |||
| // UnknownElement always has an associated target | |||
| task.setOwningTarget(this.getOwningTarget()); | |||
| task.init(); | |||
| task.setRuntimeConfigurableWrapper(getWrapper2()); | |||
| // For Script to work. Ugly | |||
| // The reference is replaced by RuntimeConfigurable | |||
| this.getOwningTarget().replaceChild(this, (Task)realThing); | |||
| } | |||
| handleChildren(realThing, getWrapper2()); | |||
| getWrapper2().maybeConfigure(getProject()); | |||
| } | |||
| /** | |||
| * Handles output sent to System.out by this task or its real task. | |||
| * | |||
| * @param line The line of output to log. Should not be <code>null</code>. | |||
| */ | |||
| protected void handleOutput(String line) { | |||
| if (realThing instanceof Task) { | |||
| ((Task) realThing).handleOutput(line); | |||
| } else { | |||
| super.handleOutput(line); | |||
| } | |||
| } | |||
| /** | |||
| * Handles error output sent to System.err by this task or its real task. | |||
| * | |||
| * @param line The error line to log. Should not be <code>null</code>. | |||
| */ | |||
| protected void handleErrorOutput(String line) { | |||
| if (realThing instanceof Task) { | |||
| ((Task) realThing).handleErrorOutput(line); | |||
| } else { | |||
| super.handleErrorOutput(line); | |||
| } | |||
| } | |||
| /** | |||
| * Executes the real object if it's a task. If it's not a task | |||
| * (e.g. a data type) then this method does nothing. | |||
| */ | |||
| public void execute() { | |||
| if (realThing == null) { | |||
| // plain impossible to get here, maybeConfigure should | |||
| // have thrown an exception. | |||
| throw new BuildException("Could not create task of type: " | |||
| + elementName, getLocation()); | |||
| } | |||
| if (realThing instanceof Task) { | |||
| ((Task) realThing).execute(); | |||
| } | |||
| // the task will not be reused ( a new init() will be called ) | |||
| // Let GC do its job | |||
| realThing=null; | |||
| } | |||
| /** | |||
| * Adds a child element to this element. | |||
| * | |||
| * @param child The child element to add. Must not be <code>null</code>. | |||
| */ | |||
| public void addChild(UnknownElement child) { | |||
| children.addElement(child); | |||
| } | |||
| /** | |||
| * Creates child elements, creates children of the children | |||
| * (recursively), and sets attributes of the child elements. | |||
| * | |||
| * @param parent The configured object for the parent. | |||
| * Must not be <code>null</code>. | |||
| * | |||
| * @param parentWrapper The wrapper containing child wrappers | |||
| * to be configured. Must not be <code>null</code> | |||
| * if there are any children. | |||
| * | |||
| * @exception BuildException if the children cannot be configured. | |||
| */ | |||
| protected void handleChildren(Object parent, | |||
| RuntimeConfigurable parentWrapper) | |||
| throws BuildException { | |||
| if (parent instanceof TaskAdapter) { | |||
| parent = ((TaskAdapter) parent).getProxy(); | |||
| } | |||
| Class parentClass = parent.getClass(); | |||
| IntrospectionHelper ih = IntrospectionHelper.getHelper(parentClass); | |||
| for (int i = 0; i < children.size(); i++) { | |||
| RuntimeConfigurable childWrapper = parentWrapper.getChild(i); | |||
| UnknownElement child = (UnknownElement) children.elementAt(i); | |||
| Object realChild = null; | |||
| if (parent instanceof TaskContainer) { | |||
| ProjectComponentHelper helper=ProjectComponentHelper.getProjectComponentHelper(); | |||
| // Used to be: makeTask(child, childWrapper, false); | |||
| realChild = helper.createProjectComponent( child, getProject(), null, | |||
| child.getTag()); | |||
| if (realChild == null ) { | |||
| throw getNotFoundException("task", child.getTag()); | |||
| } | |||
| // XXX DataTypes will be wrapped or treated like normal components | |||
| if( realChild instanceof Task ) { | |||
| ((TaskContainer) parent).addTask((Task) realChild); | |||
| Task task=(Task)realChild; | |||
| task.setLocation(child.getLocation()); | |||
| // UnknownElement always has an associated target | |||
| task.setOwningTarget(this.getOwningTarget()); | |||
| task.init(); | |||
| } else { | |||
| // What ? Add data type ? createElement ? | |||
| } | |||
| } else { | |||
| // Introspection-based task creation | |||
| realChild = ih.createElement(getProject(), parent, child.getTag()); | |||
| } | |||
| childWrapper.setProxy(realChild); | |||
| if (parent instanceof TaskContainer) { | |||
| ((Task) realChild).setRuntimeConfigurableWrapper(childWrapper); | |||
| } | |||
| child.handleChildren(realChild, childWrapper); | |||
| if (parent instanceof TaskContainer) { | |||
| ((Task) realChild).maybeConfigure(); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * @deprecated no longer used | |||
| */ | |||
| protected Object makeObject(UnknownElement ue, RuntimeConfigurable w) { | |||
| /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();} | |||
| return null; | |||
| } | |||
| /** | |||
| * @deprecated no longer used | |||
| */ | |||
| protected Task makeTask(UnknownElement ue, RuntimeConfigurable w, | |||
| boolean onTopLevel) { | |||
| /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();} | |||
| return null; | |||
| } | |||
| /** | |||
| * Returns the name to use in logging messages. | |||
| * | |||
| * @return the name to use in logging messages. | |||
| */ | |||
| public String getTaskName() { | |||
| return elementName; // cleaner, works for everything | |||
| // return realThing == null || !(realThing instanceof Task) ? | |||
| // super.getTaskName() : ((Task) realThing).getTaskName(); | |||
| } | |||
| public Object getWrapped() { | |||
| return realThing; | |||
| } | |||
| /** | |||
| * returns the task instance after it has been created and if it is a task. | |||
| * | |||
| * @return a task instance or <code>null</code> if the real object is not | |||
| * a task. | |||
| */ | |||
| public Task getTask() { | |||
| if (realThing instanceof Task) { | |||
| return (Task) realThing; | |||
| } | |||
| return null; | |||
| } | |||
| }// UnknownElement | |||
| @@ -1,196 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.helper; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.tools.ant.*; | |||
| /** | |||
| * Uses introspection to "adapt" an arbitrary Bean which doesn't | |||
| * itself extend Task, but still contains an execute method and optionally | |||
| * a setProject method. | |||
| * | |||
| * The adapter can also be used to wrap tasks that are loaded in a different class loader | |||
| * by ant, when used in programatic mode. | |||
| * | |||
| */ | |||
| public class TaskAdapter2 extends Task { // implements DynamicConfigurator { | |||
| /* Need to support DynamicConfigurator so that adapted tasks can | |||
| support that too. | |||
| */ | |||
| /** Object to act as a proxy for. */ | |||
| private Object proxy; | |||
| private String methodName="execute"; | |||
| private IntrospectionHelper ih; | |||
| void setIntrospectionHelper( IntrospectionHelper ih ) { | |||
| this.ih=ih; | |||
| } | |||
| IntrospectionHelper getIntrospectionHelper() | |||
| { | |||
| if( ih==null ) { | |||
| ih = IntrospectionHelper.getHelper(target.getClass()); | |||
| } | |||
| return ih; | |||
| } | |||
| public void setDynamicAttribute(String name, String value) | |||
| throws BuildException | |||
| { | |||
| setAttribute( name, value ); | |||
| } | |||
| public Object createDynamicElement(String name) throws BuildException | |||
| { | |||
| return null; | |||
| } | |||
| /** Experimental, non-public method for better 'adaptation' | |||
| * | |||
| */ | |||
| void setAttribute( String name, String value ) | |||
| throws BuildException | |||
| { | |||
| try { | |||
| ih.setAttribute( project, proxy, name, value ); | |||
| } catch( BuildException ex ) { | |||
| if( "do".equals( name ) ) { | |||
| setDo( value ); | |||
| } else { | |||
| throw ex; | |||
| } | |||
| } | |||
| } | |||
| /** Set the 'action' method. This allow beans implementing multiple | |||
| * actions or using methods other than 'execute()' to be used in ant | |||
| * without any modification. | |||
| * | |||
| * @ant:experimental | |||
| */ | |||
| public void setDo(String methodName ) { | |||
| this.methodName=methodName; | |||
| } | |||
| /** | |||
| * Executes the proxied task. | |||
| */ | |||
| public void execute() throws BuildException { | |||
| Method setProjectM = null; | |||
| try { | |||
| Class c = proxy.getClass(); | |||
| setProjectM = | |||
| c.getMethod( "setProject", new Class[] {Project.class}); | |||
| if(setProjectM != null) { | |||
| setProjectM.invoke(proxy, new Object[] {project}); | |||
| } | |||
| } catch (NoSuchMethodException e) { | |||
| // ignore this if the class being used as a task does not have | |||
| // a set project method. | |||
| } catch( Exception ex ) { | |||
| log("Error setting project in " + proxy.getClass(), | |||
| Project.MSG_ERR); | |||
| throw new BuildException( ex ); | |||
| } | |||
| Method executeM=null; | |||
| try { | |||
| Class c=proxy.getClass(); | |||
| executeM=c.getMethod( methodName, new Class[0] ); | |||
| if( executeM == null ) { | |||
| log("No public " + methodName + "() in " + proxy.getClass(), Project.MSG_ERR); | |||
| throw new BuildException("No public " + methodName +"() in " + proxy.getClass()); | |||
| } | |||
| executeM.invoke(proxy, null); | |||
| return; | |||
| } catch (java.lang.reflect.InvocationTargetException ie) { | |||
| log("Error in " + proxy.getClass(), Project.MSG_ERR); | |||
| Throwable t = ie.getTargetException(); | |||
| if (t instanceof BuildException) { | |||
| throw ((BuildException) t); | |||
| } else { | |||
| throw new BuildException(t); | |||
| } | |||
| } catch( Exception ex ) { | |||
| log("Error in " + proxy.getClass(), Project.MSG_ERR); | |||
| throw new BuildException( ex ); | |||
| } | |||
| } | |||
| /** | |||
| * Sets the target object to proxy for. | |||
| * | |||
| * @param o The target object. Must not be <code>null</code>. | |||
| */ | |||
| public void setProxy(Object o) { | |||
| this.proxy = o; | |||
| } | |||
| /** | |||
| * Returns the target object being proxied. | |||
| * | |||
| * @return the target proxy object | |||
| */ | |||
| public Object getProxy() { | |||
| return this.proxy ; | |||
| } | |||
| } | |||
| @@ -1,90 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.types.*; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| /** | |||
| * Description task. If top level tasks are executed during processing, import | |||
| * and description can be regular tasks, with no need for special code in processor. | |||
| * | |||
| * ( this only works for top-level descr. AFAIK that's how it works in ant1.5 ) | |||
| * If this would be extended for <description> elements in targets - a special | |||
| * construct would be needed to mark this as 'parsing time' task. | |||
| * | |||
| */ | |||
| public class Description extends Task { | |||
| String descr; | |||
| public Description() { | |||
| } | |||
| public String getDescription() { | |||
| return descr; | |||
| } | |||
| public void addText( String text ) { | |||
| this.descr=text; | |||
| } | |||
| public void execute() throws BuildException { | |||
| project.setDescription( descr ); | |||
| } | |||
| } | |||
| @@ -1,179 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.helper.*; | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.FileNotFoundException; | |||
| import java.io.IOException; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.util.Hashtable; | |||
| import java.util.Vector; | |||
| import java.util.Enumeration; | |||
| import java.util.Locale; | |||
| import java.util.Stack; | |||
| import org.xml.sax.Locator; | |||
| import org.xml.sax.InputSource; | |||
| import org.xml.sax.SAXParseException; | |||
| import org.xml.sax.XMLReader; | |||
| import org.xml.sax.SAXException; | |||
| import org.xml.sax.DocumentHandler; | |||
| import org.xml.sax.Attributes; | |||
| import org.xml.sax.AttributeList; | |||
| import org.xml.sax.helpers.XMLReaderAdapter; | |||
| import org.xml.sax.helpers.DefaultHandler; | |||
| import org.xml.sax.helpers.AttributeListImpl; | |||
| import org.apache.tools.ant.util.JAXPUtils; | |||
| /** | |||
| * Import task. | |||
| * | |||
| * It must be 'top level'. On execution it'll read another file | |||
| * into the same Project. | |||
| * | |||
| */ | |||
| public class Import extends Task { | |||
| String file; | |||
| public void setFile( String file ) { | |||
| // I don't think we can use File - different rules | |||
| // for relative paths. | |||
| this.file=file; | |||
| } | |||
| /** | |||
| * Initialisation routine called after handler creation | |||
| * with the element name and attributes. The attributes which | |||
| * this handler can deal with are: <code>"default"</code>, | |||
| * <code>"name"</code>, <code>"id"</code> and <code>"basedir"</code>. | |||
| * | |||
| * @param tag Name of the element which caused this handler | |||
| * to be created. Should not be <code>null</code>. | |||
| * Ignored in this implementation. | |||
| * @param attrs Attributes of the element which caused this | |||
| * handler to be created. Must not be <code>null</code>. | |||
| * | |||
| * @exception SAXParseException if an unexpected attribute is | |||
| * encountered or if the <code>"default"</code> attribute | |||
| * is missing. | |||
| */ | |||
| public void execute() throws BuildException | |||
| { | |||
| if (file == null) { | |||
| throw new BuildException("import element appears without a file attribute"); | |||
| } | |||
| ProjectHelperImpl2.AntXmlContext context; | |||
| context=(ProjectHelperImpl2.AntXmlContext)project.getReference("ant.parsing.context"); | |||
| context.importlevel++; | |||
| project.log("importlevel: "+(context.importlevel-1)+" -> "+(context.importlevel), | |||
| Project.MSG_DEBUG); | |||
| project.log("Importing file "+file+" from "+ | |||
| context.buildFile.getAbsolutePath(), | |||
| Project.MSG_VERBOSE); | |||
| // Paths are relative to the build file they're imported from, | |||
| // *not* the current directory (same as entity includes). | |||
| File importedFile = new File(file); | |||
| if (!importedFile.isAbsolute()) { | |||
| importedFile = new File(context.buildFileParent, file); | |||
| } | |||
| if (!importedFile.exists()) { | |||
| throw new BuildException("Cannot find "+file+" imported from "+ | |||
| context.buildFile.getAbsolutePath()); | |||
| } | |||
| // Add parent build file to the map to avoid cycles... | |||
| String parentFilename = getPath(context.buildFile); | |||
| if (!context.importedFiles.containsKey(parentFilename)) { | |||
| context.importedFiles.put(parentFilename, context.buildFile); | |||
| } | |||
| // Make sure we import the file only once | |||
| String importedFilename = getPath(importedFile); | |||
| if (context.importedFiles.containsKey(importedFilename)) { | |||
| project.log("\nSkipped already imported file:\n "+importedFilename+"\n", | |||
| Project.MSG_WARN); | |||
| context.importlevel--; | |||
| project.log("importlevel: "+context.importlevel+" <- "+ | |||
| (context.importlevel+1) ,Project.MSG_DEBUG); | |||
| return; | |||
| } else { | |||
| context.importedFiles.put(importedFilename, importedFile); | |||
| } | |||
| context.ignoreProjectTag=true; | |||
| context.helper.parse(project, importedFile, new ProjectHelperImpl2.RootHandler(context)); | |||
| context.importlevel--; | |||
| project.log("importlevel: "+context.importlevel+" <- "+ | |||
| (context.importlevel+1) ,Project.MSG_DEBUG); | |||
| } | |||
| private static String getPath(File file) { | |||
| try { | |||
| return file.getCanonicalPath(); | |||
| } | |||
| catch (IOException e) { | |||
| return file.getAbsolutePath(); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,227 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.types.*; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| import org.xml.sax.Locator; | |||
| import org.xml.sax.InputSource; | |||
| //import org.xml.sax.HandlerBase; | |||
| import org.xml.sax.SAXParseException; | |||
| import org.xml.sax.XMLReader; | |||
| import org.xml.sax.SAXException; | |||
| import org.xml.sax.DocumentHandler; | |||
| import org.xml.sax.Attributes; | |||
| import org.xml.sax.AttributeList; | |||
| import org.xml.sax.helpers.XMLReaderAdapter; | |||
| import org.xml.sax.helpers.DefaultHandler; | |||
| import org.xml.sax.helpers.AttributeListImpl; | |||
| import javax.xml.parsers.SAXParserFactory; | |||
| import javax.xml.parsers.SAXParser; | |||
| import javax.xml.parsers.ParserConfigurationException; | |||
| /** | |||
| * Specify a system path, to be used to load optional.jar and all | |||
| * related libraries. | |||
| * | |||
| * Using the specified path it'll try to load or reload all optional | |||
| * tasks. The typical use is: | |||
| * <pre> | |||
| * <path id="ant.deps" > | |||
| * <fileset ... /> | |||
| * </path> | |||
| * | |||
| * <systemPath pathRef="ant.deps" /> | |||
| * | |||
| * <junit ... /> | |||
| * </pre> | |||
| * | |||
| * This requires that ant-sax2.jar is included in ant/lib. | |||
| * | |||
| * It has a single property, a reference to a <path> containing all | |||
| * the jars that you need. It'll automatically reload optional.jar | |||
| * tasks in a different (non-delegating) loader. | |||
| * | |||
| */ | |||
| public class SystemPath extends Task { | |||
| public static final String SYSTEM_LOADER_REF="ant.system.loader"; | |||
| public SystemPath() { | |||
| } | |||
| public void setPathRef( Reference pathRef ) throws BuildException { | |||
| setClasspathRef( pathRef ); | |||
| } | |||
| /** Specify which path will be used. | |||
| */ | |||
| public void setClasspathRef( Reference pathRef ) throws BuildException { | |||
| Path path=(Path)pathRef.getReferencedObject(project); | |||
| initSystemLoader(path); | |||
| } | |||
| /** Will prepare the class loader to allow dynamic modifications | |||
| * of the classpath. Optional tasks are loaded in a different loader. | |||
| */ | |||
| private void initSystemLoader(Path path) { | |||
| try { | |||
| //if( project.getReference( SYSTEM_LOADER_REF ) != null ) | |||
| // return; // already done that. | |||
| // reverse loader | |||
| AntClassLoader acl=(AntClassLoader)project.getReference(SYSTEM_LOADER_REF); | |||
| if( acl==null ) { | |||
| acl=new AntClassLoader( this.getClass().getClassLoader(), true ); | |||
| acl.addLoaderPackageRoot( "org.apache.tools.ant.taskdefs.optional"); | |||
| project.addReference( SYSTEM_LOADER_REF, acl ); | |||
| } | |||
| String list[]=path.list(); | |||
| for( int i=0; i<list.length; i++ ) { | |||
| File f= new File( list[i] ); | |||
| if( f.exists() ) { | |||
| acl.addPathElement(f.getAbsolutePath()); | |||
| log("Adding to class loader " + acl + " " + f.getAbsolutePath(), | |||
| Project.MSG_DEBUG); | |||
| } | |||
| } | |||
| // XXX find the classpath - add the optional jars. | |||
| String antHome=project.getProperty( "ant.home" ); | |||
| File optionalJar=new File( antHome + "/lib/optional.jar" ); | |||
| if( optionalJar.exists() ) | |||
| acl.addPathElement(optionalJar.getAbsolutePath() ); | |||
| // reinit the loader for optional, if they were in /lib/ | |||
| Hashtable tasks=project.getTaskDefinitions(); | |||
| //System.out.println("Replacing jars" ); | |||
| // reload all optional tasks in this loader. | |||
| // Some tasks weren't defined by the normal init(), since deps were missing. | |||
| String defs = "/org/apache/tools/ant/taskdefs/defaults.properties"; | |||
| try { | |||
| Properties props = new Properties(); | |||
| InputStream in = this.getClass().getResourceAsStream(defs); | |||
| if (in == null) { | |||
| throw new BuildException("Can't load default task list"); | |||
| } | |||
| props.load(in); | |||
| in.close(); | |||
| Enumeration enum = tasks.keys(); | |||
| while( enum.hasMoreElements()) { | |||
| String key = (String) enum.nextElement(); | |||
| Class c=(Class)tasks.get(key); | |||
| if( ! c.getName().startsWith( "org.apache.tools.ant.taskdefs.optional" )) | |||
| continue; | |||
| // other classes that needs to be replaced ?? | |||
| try { | |||
| Class taskClass = acl.loadClass(c.getName()); | |||
| //project.addTaskDefinition(key, taskClass); | |||
| project.getTaskDefinitions().put(key, taskClass); | |||
| //System.out.println("Loaded " + key + " " + taskClass.getClassLoader() ); | |||
| } catch (NoClassDefFoundError ncdfe) { | |||
| log("Could not load a dependent class (" | |||
| + ncdfe.getMessage() + ") for task " + key, Project.MSG_DEBUG); | |||
| } catch (ClassNotFoundException cnfe) { | |||
| log("Could not load class (" + c.getName() | |||
| + ") for task " + key, Project.MSG_DEBUG); | |||
| } catch (Exception ex) { | |||
| ex.printStackTrace(); | |||
| } | |||
| } | |||
| // Some tasks couldn't be defined on the first run | |||
| enum = props.propertyNames(); | |||
| while (enum.hasMoreElements()) { | |||
| String key = (String) enum.nextElement(); | |||
| String value = props.getProperty(key); | |||
| if( ! value.startsWith( "org.apache.tools.ant.taskdefs.optional" )) | |||
| continue; | |||
| if( tasks.get( key ) != null ) | |||
| continue; | |||
| // other classes that needs to be replaced ?? | |||
| try { | |||
| Class taskClass = acl.loadClass(value); | |||
| //project.addTaskDefinition(key, taskClass); | |||
| project.getTaskDefinitions().put(key, taskClass); | |||
| //System.out.println("Loaded " + key + " " + taskClass.getClassLoader() ); | |||
| } catch (NoClassDefFoundError ncdfe) { | |||
| log("Could not load a dependent class (" | |||
| + ncdfe.getMessage() + ") for task " + key, Project.MSG_DEBUG); | |||
| } catch (ClassNotFoundException cnfe) { | |||
| log("Could not load class (" + value | |||
| + ") for task " + key, Project.MSG_DEBUG); | |||
| } catch (Exception ex) { | |||
| ex.printStackTrace(); | |||
| } | |||
| } | |||
| } catch (IOException ioe) { | |||
| throw new BuildException("Can't load default task list"); | |||
| } | |||
| } catch( Exception ex ) { | |||
| ex.printStackTrace(); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,347 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.types.*; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| // XXX Had to cut&paste the code in Definer - since most fields are private | |||
| // and no accessor is available. | |||
| /** | |||
| * Special version of taskdef using the configurable ant class loader. | |||
| * It will also have additional features ( META-INF/ant.properties ,etc ). | |||
| * | |||
| * | |||
| * @since Ant 1.6 | |||
| * @ant.task category="internal" | |||
| */ | |||
| public class Taskdef2 extends Definer { | |||
| private String name; | |||
| private String value; | |||
| private Path classpath; | |||
| private File file; | |||
| private String resource; | |||
| private boolean reverseLoader = false; | |||
| private String loaderId = null; | |||
| private String classpathId = null; | |||
| private static final String REUSE_LOADER_REF = "ant.reuse.loader"; | |||
| /** | |||
| * @deprecated stop using this attribute | |||
| * @ant.attribute ignore="true" | |||
| */ | |||
| public void setReverseLoader(boolean reverseLoader) { | |||
| this.reverseLoader = reverseLoader; | |||
| log("The reverseloader attribute is DEPRECATED. It will be removed", | |||
| Project.MSG_WARN); | |||
| } | |||
| /** | |||
| * Set the classpath to be used when searching for component being defined | |||
| * | |||
| * @param classpath an Ant Path object containing the classpath. | |||
| */ | |||
| public void setClasspath(Path classpath) { | |||
| if (this.classpath == null) { | |||
| this.classpath = classpath; | |||
| } else { | |||
| this.classpath.append(classpath); | |||
| } | |||
| } | |||
| /** | |||
| * Create the classpath to be used when searching for component being defined | |||
| */ | |||
| public Path createClasspath() { | |||
| if (this.classpath == null) { | |||
| this.classpath = new Path(getProject()); | |||
| } | |||
| return this.classpath.createPath(); | |||
| } | |||
| /** | |||
| * reference to a classpath to use when loading the files. | |||
| * To actually share the same loader, set loaderref as well | |||
| */ | |||
| public void setClasspathRef(Reference r) { | |||
| classpathId=r.getRefId(); | |||
| createClasspath().setRefid(r); | |||
| } | |||
| /** | |||
| * Use the reference to locate the loader. If the loader is not | |||
| * found, taskdef will use the specified classpath and register it | |||
| * with the specified name. | |||
| * | |||
| * This allow multiple taskdef/typedef to use the same class loader, | |||
| * so they can be used together. It eliminate the need to | |||
| * put them in the CLASSPATH. | |||
| * | |||
| * @since Ant 1.5 | |||
| */ | |||
| public void setLoaderRef(Reference r) { | |||
| loaderId = r.getRefId(); | |||
| } | |||
| public void execute() throws BuildException { | |||
| AntClassLoader al = createLoader(); | |||
| if (file == null && resource == null) { | |||
| // simple case - one definition | |||
| if (name == null || value == null) { | |||
| String msg = "name or classname attributes of " | |||
| + getTaskName() + " element " | |||
| + "are undefined"; | |||
| throw new BuildException(msg); | |||
| } | |||
| addDefinition(al, name, value); | |||
| } else { | |||
| InputStream is = null; | |||
| try { | |||
| if (name != null || value != null) { | |||
| String msg = "You must not specify name or value " | |||
| + "together with file or resource."; | |||
| throw new BuildException(msg, getLocation()); | |||
| } | |||
| if (file != null && resource != null) { | |||
| String msg = "You must not specify both, file and " | |||
| + "resource."; | |||
| throw new BuildException(msg, getLocation()); | |||
| } | |||
| Properties props = new Properties(); | |||
| if (file != null) { | |||
| log("Loading definitions from file " + file, | |||
| Project.MSG_VERBOSE); | |||
| is = new FileInputStream(file); | |||
| if (is == null) { | |||
| log("Could not load definitions from file " + file | |||
| + ". It doesn\'t exist.", Project.MSG_WARN); | |||
| } | |||
| } | |||
| if (resource != null) { | |||
| log("Loading definitions from resource " + resource, | |||
| Project.MSG_VERBOSE); | |||
| is = al.getResourceAsStream(resource); | |||
| if (is == null) { | |||
| log("Could not load definitions from resource " | |||
| + resource + ". It could not be found.", | |||
| Project.MSG_WARN); | |||
| } | |||
| } | |||
| if (is != null) { | |||
| props.load(is); | |||
| Enumeration keys = props.keys(); | |||
| while (keys.hasMoreElements()) { | |||
| String n = (String) keys.nextElement(); | |||
| String v = props.getProperty(n); | |||
| addDefinition(al, n, v); | |||
| } | |||
| } | |||
| } catch (IOException ex) { | |||
| throw new BuildException(ex, getLocation()); | |||
| } finally { | |||
| if (is != null) { | |||
| try { | |||
| is.close(); | |||
| } catch (IOException e) {} | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * create the classloader then hand the definition off to the subclass; | |||
| * @throws BuildException when the class wont load for any reason | |||
| */ | |||
| protected void addDefinition(ClassLoader al, String name, String value) | |||
| throws BuildException { | |||
| try { | |||
| Class c = al.loadClass(value); | |||
| AntClassLoader.initializeClass(c); | |||
| addDefinition(name, c); | |||
| } catch (ClassNotFoundException cnfe) { | |||
| String msg = getTaskName() + " class " + value | |||
| + " cannot be found"; | |||
| throw new BuildException(msg, cnfe, getLocation()); | |||
| } catch (NoClassDefFoundError ncdfe) { | |||
| String msg = getTaskName() + " class " + value | |||
| + " cannot be found"; | |||
| throw new BuildException(msg, ncdfe, getLocation()); | |||
| } | |||
| } | |||
| /** | |||
| * create a classloader for this definition | |||
| */ | |||
| protected AntClassLoader createLoader() { | |||
| // magic property | |||
| if (getProject().getProperty(REUSE_LOADER_REF) != null) { | |||
| // Generate the 'reuse' name automatically from the reference. | |||
| // This allows <taskdefs> that work on both ant1.4 and ant1.5. | |||
| // ( in 1.4 it'll require the task/type to be in classpath if they | |||
| // are used togheter ). | |||
| if (loaderId == null && classpathId != null) { | |||
| loaderId = "ant.loader." + classpathId; | |||
| } | |||
| } | |||
| // If a loader has been set ( either by loaderRef or magic property ) | |||
| if (loaderId != null) { | |||
| Object reusedLoader = getProject().getReference(loaderId); | |||
| if (reusedLoader != null) { | |||
| if (reusedLoader instanceof AntClassLoader) { | |||
| return (AntClassLoader)reusedLoader; | |||
| } | |||
| // In future the reference object may be the <loader> type | |||
| // if( reusedLoader instanceof Loader ) { | |||
| // return ((Loader)reusedLoader).getLoader(project); | |||
| // } | |||
| } | |||
| } | |||
| AntClassLoader al = (AntClassLoader)project.getReference( "ant.system.loader" ); | |||
| if( al==null ) { | |||
| if (classpath != null) { | |||
| al = new AntClassLoader(getProject(), classpath, !reverseLoader); | |||
| } else { | |||
| al = new AntClassLoader(getProject(), Path.systemClasspath, | |||
| !reverseLoader); | |||
| } | |||
| } else { | |||
| if (classpath != null) { | |||
| al = new AntClassLoader(al, getProject(), classpath, !reverseLoader); | |||
| } else { | |||
| al = new AntClassLoader(al, getProject(), Path.systemClasspath, | |||
| !reverseLoader); | |||
| } | |||
| } | |||
| // need to load Task via system classloader or the new | |||
| // task we want to define will never be a Task but always | |||
| // be wrapped into a TaskAdapter. | |||
| al.addSystemPackageRoot("org.apache.tools.ant"); | |||
| // If the loader is new, record it for future uses by other | |||
| // task/typedefs | |||
| if (loaderId != null) { | |||
| if (getProject().getReference(loaderId) == null) { | |||
| getProject().addReference(loaderId, al); | |||
| } | |||
| } | |||
| return al; | |||
| } | |||
| /** | |||
| * Name of the property file to load | |||
| * ant name/classname pairs from. | |||
| */ | |||
| public void setFile(File file) { | |||
| this.file = file; | |||
| } | |||
| /** | |||
| * Name of the property resource to load | |||
| * ant name/classname pairs from. | |||
| */ | |||
| public void setResource(String res) { | |||
| this.resource = res; | |||
| } | |||
| /** | |||
| * Name of the property resource to load | |||
| * ant name/classname pairs from. | |||
| */ | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| /** | |||
| * Returns the classname of the object we are defining. | |||
| * May be <code>null</code>. | |||
| */ | |||
| public String getClassname() { | |||
| return value; | |||
| } | |||
| /** | |||
| * The full class name of the object being defined. | |||
| * Required, unless file or resource have | |||
| * been specified. | |||
| */ | |||
| public void setClassname(String v) { | |||
| value = v; | |||
| } | |||
| /** | |||
| * subclassed handler for definitions; called by parent during | |||
| * execution. | |||
| */ | |||
| protected void addDefinition(String name, Class c) throws BuildException { | |||
| getProject().addTaskDefinition(name, c); | |||
| } | |||
| } | |||
| @@ -1,138 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.types.*; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| import org.w3c.dom.Document; | |||
| import org.xml.sax.SAXException; | |||
| import javax.xml.parsers.DocumentBuilderFactory; | |||
| import javax.xml.parsers.DocumentBuilder; | |||
| import javax.xml.parsers.ParserConfigurationException; | |||
| /** | |||
| * Loads an xml file as DOM in a DataType | |||
| * | |||
| */ | |||
| public class XMLDOM extends DataType { | |||
| /** The name of this data type */ | |||
| public static final String DATA_TYPE_NAME = "xmldom"; | |||
| private File xmlfile = null; | |||
| private Document docRoot = null; | |||
| public XMLDOM() { | |||
| } | |||
| public void setFile(File xmlfile) { | |||
| this.xmlfile = xmlfile; | |||
| } | |||
| /*** | |||
| * Gets the Document root of the DOM | |||
| * given project. | |||
| */ | |||
| public Document getRoot() { | |||
| if(docRoot==null){ | |||
| try{ | |||
| DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | |||
| //FIXME eventually set DocumentBuilderFactory properties in the future | |||
| DocumentBuilder builder = factory.newDocumentBuilder(); | |||
| //FIXME eventually set DocumentBuilder properties in the future | |||
| this.docRoot = builder.parse(xmlfile); | |||
| } | |||
| catch(ParserConfigurationException pce){ | |||
| throw new BuildException("Error in the configuration of the parser", pce); | |||
| } | |||
| catch(SAXException se){ | |||
| throw new BuildException("Error during parsing", se); | |||
| } | |||
| catch(IOException ioe){ | |||
| throw new BuildException("Can't load the specified file", ioe); | |||
| } | |||
| } | |||
| return docRoot; | |||
| } | |||
| /*** | |||
| * Get the RegularExpression this reference refers to in | |||
| * the given project. Check for circular references too | |||
| */ | |||
| /* | |||
| public Substitution getRef(Project p) { | |||
| if (!isChecked()) { | |||
| Stack stk = new Stack(); | |||
| stk.push(this); | |||
| dieOnCircularReference(stk, p); | |||
| } | |||
| Object o = getRefid().getReferencedObject(p); | |||
| if (!(o instanceof Substitution)) { | |||
| String msg = getRefid().getRefId() + " doesn\'t denote a substitution"; | |||
| throw new BuildException(msg); | |||
| } else { | |||
| return (Substitution) o; | |||
| } | |||
| } | |||
| */ | |||
| } //-- XMLDOM.java | |||
| @@ -1,203 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.PropertyHelper; | |||
| import org.apache.tools.ant.types.*; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| import org.apache.commons.jxpath.*; | |||
| // Experimental: need to add code to select the 'root', etc. | |||
| /** | |||
| * Enable JXPath dynamic properties. | |||
| * | |||
| */ | |||
| public class JXPath extends Task { | |||
| public static String PREFIX="jxpath:"; | |||
| JXPathPropertyHelper helper=new JXPathPropertyHelper(); | |||
| public JXPath() { | |||
| } | |||
| public JXPathContext getJXPathContext() { | |||
| return helper.jxpathCtx; | |||
| } | |||
| public void execute() { | |||
| JXPathIntrospector.registerDynamicClass(Hashtable.class, JXPathHashtableHandler.class); | |||
| helper.jxpathCtx=JXPathContext.newContext( project ); | |||
| helper.jxpathCtx.setVariables(new AntVariables()); | |||
| PropertyHelper phelper=PropertyHelper.getPropertyHelper( project ); | |||
| helper.setProject( project ); | |||
| helper.setNext( phelper.getNext() ); | |||
| phelper.setNext( helper ); | |||
| project.addReference( "jxpathTask", this ); | |||
| } | |||
| static class JXPathPropertyHelper extends PropertyHelper { | |||
| JXPathContext jxpathCtx; | |||
| public boolean setPropertyHook( String ns, String name, Object v, boolean inh, | |||
| boolean user, boolean isNew) | |||
| { | |||
| if( ! name.startsWith(PREFIX) ) { | |||
| // pass to next | |||
| return super.setPropertyHook(ns, name, v, inh, user, isNew); | |||
| } | |||
| name=name.substring( PREFIX.length() ); | |||
| jxpathCtx.setValue( name, v ); | |||
| return true; | |||
| } | |||
| public Object getPropertyHook( String ns, String name , boolean user) { | |||
| if( ! name.startsWith(PREFIX) ) { | |||
| // pass to next | |||
| return super.getPropertyHook(ns, name, user); | |||
| } | |||
| name=name.substring( PREFIX.length() ); | |||
| //Object o=jxpathCtx.getValue( name ); | |||
| //System.out.println("JXPath: getProperty " + ns + " " + name + "=" + o + o.getClass()); | |||
| String result = ""; | |||
| Iterator iter = jxpathCtx.iterate(name); | |||
| if(iter==null||!iter.hasNext()){ | |||
| return "null"; | |||
| } | |||
| result += iter.next(); | |||
| while (iter.hasNext()) { | |||
| Object o = iter.next(); | |||
| result += ", "+o; | |||
| } | |||
| return result; | |||
| } | |||
| } | |||
| public static class JXPathHashtableHandler implements DynamicPropertyHandler { | |||
| private static final String[] STRING_ARRAY = new String[0]; | |||
| /** | |||
| * Returns string representations of all keys in the map. | |||
| */ | |||
| public String[] getPropertyNames(Object object){ | |||
| // System.out.println("getPropertyNames " + object ); | |||
| Hashtable map = (Hashtable) object; | |||
| String names[] = new String[map.size()]; | |||
| Enumeration it = map.keys(); | |||
| for (int i = 0; i < names.length; i++){ | |||
| names[i] = String.valueOf(it.nextElement()); | |||
| } | |||
| return names; | |||
| } | |||
| /** | |||
| * Returns the value for the specified key. | |||
| */ | |||
| public Object getProperty(Object object, String propertyName) { | |||
| // System.out.println("getProperty " + object + " " + propertyName); | |||
| return ((Hashtable) object).get(propertyName); | |||
| } | |||
| /** | |||
| * Sets the specified key value. | |||
| */ | |||
| public void setProperty(Object object, String propertyName, Object value){ | |||
| ((Hashtable)object).put(propertyName, value); | |||
| } | |||
| } | |||
| public class AntVariables implements Variables { | |||
| protected AntVariables(){ | |||
| } | |||
| public void declareVariable(String varName, Object value){ | |||
| project.setNewProperty(varName, value.toString()); | |||
| } | |||
| public Object getVariable(String varName){ | |||
| return project.getProperty(varName); | |||
| } | |||
| public boolean isDeclaredVariable(String varName){ | |||
| return project.getProperty(varName) == null ? false : true ; | |||
| } | |||
| public void undeclareVariable(String varName){ | |||
| throw new UnsupportedOperationException("Cannot undeclare variables in Ant."); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,116 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.types.*; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| import org.apache.commons.jxpath.*; | |||
| /** | |||
| * Set a JXPath property | |||
| * | |||
| * | |||
| * @deprecated A generic <property> should be used. | |||
| */ | |||
| public class JXPathSet extends Task { | |||
| String path; | |||
| String valueString; | |||
| String refId; | |||
| public JXPathSet() { | |||
| } | |||
| /** The JXPath pointing to the target. | |||
| * The root of the tree is the Project. | |||
| * Example: | |||
| * /references[@name='myRef'] | |||
| * | |||
| */ | |||
| public void setPath( String path ) { | |||
| this.path=path; | |||
| } | |||
| /** The value will be the referenced object. | |||
| */ | |||
| public void setRefId( String refId ) { | |||
| this.refId=refId; | |||
| } | |||
| /** Set the value to be used. | |||
| */ | |||
| public void setValue( String s ) { | |||
| this.valueString=s; | |||
| } | |||
| public void execute() { | |||
| JXPathContext jxpathCtx; | |||
| JXPath jxpathTask=(JXPath)project.getReference( "jxpathTask" ); | |||
| jxpathCtx=jxpathTask.getJXPathContext(); | |||
| Object value=null; | |||
| if( refId!=null ) | |||
| value=project.getReference( refId ); | |||
| if( value==null ) | |||
| value=valueString; | |||
| jxpathCtx.setValue( path, value ); | |||
| } | |||
| } | |||
| @@ -1,113 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.PropertyHelper; | |||
| import org.apache.tools.ant.types.*; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| import org.apache.commons.jexl.*; | |||
| /** | |||
| * Enable JEXL dynamic properties | |||
| * | |||
| * | |||
| */ | |||
| public class JexlProperties extends Task { | |||
| public static String PREFIX="jexl:"; | |||
| JexlPropertyHelper helper=new JexlPropertyHelper(); | |||
| public JexlProperties() { | |||
| } | |||
| static class JexlPropertyHelper extends PropertyHelper { | |||
| JexlContext jc; | |||
| public Object getPropertyHook( String ns, String name, boolean user ) { | |||
| if( ! name.startsWith(PREFIX) ) { | |||
| return super.getPropertyHook(ns, name, user); | |||
| } | |||
| try { | |||
| name=name.substring( PREFIX.length() ); | |||
| Expression e = ExpressionFactory.createExpression(name); | |||
| Object o = e.evaluate(jc); | |||
| return o; | |||
| } catch( Exception ex ) { | |||
| ex.printStackTrace(); | |||
| return null; | |||
| } | |||
| } | |||
| } | |||
| public void execute() { | |||
| /* | |||
| * First make a jexlContext and put stuff in it | |||
| */ | |||
| helper.jc = JexlHelper.createContext(); | |||
| helper.jc.getVars().put("ant", project); | |||
| // register it | |||
| PropertyHelper phelper=PropertyHelper.getPropertyHelper( project ); | |||
| helper.setNext( phelper.getNext() ); | |||
| helper.setProject( project ); | |||
| phelper.setNext( helper ); | |||
| } | |||
| } | |||
| @@ -1,142 +0,0 @@ | |||
| /* | |||
| * ==================================================================== | |||
| * | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999-2002, 2006 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Commons", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| * | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import org.apache.tools.ant.*; | |||
| import java.util.*; | |||
| import org.apache.commons.discovery.*; | |||
| import org.apache.commons.discovery.jdk.JDKHooks; | |||
| import org.apache.commons.discovery.resource.*; | |||
| /** | |||
| * Default implementation for discovery and (lazy) creation of tasks. | |||
| * | |||
| * Several mechanisms will be used: | |||
| * - properties files found in the classpath ( META-INF/ant.tasks ). | |||
| * - resources named after the task name: META-INF/ant/[TASK_NAME].task | |||
| * | |||
| */ | |||
| public class TaskDiscovery extends Task implements ProjectComponentFactory | |||
| { | |||
| String RESOURCE_NAME="META-INF/ant.tasks"; | |||
| // Also discovery the 'legacy' names - in ant1.6 the initial preloaded tasks | |||
| // should be deprecated. | |||
| Resource[] discoveredTasks = null; | |||
| Hashtable taskDefs=new Hashtable(); | |||
| public Object createProjectComponent( Project project, | |||
| String ns, | |||
| String taskName ) | |||
| throws BuildException | |||
| { | |||
| // System.out.println("Try create " + taskName); | |||
| // | |||
| return null; | |||
| } | |||
| public String toString() { | |||
| StringBuffer sb=new StringBuffer(); | |||
| sb.append( "DiscoveredTasks[" ); | |||
| if( discoveredTasks != null ) { | |||
| for( int i=0; i<discoveredTasks.length; i++ ) { | |||
| if( i>0) sb.append( ", "); | |||
| sb.append( discoveredTasks[i] ); | |||
| } | |||
| sb.append( "]"); | |||
| } | |||
| return sb.toString(); | |||
| } | |||
| Properties taskClassNames=new Properties(); | |||
| /** @TODO: Register itself as ProjectComponentHelper. | |||
| */ | |||
| public void execute() throws BuildException | |||
| { | |||
| ProjectComponentHelper pcHelper=ProjectComponentHelper.getProjectComponentHelper(); | |||
| pcHelper.addComponentFactory( this ); | |||
| // We'll read all 'ant.tasks' at startup, and every time an unknown task | |||
| // is found ( the classloader may be different from last time ). Not the best | |||
| // solution, just a start. | |||
| DiscoverResources disc = new DiscoverResources(); | |||
| disc.addClassLoader( JDKHooks.getJDKHooks().getThreadContextClassLoader() ); | |||
| disc.addClassLoader( this.getClass().getClassLoader() ); | |||
| ResourceIterator ri = disc.findResources(RESOURCE_NAME); | |||
| Vector vector = new Vector(); | |||
| while (ri.hasNext()) { | |||
| Resource resourceInfo = ri.nextResource(); | |||
| vector.add(resourceInfo); | |||
| System.out.println("Found " + resourceInfo); | |||
| } | |||
| discoveredTasks = new Resource[vector.size()]; | |||
| vector.copyInto(discoveredTasks); | |||
| } | |||
| } | |||
| @@ -1,127 +0,0 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.taskdefs.optional; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.PropertyHelper; | |||
| import org.apache.tools.ant.types.*; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| import org.apache.velocity.app.VelocityEngine; | |||
| import org.apache.velocity.VelocityContext; | |||
| import org.apache.velocity.Template; | |||
| /** | |||
| * Enable Velocity dynamic properties | |||
| * | |||
| * | |||
| */ | |||
| public class VelocityProperties extends Task { | |||
| public static final String PREFIX="vm:"; | |||
| VelocityPropertyHelper helper=new VelocityPropertyHelper(); | |||
| public VelocityProperties() { | |||
| } | |||
| static class VelocityPropertyHelper extends PropertyHelper { | |||
| VelocityEngine engine; | |||
| VelocityContext context; | |||
| public Object getPropertyHook( String ns, String name, boolean user ) { | |||
| if( ! name.startsWith(PREFIX) ) { | |||
| // pass on to next | |||
| return super.getPropertyHook(ns, name, user); | |||
| } | |||
| try { | |||
| name=name.substring( PREFIX.length() ); | |||
| StringWriter sw=new StringWriter(); | |||
| engine.evaluate( context, sw, "antVM", name ); | |||
| System.out.println("VM: getProperty " + ns + " " + name + "=" + sw.toString()); | |||
| return sw.toString(); | |||
| } catch( Exception ex ) { | |||
| ex.printStackTrace(); | |||
| return null; | |||
| } | |||
| } | |||
| } | |||
| public VelocityEngine getVelocityEngine() { | |||
| return helper.engine; | |||
| } | |||
| public void execute() { | |||
| try { | |||
| // Prepare the engine | |||
| helper.engine=new VelocityEngine(); | |||
| helper.engine.init(); | |||
| helper.context=new VelocityContext(); | |||
| helper.context.put( "ant", project ); | |||
| // Register it | |||
| PropertyHelper phelper=PropertyHelper.getPropertyHelper( project ); | |||
| helper.setNext( phelper.getNext() ); | |||
| helper.setProject( project ); | |||
| phelper.setNext( helper ); | |||
| } catch( Exception ex ) { | |||
| ex.printStackTrace(); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,126 +0,0 @@ | |||
| <project name="embed-test" default="main" basedir="."> | |||
| <property name="ant.src" location="../.."/> | |||
| <description>Test for embed proposal</description> | |||
| <import file="build.xml"/> | |||
| <!-- This is a tricky problem: import will append tasks at the | |||
| end of the task list. That's a bug, it should replace the | |||
| <import> task with the content. When fixed, this should show | |||
| the real value. --> | |||
| <echo message="Base.path from build.xml ( in top level ): ${base.path}"/> | |||
| <target name="init"> | |||
| <property name="junit.jar" location="${base.path}/junit3.7/junit.jar"/> | |||
| <echo>Base.path from build.xml ( in init ) : ${base.path}</echo> | |||
| <path id="myJars" > | |||
| <pathelement path="${junit.jar}" /> | |||
| <pathelement path="${jxpath.jar}" /> | |||
| <pathelement path="${velocity-dep.jar}" /> | |||
| <pathelement path="${velocity.jar}" /> | |||
| <pathelement path="${jexl.jar}" /> | |||
| <pathelement path="${commons-discovery.jar}" /> | |||
| <pathelement path="${commons-logging.jar}" /> | |||
| <pathelement path="${ant.home}/lib/ant-sax2.jar" /> | |||
| <pathelement location="/usr/share/java/xalan-j_2_3_1/bin/xercesImpl.jar"/> | |||
| <pathelement location="${ant.home}/lib/xercesImpl.jar"/> | |||
| <pathelement location="${ant.home}/lib/xml-apis.jar"/> | |||
| <pathelement location="${ant.home}/lib/ant.jar"/> | |||
| <fileset dir="${ant.home}/lib" includes="optional-*.jar" /> | |||
| </path> | |||
| <echo>Path: ${toString:myJars}</echo> | |||
| <classloader classpathRef="myJars"/> | |||
| </target> | |||
| <target name="xmldom" depends="init"> | |||
| <taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPath" | |||
| name="jxpath" /> | |||
| <typedef classname="org.apache.tools.ant.taskdefs.XMLDOM" | |||
| name="xmlDom" /> | |||
| <xmlDom id="module.xml" file="/ws/jakarta-gump/project/jakarta-ant.xml"/> | |||
| <!-- Enable Jxpath support --> | |||
| <jxpath/> | |||
| <echo>Name: ${jxpath:/references/module.xml/root/module/project[1]/@name}</echo> | |||
| </target> | |||
| <target name="discovery" depends="init"> | |||
| <echo message="${commons-discovery.jar}"/> | |||
| <systemPath pathRef="myJars"/> | |||
| <taskdef classname="org.apache.tools.ant.taskdefs.ServiceDiscoveryTask" | |||
| name="discovery" /> | |||
| <taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPath" | |||
| name="jxpath" /> | |||
| <jxpath/> | |||
| <discovery debug="1" id="myDiscovery" | |||
| serviceName="META-INF/services/javax.xml.parsers.SAXParserFactory" /> | |||
| <echo message="Found ${jxpath:/references[@name='myDiscovery']}" /> | |||
| </target> | |||
| <target name="systemPathTest" depends="init"> | |||
| <junit id="replacedJunit" /> | |||
| <echo message="Found JUNIT: ${toString:replacedJunit}" /> | |||
| </target> | |||
| <target name="dynamicProperties" depends="init"> | |||
| <!-- This is Taksdef2.java - it'll use the systemPath as parent loader | |||
| --> | |||
| <taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPath" | |||
| name="jxpath" /> | |||
| <taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPathSet" | |||
| name="jxpathSet" /> | |||
| <taskdef classname="org.apache.tools.ant.taskdefs.optional.VelocityProperties" | |||
| name="velocityProperties" /> | |||
| <taskdef classname="org.apache.tools.ant.taskdefs.optional.JexlProperties" | |||
| name="jexlProperties" /> | |||
| <!-- Init JxPath. '/' is the project --> | |||
| <jxpath/> | |||
| <velocityProperties/> | |||
| <jexlProperties/> | |||
| <echo id="foo" message="Starting dynamic props tests" /> | |||
| <echo message="Value: ${vm:$ant.references.jxpathTask.foo}" /> | |||
| <jxpathSet path="/references[@name='jxpathTask']/foo" value="Test"/> | |||
| <echo message="Value: ${vm:$ant.references.jxpathTask.foo}" /> | |||
| <echo message="${jexl:ant.references.jxpathTask.foo=bar}" /> | |||
| <echo message="Value: ${vm:$ant.references.jxpathTask.foo}" /> | |||
| <echo message="jexl /references/myJars: ${jexl:ant.references.myJars}" /> | |||
| <echo message="jxPath /targets[1]: ${jxpath:/targets[1]}" /> | |||
| <echo message="jxPath /references: ${jxpath:/references}" /> | |||
| <echo message="jxPath /references[@name='myJars']: ${jxpath:/references[@name='myJars']}" /> | |||
| <echo message="jxPath /references/myJars: ${jxpath:/references/myJars}" /> | |||
| <!-- This is XMLDOM.java - a datatype that holds an xml DOM --> | |||
| <typedef name="xmldom" classname="org.apache.tools.ant.taskdefs.XMLDOM"/> | |||
| <!-- Init XMLDOM. The DOM of file test.xml will be referenced via the id--> | |||
| <xmldom id="test.xml" file="test.xml"/> | |||
| <echo message="XMLDOM: ${jxpath:/references/test.xml/root/project/@name}" /> | |||
| </target> | |||
| <target name="main" depends="init,dynamicProperties,systemPathTest,test-import"> | |||
| </target> | |||
| <target name="test-import" > | |||
| <antcall target="embed.main" /> | |||
| </target> | |||
| </project> | |||