git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271722 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -27,3 +27,6 @@ java -classpath bootstrap\lib\start.jar;bootstrap\lib\init.jar org.apache.ant.st | |||||
| REM Use the full build as the build used by the build script | REM Use the full build as the build used by the build script | ||||
| xcopy /s dist bootstrap | xcopy /s dist bootstrap | ||||
| REM clean up after bootstrap | |||||
| java -classpath bootstrap\lib\start.jar:bootstrap\lib\init.jar org.apache.ant.start.Main clean | |||||
| @@ -35,7 +35,8 @@ | |||||
| </path> | </path> | ||||
| <target name="buildsetup"> | <target name="buildsetup"> | ||||
| <available file="../checkstyle" property="checkstyle.available"/> | |||||
| <available classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" | |||||
| property="checkstyle.available"/> | |||||
| <mkdir dir="${bin.dir}"/> | <mkdir dir="${bin.dir}"/> | ||||
| <mkdir dir="${distlib.dir}"/> | <mkdir dir="${distlib.dir}"/> | ||||
| <copy todir="${distlib.dir}/parser"> | <copy todir="${distlib.dir}/parser"> | ||||
| @@ -99,6 +100,14 @@ | |||||
| <attribute name="Main-Class" value="org.apache.ant.start.Main"/> | <attribute name="Main-Class" value="org.apache.ant.start.Main"/> | ||||
| <attribute name="Class-Path" value="init.jar"/> | <attribute name="Class-Path" value="init.jar"/> | ||||
| </manifest> | </manifest> | ||||
| <include name="org/apache/ant/**/*"/> | |||||
| </jar> | |||||
| <jar basedir="${bin.dir}/start" jarfile="${distlib.dir}/ant.jar"> | |||||
| <manifest> | |||||
| <attribute name="Main-Class" value="org.apache.tools.ant.Main"/> | |||||
| <attribute name="Class-Path" value="start.jar"/> | |||||
| </manifest> | |||||
| <include name="org/apache/tools/ant/**/*"/> | |||||
| </jar> | </jar> | ||||
| </target> | </target> | ||||
| @@ -155,14 +164,8 @@ | |||||
| <target name="main" depends="cli, antlibs, ant1compat, remote, checkstyle"/> | <target name="main" depends="cli, antlibs, ant1compat, remote, checkstyle"/> | ||||
| <target name="checkstyle" if="checkstyle.available"> | <target name="checkstyle" if="checkstyle.available"> | ||||
| <property name="checkstyle.bin" value="../checkstyle"/> | |||||
| <path id="checkstyle.path"> | |||||
| <fileset dir="${checkstyle.bin}"/> | |||||
| </path> | |||||
| <taskdef name="checkstyle" | <taskdef name="checkstyle" | ||||
| classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"> | |||||
| <classpath refid="checkstyle.path"/> | |||||
| </taskdef> | |||||
| classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"/> | |||||
| <mkdir dir="${bin.dir}/check"/> | <mkdir dir="${bin.dir}/check"/> | ||||
| <checkstyle maxlinelen="80" | <checkstyle maxlinelen="80" | ||||
| memberpattern="[a-z].*" | memberpattern="[a-z].*" | ||||
| @@ -32,8 +32,6 @@ | |||||
| <patternset id="converted"> | <patternset id="converted"> | ||||
| <exclude name="org/apache/tools/ant/taskdefs/Ant.java"/> | <exclude name="org/apache/tools/ant/taskdefs/Ant.java"/> | ||||
| <exclude name="org/apache/tools/ant/taskdefs/CallTarget.java"/> | <exclude name="org/apache/tools/ant/taskdefs/CallTarget.java"/> | ||||
| <exclude name="org/apache/tools/ant/taskdefs/Parallel.java"/> | |||||
| <exclude name="org/apache/tools/ant/taskdefs/Sequential.java"/> | |||||
| </patternset> | </patternset> | ||||
| <fileset id="ant1src" dir="../../src/main"> | <fileset id="ant1src" dir="../../src/main"> | ||||
| @@ -68,6 +66,7 @@ | |||||
| <fileset dir="${lib.dir}/parser" includes="*.jar"/> | <fileset dir="${lib.dir}/parser" includes="*.jar"/> | ||||
| <fileset dir="${lib.dir}/ant1compat" includes="*.jar"/> | <fileset dir="${lib.dir}/ant1compat" includes="*.jar"/> | ||||
| <pathelement location="${distlib.dir}/common/common.jar"/> | <pathelement location="${distlib.dir}/common/common.jar"/> | ||||
| <pathelement location="${distlib.dir}/antlibs/system.tsk"/> | |||||
| </path> | </path> | ||||
| <target name="check_for_optional_packages"> | <target name="check_for_optional_packages"> | ||||
| @@ -317,11 +317,34 @@ public class ComponentManager implements ComponentService { | |||||
| * on the component type. | * on the component type. | ||||
| * @exception ExecutionException if the component cannot be created | * @exception ExecutionException if the component cannot be created | ||||
| */ | */ | ||||
| public Object createComponent(String componentName) | |||||
| throws ExecutionException { | |||||
| public Object createComponent(String componentName) | |||||
| throws ExecutionException { | |||||
| return createComponent(componentName, null); | return createComponent(componentName, null); | ||||
| } | } | ||||
| /** | |||||
| * Create a component given its class. The component will have a context | |||||
| * but will not be configured. It should be configured using the | |||||
| * appropriate set methods and then validated before being used. | |||||
| * | |||||
| * @param componentClass the component's class | |||||
| * @param factory the factory to create the component | |||||
| * @param loader the classloader associated with the component | |||||
| * @param addTaskAdapter whenther the returned component should be a | |||||
| * task, potentially being wrapped in an adapter | |||||
| * @param componentName the name of the component type | |||||
| * @return the created component. The return type of this method depends | |||||
| * on the component type. | |||||
| * @exception ExecutionException if the component cannot be created | |||||
| */ | |||||
| public Object createComponent(AntLibFactory factory, ClassLoader loader, | |||||
| Class componentClass, boolean addTaskAdapter, | |||||
| String componentName) | |||||
| throws ExecutionException { | |||||
| return createComponent(loader, factory, componentClass, | |||||
| componentName, componentName, addTaskAdapter, null); | |||||
| } | |||||
| /** | /** | ||||
| * Set the standard libraries (i.e. those which are independent of the | * Set the standard libraries (i.e. those which are independent of the | ||||
| * build files) to be used in this component manager | * build files) to be used in this component manager | ||||
| @@ -421,82 +444,39 @@ public class ComponentManager implements ComponentService { | |||||
| protected Object createComponent(String componentName, BuildElement model) | protected Object createComponent(String componentName, BuildElement model) | ||||
| throws ExecutionException { | throws ExecutionException { | ||||
| Location location = Location.UNKNOWN_LOCATION; | |||||
| if (model != null) { | |||||
| location = model.getLocation(); | |||||
| } | |||||
| ImportInfo definition = getDefinition(componentName); | ImportInfo definition = getDefinition(componentName); | ||||
| if (definition == null) { | if (definition == null) { | ||||
| throw new ExecutionException("There is no definition of the <" | throw new ExecutionException("There is no definition of the <" | ||||
| + componentName + "> component"); | |||||
| + componentName + "> component"); | |||||
| } | } | ||||
| String className = definition.getClassName(); | String className = definition.getClassName(); | ||||
| ComponentLibrary componentLibrary | ComponentLibrary componentLibrary | ||||
| = definition.getComponentLibrary(); | = definition.getComponentLibrary(); | ||||
| boolean isTask = definition.getDefinitionType() == AntLibrary.TASKDEF; | |||||
| String localName = definition.getLocalName(); | String localName = definition.getLocalName(); | ||||
| try { | try { | ||||
| ClassLoader componentLoader = componentLibrary.getClassLoader(); | ClassLoader componentLoader = componentLibrary.getClassLoader(); | ||||
| Class componentClass | Class componentClass | ||||
| = Class.forName(className, true, componentLoader); | = Class.forName(className, true, componentLoader); | ||||
| AntLibFactory libFactory = getLibFactory(componentLibrary); | AntLibFactory libFactory = getLibFactory(componentLibrary); | ||||
| Location location = Location.UNKNOWN_LOCATION; | |||||
| if (model != null) { | |||||
| location = model.getLocation(); | |||||
| } | |||||
| Object component | |||||
| = libFactory.createComponent(componentClass, localName); | |||||
| ExecutionComponent execComponent = null; | |||||
| if (definition.getDefinitionType() == AntLibrary.TASKDEF) { | |||||
| if (component instanceof Task) { | |||||
| execComponent = (Task)component; | |||||
| } else { | |||||
| execComponent = new TaskAdapter(componentName, component); | |||||
| } | |||||
| } else if (component instanceof ExecutionComponent) { | |||||
| execComponent = (ExecutionComponent)component; | |||||
| } | |||||
| ExecutionContext context | |||||
| = new ExecutionContext(frame, execComponent, location); | |||||
| context.setClassLoader(componentLoader); | |||||
| ClassLoader currentLoader | |||||
| = LoaderUtils.setContextLoader(componentLoader); | |||||
| if (execComponent != null) { | |||||
| execComponent.init(context, componentName); | |||||
| } | |||||
| if (model != null) { | |||||
| configureElement(libFactory, component, model); | |||||
| if (execComponent != null) { | |||||
| execComponent.validateComponent(); | |||||
| } | |||||
| } | |||||
| LoaderUtils.setContextLoader(currentLoader); | |||||
| if (execComponent != null) { | |||||
| return execComponent; | |||||
| } | |||||
| return component; | |||||
| return createComponent(componentLoader, libFactory, componentClass, | |||||
| componentName, localName, isTask, model); | |||||
| } catch (ClassNotFoundException e) { | } catch (ClassNotFoundException e) { | ||||
| throw new ExecutionException("Class " + className | throw new ExecutionException("Class " + className | ||||
| + " for component <" + componentName + "> was not found", e, | + " for component <" + componentName + "> was not found", e, | ||||
| model.getLocation()); | |||||
| location); | |||||
| } catch (NoClassDefFoundError e) { | } catch (NoClassDefFoundError e) { | ||||
| throw new ExecutionException("Could not load a dependent class (" | throw new ExecutionException("Could not load a dependent class (" | ||||
| + e.getMessage() + ") for component " + componentName, | + e.getMessage() + ") for component " + componentName, | ||||
| e, model.getLocation()); | |||||
| } catch (InstantiationException e) { | |||||
| throw new ExecutionException("Unable to instantiate component " | |||||
| + "class " + className + " for component <" + componentName | |||||
| + ">", e, model.getLocation()); | |||||
| } catch (IllegalAccessException e) { | |||||
| throw new ExecutionException("Unable to access task class " | |||||
| + className + " for component <" + componentName + ">", | |||||
| e, model.getLocation()); | |||||
| e, location); | |||||
| } catch (ExecutionException e) { | } catch (ExecutionException e) { | ||||
| e.setLocation(model.getLocation(), false); | e.setLocation(model.getLocation(), false); | ||||
| throw e; | throw e; | ||||
| } catch (RuntimeException e) { | |||||
| throw new ExecutionException(e.getClass().getName() + ": " | |||||
| + e.getMessage(), e, model.getLocation()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -545,6 +525,100 @@ public class ComponentManager implements ComponentService { | |||||
| return setter; | return setter; | ||||
| } | } | ||||
| /** | |||||
| * Create a component - handles all the variations | |||||
| * | |||||
| * @param loader the component's classloader | |||||
| * @param componentClass The class of the component. | |||||
| * @param componentName The component's name in the global context | |||||
| * @param addTaskAdapter whether the component should add a Task adapter | |||||
| * to make this component a Task. | |||||
| * @param localName The name of the component within its library | |||||
| * @param model the BuildElement model of the component's configuration | |||||
| * @param factory the facrtory object used to create the component | |||||
| * @return the required component potentially wrapped in a wrapper | |||||
| * object. | |||||
| * @exception ExecutionException if the component cannot be created | |||||
| */ | |||||
| private Object createComponent(ClassLoader loader, AntLibFactory factory, | |||||
| Class componentClass, String componentName, | |||||
| String localName, boolean addTaskAdapter, | |||||
| BuildElement model) | |||||
| throws ExecutionException { | |||||
| // set the location to unknown unless we have a build model to use | |||||
| Location location = Location.UNKNOWN_LOCATION; | |||||
| if (model != null) { | |||||
| location = model.getLocation(); | |||||
| } | |||||
| try { | |||||
| // create the component using the factory | |||||
| Object component | |||||
| = factory.createComponent(componentClass, localName); | |||||
| // wrap the component in an adapter if required. | |||||
| ExecutionComponent execComponent = null; | |||||
| if (addTaskAdapter) { | |||||
| if (component instanceof Task) { | |||||
| execComponent = (Task)component; | |||||
| } else { | |||||
| execComponent = new TaskAdapter(componentName, component); | |||||
| } | |||||
| } else if (component instanceof ExecutionComponent) { | |||||
| execComponent = (ExecutionComponent)component; | |||||
| } | |||||
| // set the context loader to that for the component | |||||
| ClassLoader currentLoader | |||||
| = LoaderUtils.setContextLoader(loader); | |||||
| // if the component is an execution component create a context and | |||||
| // initialise the component with it. | |||||
| if (execComponent != null) { | |||||
| ExecutionContext context | |||||
| = new ExecutionContext(frame, execComponent, location); | |||||
| context.setClassLoader(loader); | |||||
| execComponent.init(context, componentName); | |||||
| } | |||||
| // if we have a model, use it to configure the component. Otherwise | |||||
| // the caller is expected to configure thre object | |||||
| if (model != null) { | |||||
| configureElement(factory, component, model); | |||||
| // if the component is an execution component and we have a | |||||
| // model, validate it | |||||
| if (execComponent != null) { | |||||
| execComponent.validateComponent(); | |||||
| } | |||||
| } | |||||
| // reset the loader | |||||
| LoaderUtils.setContextLoader(currentLoader); | |||||
| // if we have an execution component, potentially a wrapper, | |||||
| // return it otherwise the component directly | |||||
| if (execComponent != null) { | |||||
| return execComponent; | |||||
| } else { | |||||
| return component; | |||||
| } | |||||
| } catch (InstantiationException e) { | |||||
| throw new ExecutionException("Unable to instantiate component " | |||||
| + "class " + componentClass.getName() + " for component <" | |||||
| + componentName + ">", e, location); | |||||
| } catch (IllegalAccessException e) { | |||||
| throw new ExecutionException("Unable to access task class " | |||||
| + componentClass.getName() + " for component <" | |||||
| + componentName + ">", e, location); | |||||
| } catch (ExecutionException e) { | |||||
| e.setLocation(location, false); | |||||
| throw e; | |||||
| } catch (RuntimeException e) { | |||||
| throw new ExecutionException(e.getClass().getName() + ": " | |||||
| + e.getMessage(), e, location); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Create an instance of a type given its required class | * Create an instance of a type given its required class | ||||
| * | * | ||||
| @@ -154,7 +154,7 @@ public class CoreExecService implements ExecService { | |||||
| Throwable failureCause = null; | Throwable failureCause = null; | ||||
| try { | try { | ||||
| ClassLoader currentLoader | ClassLoader currentLoader | ||||
| = LoaderUtils.setContextLoader(execContext.getLoader()); | |||||
| = LoaderUtils.setContextLoader(execContext.getClassLoader()); | |||||
| task.execute(); | task.execute(); | ||||
| LoaderUtils.setContextLoader(currentLoader); | LoaderUtils.setContextLoader(currentLoader); | ||||
| } catch (Throwable e) { | } catch (Throwable e) { | ||||
| @@ -160,11 +160,11 @@ public class ExecutionContext implements AntContext { | |||||
| } | } | ||||
| /** | /** | ||||
| * Gets the loader for this task | |||||
| * Gets the loader for this context | |||||
| * | * | ||||
| * @return the task's loader | |||||
| * @return the context's loader | |||||
| */ | */ | ||||
| protected ClassLoader getLoader() { | |||||
| public ClassLoader getClassLoader() { | |||||
| return loader; | return loader; | ||||
| } | } | ||||
| @@ -1,14 +1,13 @@ | |||||
| <antlib libid="ant.ant1compat" | <antlib libid="ant.ant1compat" | ||||
| home="http://jakarta.apache.org/ant" | home="http://jakarta.apache.org/ant" | ||||
| reqxml="true" reqtools="true"> | |||||
| reqxml="true" reqtools="true" | |||||
| extends="ant.system"> | |||||
| <factory classname="org.apache.tools.ant.Ant1Factory"/> | <factory classname="org.apache.tools.ant.Ant1Factory"/> | ||||
| <converter classname="org.apache.tools.ant.Ant1Converter"/> | <converter classname="org.apache.tools.ant.Ant1Converter"/> | ||||
| <!-- typedefs --> | <!-- typedefs --> | ||||
| <taskdef name="ant" classname="org.apache.tools.ant.taskdefs.Ant"/> | |||||
| <taskdef name="antcall" classname="org.apache.tools.ant.taskdefs.CallTarget"/> | |||||
| <taskdef name="antlr" classname="org.apache.tools.ant.taskdefs.optional.ANTLR"/> | <taskdef name="antlr" classname="org.apache.tools.ant.taskdefs.optional.ANTLR"/> | ||||
| <taskdef name="antstructure" classname="org.apache.tools.ant.taskdefs.AntStructure"/> | <taskdef name="antstructure" classname="org.apache.tools.ant.taskdefs.AntStructure"/> | ||||
| <taskdef name="apply" classname="org.apache.tools.ant.taskdefs.Transform"/> | <taskdef name="apply" classname="org.apache.tools.ant.taskdefs.Transform"/> | ||||
| @@ -89,7 +88,6 @@ | |||||
| <taskdef name="p4label" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Label"/> | <taskdef name="p4label" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Label"/> | ||||
| <taskdef name="p4submit" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Submit"/> | <taskdef name="p4submit" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Submit"/> | ||||
| <taskdef name="p4sync" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Sync"/> | <taskdef name="p4sync" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Sync"/> | ||||
| <taskdef name="parallel" classname="org.apache.tools.ant.taskdefs.Parallel"/> | |||||
| <taskdef name="patch" classname="org.apache.tools.ant.taskdefs.Patch"/> | <taskdef name="patch" classname="org.apache.tools.ant.taskdefs.Patch"/> | ||||
| <taskdef name="pathconvert" classname="org.apache.tools.ant.taskdefs.PathConvert"/> | <taskdef name="pathconvert" classname="org.apache.tools.ant.taskdefs.PathConvert"/> | ||||
| <taskdef name="property" classname="org.apache.tools.ant.taskdefs.Property"/> | <taskdef name="property" classname="org.apache.tools.ant.taskdefs.Property"/> | ||||
| @@ -102,7 +100,6 @@ | |||||
| <taskdef name="rmic" classname="org.apache.tools.ant.taskdefs.Rmic"/> | <taskdef name="rmic" classname="org.apache.tools.ant.taskdefs.Rmic"/> | ||||
| <taskdef name="rpm" classname="org.apache.tools.ant.taskdefs.optional.Rpm"/> | <taskdef name="rpm" classname="org.apache.tools.ant.taskdefs.optional.Rpm"/> | ||||
| <taskdef name="script" classname="org.apache.tools.ant.taskdefs.optional.Script"/> | <taskdef name="script" classname="org.apache.tools.ant.taskdefs.optional.Script"/> | ||||
| <taskdef name="sequential" classname="org.apache.tools.ant.taskdefs.Sequential"/> | |||||
| <taskdef name="signjar" classname="org.apache.tools.ant.taskdefs.SignJar"/> | <taskdef name="signjar" classname="org.apache.tools.ant.taskdefs.SignJar"/> | ||||
| <taskdef name="sleep" classname="org.apache.tools.ant.taskdefs.Sleep"/> | <taskdef name="sleep" classname="org.apache.tools.ant.taskdefs.Sleep"/> | ||||
| <taskdef name="soscheckin" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSCheckin"/> | <taskdef name="soscheckin" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSCheckin"/> | ||||
| @@ -870,24 +870,59 @@ public class Project implements org.apache.ant.common.event.BuildListener { | |||||
| * @return the created task instance | * @return the created task instance | ||||
| */ | */ | ||||
| public Task createTask(String taskType) { | public Task createTask(String taskType) { | ||||
| // we piggy back the task onto the current context | |||||
| Task task = null; | Task task = null; | ||||
| Class c = (Class)taskClassDefinitions.get(taskType); | |||||
| Class taskClass = (Class)taskClassDefinitions.get(taskType); | |||||
| if (c == null) { | |||||
| if (taskClass == null) { | |||||
| return null; | return null; | ||||
| } | } | ||||
| try { | try { | ||||
| task = (Task)c.newInstance(); | |||||
| task.setProject(this); | |||||
| task.init(context, taskType); | |||||
| Object taskObject = componentService.createComponent(factory, | |||||
| context.getClassLoader(), taskClass, false, taskType); | |||||
| if (taskObject instanceof Task) { | |||||
| task = (Task)taskObject; | |||||
| } else { | |||||
| TaskAdapter adapter = new TaskAdapter(); | |||||
| adapter.setProxy(taskObject); | |||||
| task = adapter; | |||||
| } | |||||
| task.setTaskType(taskType); | |||||
| task.setTaskName(taskType); | |||||
| return task; | return task; | ||||
| } catch (Throwable e) { | } catch (Throwable e) { | ||||
| throw new BuildException(e); | throw new BuildException(e); | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Creates a new instance of a data type. | |||||
| * | |||||
| * @param typeName The name of the data type to create an instance of. | |||||
| * Must not be <code>null</code>. | |||||
| * | |||||
| * @return an instance of the specified data type, or <code>null</code> if | |||||
| * the data type name is not recognised. | |||||
| * | |||||
| * @exception BuildException if the data type name is recognised but | |||||
| * instance creation fails. | |||||
| */ | |||||
| public Object createDataType(String typeName) throws BuildException { | |||||
| Class typeClass = (Class)dataClassDefinitions.get(typeName); | |||||
| if (typeClass == null) { | |||||
| return null; | |||||
| } | |||||
| try { | |||||
| Object dataInstance = componentService.createComponent(factory, | |||||
| context.getClassLoader(), typeClass, false, typeName); | |||||
| return dataInstance; | |||||
| } catch (Throwable e) { | |||||
| throw new BuildException(e); | |||||
| } | |||||
| } | |||||
| /** send build started event to the listeners */ | /** send build started event to the listeners */ | ||||
| protected void fireBuildStarted() { | protected void fireBuildStarted() { | ||||
| BuildEvent event = new BuildEvent(this); | BuildEvent event = new BuildEvent(this); | ||||
| @@ -133,7 +133,7 @@ public abstract class Task extends ProjectComponent | |||||
| /** | /** | ||||
| * Add a nested task to this Ant1 task. | |||||
| * Add a nested task to this Ant1 task. | |||||
| * | * | ||||
| * @param task The task to be added | * @param task The task to be added | ||||
| * @exception ExecutionException if the task cannot be added. | * @exception ExecutionException if the task cannot be added. | ||||
| @@ -173,6 +173,10 @@ public abstract class Task extends ProjectComponent | |||||
| } | } | ||||
| /** Initialise this task */ | |||||
| public void init() { | |||||
| } | |||||
| /** Validate this component */ | /** Validate this component */ | ||||
| public void validateComponent() { | public void validateComponent() { | ||||
| // no default validation for Ant1 tasks | // no default validation for Ant1 tasks | ||||
| @@ -0,0 +1,64 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 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; | |||||
| /** | |||||
| * Ant facade over system version of Ant | |||||
| * | |||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||||
| * @created 31 January 2002 | |||||
| */ | |||||
| public class Ant extends org.apache.ant.antlib.system.Ant { | |||||
| } | |||||
| @@ -0,0 +1,66 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 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.ant.antlib.system.AntCall; | |||||
| /** | |||||
| * CallTarget facade over AntCall | |||||
| * | |||||
| * @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||||
| * @created 31 January 2002 | |||||
| */ | |||||
| public class CallTarget extends AntCall { | |||||
| } | |||||
| @@ -1,5 +1,4 @@ | |||||
| package org.apache.ant.builder; | package org.apache.ant.builder; | ||||
| public class Ant1CompatBuilder { | public class Ant1CompatBuilder { | ||||
| protected void _init(BuildHelper helper) { | protected void _init(BuildHelper helper) { | ||||
| helper.setProperty("src.dir", "src"); | helper.setProperty("src.dir", "src"); | ||||
| @@ -16,10 +15,13 @@ public class Ant1CompatBuilder { | |||||
| helper.setProperty("util.package", "${ant.package}/util"); | helper.setProperty("util.package", "${ant.package}/util"); | ||||
| helper.setProperty("regexp.package", "${util.package}/regexp"); | helper.setProperty("regexp.package", "${util.package}/regexp"); | ||||
| helper.createPath("classpath"); | helper.createPath("classpath"); | ||||
| helper.addFileSetToPath("classpath", "${lib.dir}/parser", "*.jar"); | |||||
| helper.addFileSetToPath("classpath", "${lib.dir}/ant1compat", "*.jar"); | |||||
| helper.addFileSetToPath("classpath", | |||||
| "${lib.dir}/parser", "*.jar"); | |||||
| helper.addFileSetToPath("classpath", | |||||
| "${lib.dir}/ant1compat", "*.jar"); | |||||
| helper.addPathElementToPath("classpath", "${distlib.dir}/init.jar"); | helper.addPathElementToPath("classpath", "${distlib.dir}/init.jar"); | ||||
| helper.addPathElementToPath("classpath", "${distlib.dir}/common/common.jar"); | helper.addPathElementToPath("classpath", "${distlib.dir}/common/common.jar"); | ||||
| helper.addPathElementToPath("classpath", "${distlib.dir}/antlibs/system.tsk"); | |||||
| } | } | ||||
| protected void check_for_optional_packages(BuildHelper helper) { | protected void check_for_optional_packages(BuildHelper helper) { | ||||
| } | } | ||||
| @@ -10,7 +10,8 @@ public class MutantBuilder { | |||||
| helper.setProperty("distlib.dir", "${dist.dir}/lib"); | helper.setProperty("distlib.dir", "${dist.dir}/lib"); | ||||
| helper.setProperty("debug", "true"); | helper.setProperty("debug", "true"); | ||||
| helper.createPath("classpath.parser"); | helper.createPath("classpath.parser"); | ||||
| helper.addFileSetToPath("classpath.parser", "${lib.dir}/parser", "*.jar"); | |||||
| helper.addFileSetToPath("classpath.parser", | |||||
| "${lib.dir}/parser", "*.jar"); | |||||
| helper.createPath("classpath.common"); | helper.createPath("classpath.common"); | ||||
| helper.addPathElementToPath("classpath.common", "${distlib.dir}/init.jar"); | helper.addPathElementToPath("classpath.common", "${distlib.dir}/init.jar"); | ||||
| helper.createPath("classpath.antcore"); | helper.createPath("classpath.antcore"); | ||||
| @@ -60,6 +61,8 @@ public class MutantBuilder { | |||||
| helper.javac("${java.dir}/start", "${bin.dir}/start", "classpath.start"); | helper.javac("${java.dir}/start", "${bin.dir}/start", "classpath.start"); | ||||
| helper.jar("${bin.dir}/start", "${distlib.dir}/start.jar", | helper.jar("${bin.dir}/start", "${distlib.dir}/start.jar", | ||||
| null, null); | null, null); | ||||
| helper.jar("${bin.dir}/start", "${distlib.dir}/ant.jar", | |||||
| null, null); | |||||
| } | } | ||||
| protected void ant1compat(BuildHelper helper) { | protected void ant1compat(BuildHelper helper) { | ||||
| } | } | ||||
| @@ -86,9 +89,6 @@ public class MutantBuilder { | |||||
| protected void main(BuildHelper helper) { | protected void main(BuildHelper helper) { | ||||
| } | } | ||||
| protected void checkstyle(BuildHelper helper) { | protected void checkstyle(BuildHelper helper) { | ||||
| helper.setProperty("checkstyle.bin", "../checkstyle"); | |||||
| helper.createPath("checkstyle.path"); | |||||
| helper.addFileSetToPath("checkstyle.path", "${checkstyle.bin}", null); | |||||
| helper.mkdir("${bin.dir}/check"); | helper.mkdir("${bin.dir}/check"); | ||||
| } | } | ||||
| protected void javadocs(BuildHelper helper) { | protected void javadocs(BuildHelper helper) { | ||||
| @@ -99,5 +99,12 @@ public interface AntContext { | |||||
| * @return the location | * @return the location | ||||
| */ | */ | ||||
| Location getLocation(); | Location getLocation(); | ||||
| /** | |||||
| * Get the classloader associated with this context | |||||
| * | |||||
| * @return a classloader instance. | |||||
| */ | |||||
| ClassLoader getClassLoader(); | |||||
| } | } | ||||
| @@ -171,5 +171,23 @@ public interface ComponentService { | |||||
| */ | */ | ||||
| Object createComponent(String componentName) throws ExecutionException; | Object createComponent(String componentName) throws ExecutionException; | ||||
| /** | |||||
| * Create a component given its class. The component will have a context | |||||
| * but will not be configured. It should be configured using the | |||||
| * appropriate set methods and then validated before being used. | |||||
| * | |||||
| * @param componentClass the component's class | |||||
| * @param factory the factory to create the component | |||||
| * @param loader the classloader associated with the component | |||||
| * @param addTaskAdapter whenther the returned component should be a | |||||
| * task, potentially being wrapped in an adapter | |||||
| * @param componentName the name of the component type | |||||
| * @return the created component. The return type of this method depends | |||||
| * on the component type. | |||||
| * @exception ExecutionException if the component cannot be created | |||||
| */ | |||||
| Object createComponent(AntLibFactory factory, ClassLoader loader, | |||||
| Class componentClass, boolean addTaskAdapter, | |||||
| String componentName) throws ExecutionException; | |||||
| } | } | ||||