git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272626 13f79535-47bb-0310-9956-ffa450edef68master
@@ -144,28 +144,25 @@ | |||||
<delete dir="${dist.dir}"/> | <delete dir="${dist.dir}"/> | ||||
</target> | </target> | ||||
<target name="antlibs" depends="common"> | |||||
<antcall target="build-lib"> | |||||
<param name="libset" value="system"/> | |||||
</antcall> | |||||
<target name="antlibs" depends="common, systemlib"> | |||||
<ant antfile="build/script.xml"/> | <ant antfile="build/script.xml"/> | ||||
</target> | </target> | ||||
<target name="build-lib"> | |||||
<mkdir dir="${bin.dir}/antlibs/${libset}"/> | |||||
<mkdir dir="${distlib.dir}/antlibs"/> | |||||
<target name="systemlib" depends="common"> | |||||
<mkdir dir="${bin.dir}/antlibs/system"/> | |||||
<mkdir dir="${distlib.dir}/syslibs"/> | |||||
<path id="classpath.antlibs"> | <path id="classpath.antlibs"> | ||||
<path refid="classpath.common"/> | <path refid="classpath.common"/> | ||||
<pathelement location="${distlib.dir}/common/common.jar"/> | <pathelement location="${distlib.dir}/common/common.jar"/> | ||||
</path> | </path> | ||||
<depend destdir="${bin.dir}/antlibs/${libset}" srcdir="${java.dir}/antlibs/${libset}"> | |||||
<depend destdir="${bin.dir}/antlibs/system" srcdir="${java.dir}/antlibs/system"> | |||||
<classpath refid="classpath.antlibs"/> | <classpath refid="classpath.antlibs"/> | ||||
</depend> | </depend> | ||||
<javac destdir="${bin.dir}/antlibs/${libset}" srcdir="${java.dir}/antlibs/${libset}" debug="${debug}"> | |||||
<javac destdir="${bin.dir}/antlibs/system" srcdir="${java.dir}/antlibs/system" debug="${debug}"> | |||||
<classpath refid="classpath.antlibs"/> | <classpath refid="classpath.antlibs"/> | ||||
</javac> | </javac> | ||||
<jar basedir="${bin.dir}/antlibs/${libset}" jarfile="${distlib.dir}/antlibs/${libset}.jar"> | |||||
<metainf dir="${java.dir}/antlibs/${libset}" | |||||
<jar basedir="${bin.dir}/antlibs/system" jarfile="${distlib.dir}/syslibs/system.jar"> | |||||
<metainf dir="${java.dir}/antlibs/system" | |||||
includes="antlib.xml"/> | includes="antlib.xml"/> | ||||
</jar> | </jar> | ||||
</target> | </target> | ||||
@@ -43,6 +43,7 @@ | |||||
<exclude name="org/apache/tools/ant/ProjectHelper.java"/> | <exclude name="org/apache/tools/ant/ProjectHelper.java"/> | ||||
<exclude name="org/apache/tools/ant/Task.java"/> | <exclude name="org/apache/tools/ant/Task.java"/> | ||||
<exclude name="org/apache/tools/ant/Main.java"/> | <exclude name="org/apache/tools/ant/Main.java"/> | ||||
<exclude name="org/apache/tools/ant/input/InputRequest.java"/> | |||||
</patternset> | </patternset> | ||||
<patternset id="notrequired"> | <patternset id="notrequired"> | ||||
@@ -63,6 +64,7 @@ | |||||
<include name="org/apache/tools/mail/**/*.java"/> | <include name="org/apache/tools/mail/**/*.java"/> | ||||
<include name="org/apache/tools/tar/**/*.java"/> | <include name="org/apache/tools/tar/**/*.java"/> | ||||
<include name="org/apache/tools/ant/*.java"/> | <include name="org/apache/tools/ant/*.java"/> | ||||
<include name="org/apache/tools/ant/input/*.java"/> | |||||
<!-- <patternset refid="deprecated"/> --> | <!-- <patternset refid="deprecated"/> --> | ||||
<patternset refid="toohard"/> | <patternset refid="toohard"/> | ||||
<patternset refid="converted"/> | <patternset refid="converted"/> | ||||
@@ -74,7 +76,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.jar"/> | |||||
<pathelement location="${distlib.dir}/syslibs/system.jar"/> | |||||
</path> | </path> | ||||
<!-- | <!-- | ||||
@@ -480,6 +482,7 @@ | |||||
</fileset> | </fileset> | ||||
</copy> | </copy> | ||||
<mkdir dir="${distlib.dir}/antlibs/"/> | |||||
<jar basedir="${bin.dir}/ant1compat" jarfile="${distlib.dir}/antlibs/ant1compat.jar"> | <jar basedir="${bin.dir}/ant1compat" jarfile="${distlib.dir}/antlibs/ant1compat.jar"> | ||||
<metainf dir="${java.dir}/antlibs/ant1compat" | <metainf dir="${java.dir}/antlibs/ant1compat" | ||||
includes="antlib.xml"/> | includes="antlib.xml"/> | ||||
@@ -152,7 +152,7 @@ public class AntLibManager { | |||||
* @param librarySpecs the loaded specifications of the Ant libraries | * @param librarySpecs the loaded specifications of the Ant libraries | ||||
* @param initConfig the Ant initialization configuration | * @param initConfig the Ant initialization configuration | ||||
* @param libraries the collection of libraries already configured | * @param libraries the collection of libraries already configured | ||||
* @param libPathsMap a map of lists of library patsh fro each library | |||||
* @param libPathsMap a map of lists of library paths for each library | |||||
* @exception ExecutionException if a library cannot be configured from | * @exception ExecutionException if a library cannot be configured from | ||||
* the given specification | * the given specification | ||||
*/ | */ | ||||
@@ -231,7 +231,7 @@ public class AntLibManager { | |||||
} | } | ||||
/** | /** | ||||
* add a library path to the given library | |||||
* Add a library path to the given library | |||||
* | * | ||||
* @param antLibrary the library to which the path is to be added | * @param antLibrary the library to which the path is to be added | ||||
* @param path the path to be added | * @param path the path to be added | ||||
@@ -320,11 +320,13 @@ public class AntLibManager { | |||||
antLibrary.setParentLoader(initConfig.getCommonLoader()); | antLibrary.setParentLoader(initConfig.getCommonLoader()); | ||||
libraries.put(libraryId, antLibrary); | libraries.put(libraryId, antLibrary); | ||||
List libPaths = (List) libPathsMap.get(libraryId); | |||||
if (libPaths != null) { | |||||
for (Iterator j = libPaths.iterator(); j.hasNext();) { | |||||
URL pathURL = (URL) j.next(); | |||||
addLibPath(antLibrary, pathURL); | |||||
if (libPathsMap != null) { | |||||
List libPaths = (List) libPathsMap.get(libraryId); | |||||
if (libPaths != null) { | |||||
for (Iterator j = libPaths.iterator(); j.hasNext();) { | |||||
URL pathURL = (URL) j.next(); | |||||
addLibPath(antLibrary, pathURL); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -63,6 +63,7 @@ import java.util.Map; | |||||
import org.apache.ant.common.util.ConfigException; | import org.apache.ant.common.util.ConfigException; | ||||
import org.apache.ant.common.util.PathTokenizer; | import org.apache.ant.common.util.PathTokenizer; | ||||
import org.apache.ant.init.InitUtils; | import org.apache.ant.init.InitUtils; | ||||
import org.apache.ant.common.model.BuildElement; | |||||
/** | /** | ||||
* An AntConfig is the java class representation of the antconfig.xml files | * An AntConfig is the java class representation of the antconfig.xml files | ||||
@@ -72,15 +73,6 @@ import org.apache.ant.init.InitUtils; | |||||
* @created 20 January 2002 | * @created 20 January 2002 | ||||
*/ | */ | ||||
public class AntConfig { | public class AntConfig { | ||||
/** The list of additional directories to be searched for Ant libraries */ | |||||
private List libraryLocations = new ArrayList(); | |||||
/** | |||||
* A list of additional paths for each ant library, indexed on the | |||||
* library id | |||||
*/ | |||||
private Map libPaths = new HashMap(); | |||||
/** Indicates if remote libraries may be used */ | /** Indicates if remote libraries may be used */ | ||||
private boolean remoteLibs = false; | private boolean remoteLibs = false; | ||||
@@ -90,6 +82,11 @@ public class AntConfig { | |||||
/** Indicates if unset properties are ignored */ | /** Indicates if unset properties are ignored */ | ||||
private boolean unsetProperties = true; | private boolean unsetProperties = true; | ||||
/** | |||||
* Configuration tasks. | |||||
*/ | |||||
private List tasks = new ArrayList(); | |||||
/** | /** | ||||
* Indicate if unset properties are OK. | * Indicate if unset properties are OK. | ||||
* | * | ||||
@@ -118,50 +115,21 @@ public class AntConfig { | |||||
} | } | ||||
/** | /** | ||||
* Get the additional locations in which to search for Ant Libraries | |||||
* | |||||
* @return an iterator over the library locations | |||||
*/ | |||||
public Iterator getLibraryLocations() { | |||||
return libraryLocations.iterator(); | |||||
} | |||||
/** | |||||
* Get the list of additional path components for a given path | |||||
* Get the configuration tasks | |||||
* | * | ||||
* @param libraryId the identifier for the library | |||||
* @return the list of URLs for the additional paths for the given | |||||
* library | |||||
* @return an iterator over the set of config tasks. | |||||
*/ | */ | ||||
public List getLibraryPathList(String libraryId) { | |||||
List libraryPathList = (List) libPaths.get(libraryId); | |||||
if (libraryPathList == null) { | |||||
libraryPathList = new ArrayList(); | |||||
libPaths.put(libraryId, libraryPathList); | |||||
} | |||||
return libraryPathList; | |||||
public Iterator getTasks() { | |||||
return tasks.iterator(); | |||||
} | } | ||||
/** | /** | ||||
* Get the map of library paths. This map contains a collection of List | |||||
* instances, indexed by the libraryIds. Each list is a set of | |||||
* additional classpath entries for the given library | |||||
* Add a config task. | |||||
* | * | ||||
* @return the library paths map | |||||
* @param task a task to be executed as part of the configuration process. | |||||
*/ | */ | ||||
public Map getLibraryPathsMap() { | |||||
return libPaths; | |||||
} | |||||
/** | |||||
* Gets the libraryIds of the AntConfig | |||||
* | |||||
* @return an interator over the library identifiers for which there is | |||||
* additional path information | |||||
*/ | |||||
public Iterator getLibraryIds() { | |||||
return libPaths.keySet().iterator(); | |||||
public void addTask(BuildElement task) { | |||||
tasks.add(task); | |||||
} | } | ||||
/** | /** | ||||
@@ -191,88 +159,18 @@ public class AntConfig { | |||||
public void allowUnsetProperties(boolean allowUnsetProperties) { | public void allowUnsetProperties(boolean allowUnsetProperties) { | ||||
this.unsetProperties = allowUnsetProperties; | this.unsetProperties = allowUnsetProperties; | ||||
} | } | ||||
/** | |||||
* Add an additional set of paths for the given library. | |||||
* | |||||
* @param libraryId The library id for which the additional class path | |||||
* is being specified | |||||
* @param libraryPath the classpath style string for the library's | |||||
* additonal paths | |||||
* @exception ConfigException if the appropriate URLs cannot be formed. | |||||
*/ | |||||
public void addLibPath(String libraryId, String libraryPath) | |||||
throws ConfigException { | |||||
try { | |||||
List libraryPathList = getLibraryPathList(libraryId); | |||||
PathTokenizer p = new PathTokenizer(libraryPath); | |||||
while (p.hasMoreTokens()) { | |||||
String pathElement = p.nextToken(); | |||||
File pathElementFile = new File(pathElement); | |||||
URL pathElementURL = InitUtils.getFileURL(pathElementFile); | |||||
libraryPathList.add(pathElementURL); | |||||
} | |||||
} catch (MalformedURLException e) { | |||||
throw new ConfigException("Unable to process libraryPath '" | |||||
+ libraryPath + "' for library '" + libraryId + "'", e); | |||||
} | |||||
} | |||||
/** | |||||
* Add an additional URL for the library's classpath | |||||
* | |||||
* @param libraryId the library's unique Id | |||||
* @param libraryURL a string which points to the additonal path | |||||
* @exception ConfigException if the URL could not be formed | |||||
*/ | |||||
public void addLibURL(String libraryId, String libraryURL) | |||||
throws ConfigException { | |||||
try { | |||||
List libraryPathList = getLibraryPathList(libraryId); | |||||
libraryPathList.add(new URL(libraryURL)); | |||||
} catch (MalformedURLException e) { | |||||
throw new ConfigException("Unable to process libraryURL '" | |||||
+ libraryURL + "' for library '" + libraryId + "'", e); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Merge in another ocnfiguration. The configuration being merged in | |||||
* Merge in another configuration. The configuration being merged in | |||||
* takes precedence | * takes precedence | ||||
* | * | ||||
* @param otherConfig the other AntConfig to be merged. | * @param otherConfig the other AntConfig to be merged. | ||||
*/ | */ | ||||
public void merge(AntConfig otherConfig) { | public void merge(AntConfig otherConfig) { | ||||
// merge by | |||||
List currentLibraryLocations = libraryLocations; | |||||
libraryLocations = new ArrayList(); | |||||
libraryLocations.addAll(otherConfig.libraryLocations); | |||||
libraryLocations.addAll(currentLibraryLocations); | |||||
Iterator i = otherConfig.libPaths.keySet().iterator(); | |||||
while (i.hasNext()) { | |||||
String libraryId = (String) i.next(); | |||||
List currentList = getLibraryPathList(libraryId); | |||||
List combined = new ArrayList(); | |||||
combined.addAll(otherConfig.getLibraryPathList(libraryId)); | |||||
combined.addAll(currentList); | |||||
libPaths.put(libraryId, combined); | |||||
} | |||||
remoteLibs = otherConfig.remoteLibs; | remoteLibs = otherConfig.remoteLibs; | ||||
remoteProjects = otherConfig.remoteProjects; | remoteProjects = otherConfig.remoteProjects; | ||||
unsetProperties = otherConfig.unsetProperties; | unsetProperties = otherConfig.unsetProperties; | ||||
} | |||||
/** | |||||
* Add a new task directory to be searched for additional Ant libraries | |||||
* | |||||
* @param libraryLocation the location (can be a file or a URL) where | |||||
* the libraries may be loaded from. | |||||
*/ | |||||
public void addAntLibraryLocation(String libraryLocation) { | |||||
libraryLocations.add(libraryLocation); | |||||
tasks.addAll(otherConfig.tasks); | |||||
} | } | ||||
} | } | ||||
@@ -54,6 +54,7 @@ | |||||
package org.apache.ant.antcore.config; | package org.apache.ant.antcore.config; | ||||
import org.apache.ant.common.util.ConfigException; | import org.apache.ant.common.util.ConfigException; | ||||
import org.apache.ant.antcore.xml.ElementHandler; | import org.apache.ant.antcore.xml.ElementHandler; | ||||
import org.apache.ant.antcore.modelparser.BuildElementHandler; | |||||
import org.xml.sax.Attributes; | import org.xml.sax.Attributes; | ||||
import org.xml.sax.SAXParseException; | import org.xml.sax.SAXParseException; | ||||
@@ -123,36 +124,17 @@ public class AntConfigHandler extends ElementHandler { | |||||
Attributes attributes) | Attributes attributes) | ||||
throws SAXParseException { | throws SAXParseException { | ||||
try { | |||||
if (qualifiedName.equals("loadlib")) { | |||||
LoadLibHandler loadlibHandler | |||||
= new LoadLibHandler(); | |||||
loadlibHandler.start(getParseContext(), getXMLReader(), | |||||
this, getLocator(), attributes, getElementSource(), | |||||
qualifiedName); | |||||
config.addAntLibraryLocation(loadlibHandler.getLibLocation()); | |||||
} else if (qualifiedName.equals("libpath")) { | |||||
LibPathHandler libPathHandler | |||||
= new LibPathHandler(); | |||||
libPathHandler.start(getParseContext(), getXMLReader(), | |||||
this, getLocator(), attributes, getElementSource(), | |||||
qualifiedName); | |||||
if (libPathHandler.getLibraryPath() != null) { | |||||
config.addLibPath(libPathHandler.getLibraryId(), | |||||
libPathHandler.getLibraryPath()); | |||||
} else { | |||||
config.addLibURL(libPathHandler.getLibraryId(), | |||||
libPathHandler.getLibraryURL()); | |||||
} | |||||
} else { | |||||
super.startElement(uri, localName, qualifiedName, attributes); | |||||
} | |||||
} catch (ConfigException e) { | |||||
throw new SAXParseException("Unable to process config", | |||||
getLocator(), e); | |||||
} | |||||
// everything else is a task | |||||
BuildElementHandler buildElementHandler = new BuildElementHandler(); | |||||
buildElementHandler.start(getParseContext(), getXMLReader(), | |||||
this, getLocator(), attributes, getElementSource(), | |||||
qualifiedName); | |||||
config.addTask(buildElementHandler.getBuildElement()); | |||||
// try { | |||||
// } catch (ConfigException e) { | |||||
// throw new SAXParseException("Unable to process config", | |||||
// getLocator(), e); | |||||
// } | |||||
} | } | ||||
/** | /** | ||||
@@ -1,141 +0,0 @@ | |||||
/* | |||||
* 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.ant.antcore.config; | |||||
import org.apache.ant.antcore.xml.ElementHandler; | |||||
import org.xml.sax.SAXParseException; | |||||
/** | |||||
* An XML Handler for the libpath element in an Ant config file | |||||
* | |||||
* @author Conor MacNeill | |||||
* @created 20 January 2002 | |||||
*/ | |||||
public class LibPathHandler extends ElementHandler { | |||||
/** The library identifier attribute name */ | |||||
public static final String LIBID_ATTR = "libid"; | |||||
/** The path attribute name */ | |||||
public static final String PATH_ATTR = "path"; | |||||
/** The path attribute name */ | |||||
public static final String URL_ATTR = "url"; | |||||
/** | |||||
* Get the libraryId for which the additional path is being defined | |||||
* | |||||
* @return the library's unique id | |||||
*/ | |||||
public String getLibraryId() { | |||||
return getAttribute(LIBID_ATTR); | |||||
} | |||||
/** | |||||
* Get the additional path being defined fro the library | |||||
* | |||||
* @return the libraryPath value, may be null | |||||
*/ | |||||
public String getLibraryPath() { | |||||
return getAttribute(PATH_ATTR); | |||||
} | |||||
/** | |||||
* Get the URL (as a string) containing the additional path for the | |||||
* library. | |||||
* | |||||
* @return the libraryURL value | |||||
*/ | |||||
public String getLibraryURL() { | |||||
return getAttribute(URL_ATTR); | |||||
} | |||||
/** | |||||
* Process the libpath element | |||||
* | |||||
* @param elementName the name of the element | |||||
* @exception SAXParseException if there is a problem parsing the | |||||
* element | |||||
*/ | |||||
public void processElement(String elementName) | |||||
throws SAXParseException { | |||||
if (getLibraryId() == null | |||||
|| (getLibraryPath() == null && getLibraryURL() == null) | |||||
|| (getLibraryPath() != null && getLibraryURL() != null)) { | |||||
throw new SAXParseException("The " + LIBID_ATTR | |||||
+ " attribute and only one of " | |||||
+ PATH_ATTR + " or " + URL_ATTR | |||||
+ " attributes must be specified for a libpath element", | |||||
getLocator()); | |||||
} | |||||
} | |||||
/** | |||||
* Validate that the given attribute and value are valid. | |||||
* | |||||
* @param attributeName The name of the attributes | |||||
* @param attributeValue The value of the attributes | |||||
* @exception SAXParseException if the attribute is not allowed on the | |||||
* element. | |||||
*/ | |||||
protected void validateAttribute(String attributeName, | |||||
String attributeValue) | |||||
throws SAXParseException { | |||||
if (!attributeName.equals(LIBID_ATTR) && | |||||
!attributeName.equals(PATH_ATTR) && | |||||
!attributeName.equals(URL_ATTR)) { | |||||
throwInvalidAttribute(attributeName); | |||||
} | |||||
} | |||||
} | |||||
@@ -1,110 +0,0 @@ | |||||
/* | |||||
* 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.ant.antcore.config; | |||||
import org.apache.ant.antcore.xml.ElementHandler; | |||||
import org.xml.sax.SAXParseException; | |||||
/** | |||||
* An XML handler to handle the loadlib element of an AntConfig file. | |||||
* | |||||
* @author Conor MacNeill | |||||
* @created 20 January 2002 | |||||
*/ | |||||
public class LoadLibHandler extends ElementHandler { | |||||
/** The location attribute name */ | |||||
public static final String LOCATION_ATTR = "location"; | |||||
/** | |||||
* Get the location of the additional search directory | |||||
* | |||||
* @return the additional directory to be searched for Ant libraries. | |||||
*/ | |||||
public String getLibLocation() { | |||||
return getAttribute(LOCATION_ATTR); | |||||
} | |||||
/** | |||||
* Process the loadlibs element | |||||
* | |||||
* @param elementName the name of the element | |||||
* @exception SAXParseException if there is a problem parsing the | |||||
* element | |||||
*/ | |||||
public void processElement(String elementName) | |||||
throws SAXParseException { | |||||
if (getLocation() == null) { | |||||
throw new SAXParseException(LOCATION_ATTR | |||||
+ " must be specified for a taskdir element", getLocator()); | |||||
} | |||||
} | |||||
/** | |||||
* Validate that the given attribute and value are valid. | |||||
* | |||||
* @param attributeName The name of the attributes | |||||
* @param attributeValue The value of the attributes | |||||
* @exception SAXParseException if the attribute is not allowed on the | |||||
* element. | |||||
*/ | |||||
protected void validateAttribute(String attributeName, | |||||
String attributeValue) | |||||
throws SAXParseException { | |||||
if (!attributeName.equals(LOCATION_ATTR)) { | |||||
throwInvalidAttribute(attributeName); | |||||
} | |||||
} | |||||
} | |||||
@@ -79,6 +79,7 @@ import org.apache.ant.common.service.ComponentService; | |||||
import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
import org.apache.ant.common.util.Location; | import org.apache.ant.common.util.Location; | ||||
import org.apache.ant.init.LoaderUtils; | import org.apache.ant.init.LoaderUtils; | ||||
import org.apache.ant.antcore.config.AntConfig; | |||||
/** | /** | ||||
* The instance of the ComponentServices made available by the core to the | * The instance of the ComponentServices made available by the core to the | ||||
@@ -110,7 +111,7 @@ public class ComponentManager implements ComponentService { | |||||
* These are AntLibraries which have been loaded into this component | * These are AntLibraries which have been loaded into this component | ||||
* manager | * manager | ||||
*/ | */ | ||||
private Map antLibraries; | |||||
private Map antLibraries = new HashMap(); | |||||
/** dynamic libraries which have been defined */ | /** dynamic libraries which have been defined */ | ||||
private Map dynamicLibraries; | private Map dynamicLibraries; | ||||
@@ -122,7 +123,7 @@ public class ComponentManager implements ComponentService { | |||||
* This map stores a list of additional paths for each library indexed | * This map stores a list of additional paths for each library indexed | ||||
* by the libraryId | * by the libraryId | ||||
*/ | */ | ||||
private Map libPathsMap; | |||||
private Map libPathsMap = new HashMap(); | |||||
/** Reflector objects used to configure Tasks from the Task models. */ | /** Reflector objects used to configure Tasks from the Task models. */ | ||||
private Map setters = new HashMap(); | private Map setters = new HashMap(); | ||||
@@ -132,17 +133,13 @@ public class ComponentManager implements ComponentService { | |||||
* Constructor | * Constructor | ||||
* | * | ||||
* @param frame the frame containing this context | * @param frame the frame containing this context | ||||
* @param allowRemoteLibs true if remote libraries can be loaded though | |||||
* this service. | |||||
* @param configLibPaths the additional library paths specified in the | |||||
* configuration | |||||
*/ | */ | ||||
protected ComponentManager(Frame frame, boolean allowRemoteLibs, | |||||
Map configLibPaths) { | |||||
protected ComponentManager(Frame frame) { | |||||
this.frame = frame; | this.frame = frame; | ||||
libManager = new AntLibManager(allowRemoteLibs); | |||||
AntConfig config = frame.getConfig(); | |||||
libManager = new AntLibManager(config.isRemoteLibAllowed()); | |||||
dynamicLibraries = new HashMap(); | dynamicLibraries = new HashMap(); | ||||
libPathsMap = new HashMap(configLibPaths); | |||||
libPathsMap = new HashMap(); | |||||
} | } | ||||
/** | /** | ||||
@@ -162,10 +159,11 @@ public class ComponentManager implements ComponentService { | |||||
libManager.configLibraries(frame.getInitConfig(), librarySpecs, | libManager.configLibraries(frame.getInitConfig(), librarySpecs, | ||||
antLibraries, libPathsMap); | antLibraries, libPathsMap); | ||||
if (importAll) { | |||||
Iterator i = librarySpecs.keySet().iterator(); | |||||
while (i.hasNext()) { | |||||
String libraryId = (String) i.next(); | |||||
Iterator i = librarySpecs.keySet().iterator(); | |||||
while (i.hasNext()) { | |||||
String libraryId = (String) i.next(); | |||||
if (importAll | |||||
|| libraryId.startsWith(Constants.ANT_LIB_PREFIX)) { | |||||
importLibrary(libraryId); | importLibrary(libraryId); | ||||
} | } | ||||
} | } | ||||
@@ -345,30 +343,6 @@ public class ComponentManager implements ComponentService { | |||||
componentName, componentName, addTaskAdapter, null); | componentName, componentName, addTaskAdapter, null); | ||||
} | } | ||||
/** | |||||
* Set the standard libraries (i.e. those which are independent of the | |||||
* build files) to be used in this component manager | |||||
* | |||||
* @param standardLibs A collection of AntLibrary objects indexed by | |||||
* their libraryId | |||||
* @exception ExecutionException if the components cannot be imported | |||||
* form the libraries fro which such importing is automatic. | |||||
*/ | |||||
protected void setStandardLibraries(Map standardLibs) | |||||
throws ExecutionException { | |||||
antLibraries = new HashMap(standardLibs); | |||||
// go through the libraries and import all standard ant libraries | |||||
for (Iterator i = antLibraries.keySet().iterator(); i.hasNext();) { | |||||
String libraryId = (String) i.next(); | |||||
if (libraryId.startsWith(Constants.ANT_LIB_PREFIX)) { | |||||
// standard library - import whole library | |||||
importLibrary(libraryId); | |||||
} | |||||
} | |||||
} | |||||
/** | /** | ||||
* Get the collection ov converters currently configured | * Get the collection ov converters currently configured | ||||
* | * | ||||
@@ -65,6 +65,5 @@ public abstract class Constants { | |||||
/** The Ant aspect used to identify Ant metadata */ | /** The Ant aspect used to identify Ant metadata */ | ||||
public static final String ANT_ASPECT = "ant"; | public static final String ANT_ASPECT = "ant"; | ||||
} | } | ||||
@@ -234,30 +234,6 @@ public class CoreExecService implements ExecService { | |||||
} | } | ||||
/** | |||||
* Setup a sub-build. | |||||
* | |||||
* @param properties the initiali properties to be used in the build | |||||
* @param model XXX Description of the Parameter | |||||
* @return Description of the Return Value | |||||
* @exception ExecutionException if the subbuild cannot be run | |||||
*/ | |||||
/* | |||||
public Object setupBuild(File antFile, Map properties) | |||||
throws ExecutionException { | |||||
try { | |||||
// Parse the build file into a project | |||||
XMLProjectParser parser = new XMLProjectParser(); | |||||
Project project | |||||
= parser.parseBuildFile(InitUtils.getFileURL(antFile)); | |||||
return setupBuild(project, properties); | |||||
} catch (MalformedURLException e) { | |||||
throw new ExecutionException(e); | |||||
} catch (XMLParseException e) { | |||||
throw new ExecutionException(e); | |||||
} | |||||
} | |||||
*/ | |||||
/** | /** | ||||
* Setup a sub-build. | * Setup a sub-build. | ||||
* | * | ||||
@@ -77,9 +77,6 @@ import org.apache.ant.init.InitConfig; | |||||
* @created 12 January 2002 | * @created 12 January 2002 | ||||
*/ | */ | ||||
public class ExecutionManager implements DemuxOutputReceiver { | public class ExecutionManager implements DemuxOutputReceiver { | ||||
/** The AntLibraries built from Ant's Populated Task Libraries. */ | |||||
private Map antLibraries = new HashMap(); | |||||
/** BuildEvent support used to fire events and manage listeners */ | /** BuildEvent support used to fire events and manage listeners */ | ||||
private BuildEventSupport eventSupport = new BuildEventSupport(); | private BuildEventSupport eventSupport = new BuildEventSupport(); | ||||
@@ -122,32 +119,6 @@ public class ExecutionManager implements DemuxOutputReceiver { | |||||
* loaded | * loaded | ||||
*/ | */ | ||||
public void init() throws ExecutionException { | public void init() throws ExecutionException { | ||||
Map librarySpecs = new HashMap(10); | |||||
try { | |||||
// start by loading the task libraries | |||||
URL standardLibsURL | |||||
= new URL(initConfig.getLibraryURL(), "antlibs/"); | |||||
AntLibManager libManager | |||||
= new AntLibManager(config.isRemoteLibAllowed()); | |||||
libManager.loadLibs(librarySpecs, standardLibsURL); | |||||
libManager.configLibraries(initConfig, librarySpecs, antLibraries, | |||||
config.getLibraryPathsMap()); | |||||
librarySpecs.clear(); | |||||
// add any additional libraries. | |||||
for (Iterator i = config.getLibraryLocations(); i.hasNext();) { | |||||
// try file first | |||||
String libLocation = (String) i.next(); | |||||
libManager.loadLibs(librarySpecs, libLocation); | |||||
} | |||||
libManager.configLibraries(initConfig, librarySpecs, antLibraries, | |||||
config.getLibraryPathsMap()); | |||||
} catch (MalformedURLException e) { | |||||
throw new ExecutionException("Unable to load Ant libraries", e); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -167,7 +138,7 @@ public class ExecutionManager implements DemuxOutputReceiver { | |||||
// start by validating the project we have been given. | // start by validating the project we have been given. | ||||
project.validate(); | project.validate(); | ||||
mainFrame = new Frame(antLibraries, initConfig, config); | |||||
mainFrame = new Frame(initConfig, config); | |||||
for (Iterator j = eventSupport.getListeners(); j.hasNext();) { | for (Iterator j = eventSupport.getListeners(); j.hasNext();) { | ||||
BuildListener listener = (BuildListener) j.next(); | BuildListener listener = (BuildListener) j.next(); | ||||
mainFrame.addBuildListener(listener); | mainFrame.addBuildListener(listener); | ||||
@@ -54,6 +54,7 @@ | |||||
package org.apache.ant.antcore.execution; | package org.apache.ant.antcore.execution; | ||||
import java.io.File; | import java.io.File; | ||||
import java.net.URL; | import java.net.URL; | ||||
import java.net.MalformedURLException; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -97,6 +98,13 @@ public class Frame implements DemuxOutputReceiver { | |||||
/** The referenced frames corresponding to the referenced projects */ | /** The referenced frames corresponding to the referenced projects */ | ||||
private Map referencedFrames = new HashMap(); | private Map referencedFrames = new HashMap(); | ||||
/** | |||||
* The property overrides for the referenced frames. This map is indexed | |||||
* by the reference names of the frame. Each entry is another Map of | |||||
* property values indexed by their relative name. | |||||
*/ | |||||
private Map overrides = new HashMap(); | |||||
/** | /** | ||||
* The context of this execution. This contains all data object's created | * The context of this execution. This contains all data object's created | ||||
* by tasks that have been executed | * by tasks that have been executed | ||||
@@ -109,12 +117,6 @@ public class Frame implements DemuxOutputReceiver { | |||||
*/ | */ | ||||
private InitConfig initConfig; | private InitConfig initConfig; | ||||
/** | |||||
* These are the standard libraries from which taskdefs, typedefs, etc may | |||||
* be imported. | |||||
*/ | |||||
private Map standardLibs; | |||||
/** BuildEvent support used to fire events and manage listeners */ | /** BuildEvent support used to fire events and manage listeners */ | ||||
private BuildEventSupport eventSupport = new BuildEventSupport(); | private BuildEventSupport eventSupport = new BuildEventSupport(); | ||||
@@ -158,9 +160,8 @@ public class Frame implements DemuxOutputReceiver { | |||||
* @exception ExecutionException if a component of the library cannot be | * @exception ExecutionException if a component of the library cannot be | ||||
* imported | * imported | ||||
*/ | */ | ||||
protected Frame(Map standardLibs, InitConfig initConfig, | |||||
protected Frame(InitConfig initConfig, | |||||
AntConfig config) throws ExecutionException { | AntConfig config) throws ExecutionException { | ||||
this.standardLibs = standardLibs; | |||||
this.config = config; | this.config = config; | ||||
this.initConfig = initConfig; | this.initConfig = initConfig; | ||||
} | } | ||||
@@ -189,11 +190,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
*/ | */ | ||||
protected void setProject(Project project) throws ExecutionException { | protected void setProject(Project project) throws ExecutionException { | ||||
this.project = project; | this.project = project; | ||||
referencedFrames = new HashMap(); | |||||
configureServices(); | |||||
componentManager.setStandardLibraries(standardLibs); | |||||
setMagicProperties(); | |||||
referencedFrames.clear(); | |||||
} | } | ||||
@@ -223,9 +220,10 @@ public class Frame implements DemuxOutputReceiver { | |||||
Frame frame = getContainingFrame(name); | Frame frame = getContainingFrame(name); | ||||
if (frame == null) { | if (frame == null) { | ||||
throw new ExecutionException("There is no project corresponding " | |||||
+ "to the name \"" + name + "\""); | |||||
setOverrideProperty(name, value, mutable); | |||||
return; | |||||
} | } | ||||
if (frame == this) { | if (frame == this) { | ||||
if (dataValues.containsKey(name) && !mutable) { | if (dataValues.containsKey(name) && !mutable) { | ||||
log("Ignoring oveeride for data value " + name, | log("Ignoring oveeride for data value " + name, | ||||
@@ -238,6 +236,104 @@ public class Frame implements DemuxOutputReceiver { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* When a frame has not yet been referenced, this method is used | |||||
* to set the initial properties for the frame when it is introduced. | |||||
* | |||||
* @param name the name of the value | |||||
* @param value the actual value | |||||
* @param mutable if true, existing values can be changed | |||||
* @exception ExecutionException if attempting to override a property in | |||||
* the current frame. | |||||
*/ | |||||
private void setOverrideProperty(String name, Object value, | |||||
boolean mutable) | |||||
throws ExecutionException { | |||||
int refIndex = name.indexOf(Project.REF_DELIMITER); | |||||
if (refIndex == -1) { | |||||
throw new ExecutionException("Property overrides can only be set" | |||||
+ " for properties in referenced projects - not " | |||||
+ name); | |||||
} | |||||
String firstFrameName = name.substring(0, refIndex); | |||||
String relativeName | |||||
= name.substring(refIndex + Project.REF_DELIMITER.length()); | |||||
Map frameOverrides = (Map) overrides.get(firstFrameName); | |||||
if (frameOverrides == null) { | |||||
frameOverrides = new HashMap(); | |||||
overrides.put(firstFrameName, frameOverrides); | |||||
} | |||||
if (mutable || !frameOverrides.containsKey(relativeName)) { | |||||
frameOverrides.put(relativeName, value); | |||||
} | |||||
} | |||||
/** | |||||
* Get a value which exists in the frame property overrides awaiting | |||||
* the frame to be introduced. | |||||
* | |||||
* @param name the name of the value | |||||
* @return the value of the property or null if the property does not | |||||
* exist. | |||||
* @exception ExecutionException if attempting to get an override in | |||||
* the current frame. | |||||
*/ | |||||
private Object getOverrideProperty(String name) throws ExecutionException { | |||||
int refIndex = name.indexOf(Project.REF_DELIMITER); | |||||
if (refIndex == -1) { | |||||
throw new ExecutionException("Property overrides can only be" | |||||
+ " returned for properties in referenced projects - not " | |||||
+ name); | |||||
} | |||||
String firstFrameName = name.substring(0, refIndex); | |||||
String relativeName | |||||
= name.substring(refIndex + Project.REF_DELIMITER.length()); | |||||
Map frameOverrides = (Map) overrides.get(firstFrameName); | |||||
if (frameOverrides == null) { | |||||
return null; | |||||
} | |||||
return frameOverrides.get(relativeName); | |||||
} | |||||
/** | |||||
* Get a value which exists in the frame property overrides awaiting | |||||
* the frame to be introduced. | |||||
* | |||||
* @param name the name of the value | |||||
* @return the value of the property or null if the property does not | |||||
* exist. | |||||
* @exception ExecutionException if attempting to check an override in | |||||
* the current frame. | |||||
*/ | |||||
private boolean isOverrideSet(String name) throws ExecutionException { | |||||
int refIndex = name.indexOf(Project.REF_DELIMITER); | |||||
if (refIndex == -1) { | |||||
throw new ExecutionException("Property overrides can only be" | |||||
+ " returned for properties in referenced projects - not " | |||||
+ name); | |||||
} | |||||
String firstFrameName = name.substring(0, refIndex); | |||||
String relativeName | |||||
= name.substring(refIndex + Project.REF_DELIMITER.length()); | |||||
Map frameOverrides = (Map) overrides.get(firstFrameName); | |||||
if (frameOverrides == null) { | |||||
return false; | |||||
} | |||||
return frameOverrides.containsKey(relativeName); | |||||
} | |||||
/** | /** | ||||
* Set the initial properties to be used when the frame starts execution | * Set the initial properties to be used when the frame starts execution | ||||
@@ -456,8 +552,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
Frame frame = getContainingFrame(name); | Frame frame = getContainingFrame(name); | ||||
if (frame == null) { | if (frame == null) { | ||||
throw new ExecutionException("There is no project corresponding " | |||||
+ "to the name \"" + name + "\""); | |||||
return getOverrideProperty(name); | |||||
} | } | ||||
if (frame == this) { | if (frame == this) { | ||||
return dataValues.get(name); | return dataValues.get(name); | ||||
@@ -480,8 +575,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
Frame frame = getContainingFrame(name); | Frame frame = getContainingFrame(name); | ||||
if (frame == null) { | if (frame == null) { | ||||
throw new ExecutionException("There is no project corresponding " | |||||
+ "to the name \"" + name + "\""); | |||||
return isOverrideSet(name); | |||||
} | } | ||||
if (frame == this) { | if (frame == this) { | ||||
return dataValues.containsKey(name); | return dataValues.containsKey(name); | ||||
@@ -551,6 +645,14 @@ public class Frame implements DemuxOutputReceiver { | |||||
protected void createProjectReference(String name, Project project) | protected void createProjectReference(String name, Project project) | ||||
throws ExecutionException { | throws ExecutionException { | ||||
Frame referencedFrame = createFrame(project); | Frame referencedFrame = createFrame(project); | ||||
// does the frame have any overrides? | |||||
Map initialProperties = (Map) overrides.get(name); | |||||
if (initialProperties != null) { | |||||
referencedFrame.setInitialProperties(initialProperties); | |||||
overrides.remove(name); | |||||
} | |||||
referencedFrames.put(name, referencedFrame); | referencedFrames.put(name, referencedFrame); | ||||
referencedFrame.initialize(); | referencedFrame.initialize(); | ||||
} | } | ||||
@@ -565,7 +667,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
protected Frame createFrame(Project project) | protected Frame createFrame(Project project) | ||||
throws ExecutionException { | throws ExecutionException { | ||||
Frame newFrame | Frame newFrame | ||||
= new Frame(standardLibs, initConfig, config); | |||||
= new Frame(initConfig, config); | |||||
newFrame.setProject(project); | newFrame.setProject(project); | ||||
for (Iterator j = eventSupport.getListeners(); j.hasNext();) { | for (Iterator j = eventSupport.getListeners(); j.hasNext();) { | ||||
@@ -573,6 +675,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
newFrame.addBuildListener(listener); | newFrame.addBuildListener(listener); | ||||
} | } | ||||
return newFrame; | return newFrame; | ||||
} | } | ||||
@@ -840,11 +943,27 @@ public class Frame implements DemuxOutputReceiver { | |||||
* failed | * failed | ||||
*/ | */ | ||||
protected void initialize() throws ExecutionException { | protected void initialize() throws ExecutionException { | ||||
configureServices(); | |||||
setMagicProperties(); | |||||
determineBaseDir(); | determineBaseDir(); | ||||
Iterator taskIterator = project.getTasks(); | |||||
executeTasks(taskIterator); | |||||
try { | |||||
// load system ant lib | |||||
URL systemLibs | |||||
= new URL(initConfig.getLibraryURL(), "syslibs/"); | |||||
componentManager.loadLib(systemLibs.toString(), true); | |||||
// execute any config tasks | |||||
executeTasks(config.getTasks()); | |||||
// now load other system libraries | |||||
URL antLibs = new URL(initConfig.getLibraryURL(), "antlibs/"); | |||||
componentManager.loadLib(antLibs.toString(), false); | |||||
executeTasks(project.getTasks()); | |||||
} catch (MalformedURLException e) { | |||||
throw new ExecutionException("Unable to initialize antlibs", e); | |||||
} | |||||
} | } | ||||
@@ -888,8 +1007,7 @@ public class Frame implements DemuxOutputReceiver { | |||||
private void configureServices() { | private void configureServices() { | ||||
// create services and make them available in our services map | // create services and make them available in our services map | ||||
fileService = new CoreFileService(this); | fileService = new CoreFileService(this); | ||||
componentManager = new ComponentManager(this, | |||||
config.isRemoteLibAllowed(), config.getLibraryPathsMap()); | |||||
componentManager = new ComponentManager(this); | |||||
dataService = new CoreDataService(this, | dataService = new CoreDataService(this, | ||||
config.isUnsetPropertiesAllowed()); | config.isUnsetPropertiesAllowed()); | ||||
execService = new CoreExecService(this); | execService = new CoreExecService(this); | ||||
@@ -38,6 +38,7 @@ | |||||
<taskdef name="dependset" classname="org.apache.tools.ant.taskdefs.DependSet"/> | <taskdef name="dependset" classname="org.apache.tools.ant.taskdefs.DependSet"/> | ||||
<taskdef name="ear" classname="org.apache.tools.ant.taskdefs.Ear"/> | <taskdef name="ear" classname="org.apache.tools.ant.taskdefs.Ear"/> | ||||
<taskdef name="echo" classname="org.apache.tools.ant.taskdefs.Echo"/> | <taskdef name="echo" classname="org.apache.tools.ant.taskdefs.Echo"/> | ||||
<taskdef name="echoproperties" classname="org.apache.tools.ant.taskdefs.optional.EchoProperties"/> | |||||
<taskdef name="ejbc" classname="org.apache.tools.ant.taskdefs.optional.ejb.Ejbc"/> | <taskdef name="ejbc" classname="org.apache.tools.ant.taskdefs.optional.ejb.Ejbc"/> | ||||
<taskdef name="ejbjar" classname="org.apache.tools.ant.taskdefs.optional.ejb.EjbJar"/> | <taskdef name="ejbjar" classname="org.apache.tools.ant.taskdefs.optional.ejb.EjbJar"/> | ||||
<taskdef name="exec" classname="org.apache.tools.ant.taskdefs.ExecTask"/> | <taskdef name="exec" classname="org.apache.tools.ant.taskdefs.ExecTask"/> | ||||
@@ -107,6 +108,7 @@ | |||||
<taskdef name="sosget" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSGet"/> | <taskdef name="sosget" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSGet"/> | ||||
<taskdef name="soslabel" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSLabel"/> | <taskdef name="soslabel" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSLabel"/> | ||||
<taskdef name="sound" classname="org.apache.tools.ant.taskdefs.optional.sound.SoundTask"/> | <taskdef name="sound" classname="org.apache.tools.ant.taskdefs.optional.sound.SoundTask"/> | ||||
<taskdef name="splash" classname="org.apache.tools.ant.taskdefs.optional.splash.SplashTask"/> | |||||
<taskdef name="sql" classname="org.apache.tools.ant.taskdefs.SQLExec"/> | <taskdef name="sql" classname="org.apache.tools.ant.taskdefs.SQLExec"/> | ||||
<taskdef name="stcheckin" classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckin"/> | <taskdef name="stcheckin" classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckin"/> | ||||
<taskdef name="stcheckout" classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckout"/> | <taskdef name="stcheckout" classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckout"/> | ||||
@@ -155,9 +157,13 @@ | |||||
<typedef name="filelist" classname="org.apache.tools.ant.types.FileList"/> | <typedef name="filelist" classname="org.apache.tools.ant.types.FileList"/> | ||||
<typedef name="patternset" classname="org.apache.tools.ant.types.PatternSet"/> | <typedef name="patternset" classname="org.apache.tools.ant.types.PatternSet"/> | ||||
<typedef name="mapper" classname="org.apache.tools.ant.types.Mapper"/> | <typedef name="mapper" classname="org.apache.tools.ant.types.Mapper"/> | ||||
<typedef name="filterchain" classname="org.apache.tools.ant.types.FilterChain"/> | |||||
<typedef name="filterreader" classname="org.apache.tools.ant.types.AntFilterReader"/> | |||||
<typedef name="filterset" classname="org.apache.tools.ant.types.FilterSet"/> | <typedef name="filterset" classname="org.apache.tools.ant.types.FilterSet"/> | ||||
<typedef name="description" classname="org.apache.tools.ant.types.Description"/> | <typedef name="description" classname="org.apache.tools.ant.types.Description"/> | ||||
<typedef name="classfileset" classname="org.apache.tools.ant.types.optional.depend.ClassfileSet"/> | <typedef name="classfileset" classname="org.apache.tools.ant.types.optional.depend.ClassfileSet"/> | ||||
<typedef name="substitution" classname="org.apache.tools.ant.types.Substitution"/> | <typedef name="substitution" classname="org.apache.tools.ant.types.Substitution"/> | ||||
<typedef name="regexp" classname="org.apache.tools.ant.types.RegularExpression"/> | |||||
<typedef name="regularexpression" classname="org.apache.tools.ant.types.RegularExpression"/> | <typedef name="regularexpression" classname="org.apache.tools.ant.types.RegularExpression"/> | ||||
<typedef name="xmlcatalog" classname="org.apache.tools.ant.types.XMLCatalog"/> | |||||
</antlib> | </antlib> |
@@ -53,14 +53,8 @@ | |||||
*/ | */ | ||||
package org.apache.ant.antlib.system; | package org.apache.ant.antlib.system; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import org.apache.ant.common.antlib.AbstractComponent; | |||||
import org.apache.ant.common.antlib.AbstractTask; | |||||
import org.apache.ant.common.antlib.AntContext; | |||||
import org.apache.ant.common.service.DataService; | |||||
import org.apache.ant.common.service.ExecService; | |||||
import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
/** | /** | ||||
@@ -69,154 +63,8 @@ import org.apache.ant.common.util.ExecutionException; | |||||
* @author Conor MacNeill | * @author Conor MacNeill | ||||
* @created 4 February 2002 | * @created 4 February 2002 | ||||
*/ | */ | ||||
public abstract class AntBase extends AbstractTask { | |||||
public abstract class AntBase extends SubBuild { | |||||
/** | |||||
* Simple Property value storing class | |||||
* | |||||
* @author Conor MacNeill | |||||
* @created 5 February 2002 | |||||
*/ | |||||
public static class Property extends AbstractComponent { | |||||
/** The property name */ | |||||
private String name; | |||||
/** The property value */ | |||||
private String value; | |||||
/** | |||||
* Gets the name of the Property | |||||
* | |||||
* @return the name value | |||||
*/ | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
/** | |||||
* Gets the value of the Property | |||||
* | |||||
* @return the value value | |||||
*/ | |||||
public String getValue() { | |||||
return value; | |||||
} | |||||
/** | |||||
* Sets the name of the Property | |||||
* | |||||
* @param name the new name value | |||||
*/ | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
/** | |||||
* Sets the value of the Property | |||||
* | |||||
* @param value the new value value | |||||
*/ | |||||
public void setValue(String value) { | |||||
this.value = value; | |||||
} | |||||
/** | |||||
* Validate this data type instance | |||||
* | |||||
* @exception ExecutionException if either attribute has not been set | |||||
*/ | |||||
public void validateComponent() throws ExecutionException { | |||||
if (name == null) { | |||||
throw new ExecutionException("\"name\" attribute of " | |||||
+ "<property> must be supplied"); | |||||
} | |||||
if (value == null) { | |||||
throw new ExecutionException("\"value\" attribute of " | |||||
+ "<property> must be supplied"); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* A simple class to store information about references being passed | |||||
* | |||||
* @author Conor MacNeill | |||||
* @created 5 February 2002 | |||||
*/ | |||||
public static class Reference extends AbstractComponent { | |||||
/** The id of the reference to be passed */ | |||||
private String refId; | |||||
/** The id to be used in the sub-build for this reference */ | |||||
private String toId; | |||||
/** | |||||
* Gets the refId of the Reference | |||||
* | |||||
* @return the refId value | |||||
*/ | |||||
public String getRefId() { | |||||
return refId; | |||||
} | |||||
/** | |||||
* Gets the toId of the Reference | |||||
* | |||||
* @return the toId value | |||||
*/ | |||||
public String getToId() { | |||||
return toId; | |||||
} | |||||
/** | |||||
* Sets the refId of the Reference | |||||
* | |||||
* @param refId the new refId value | |||||
*/ | |||||
public void setRefId(String refId) { | |||||
this.refId = refId; | |||||
} | |||||
/** | |||||
* Sets the toId of the Reference | |||||
* | |||||
* @param toId the new toId value | |||||
*/ | |||||
public void setToId(String toId) { | |||||
this.toId = toId; | |||||
} | |||||
/** | |||||
* Validate this data type instance | |||||
* | |||||
* @exception ExecutionException if the refid attribute has not been | |||||
* set | |||||
*/ | |||||
public void validateComponent() throws ExecutionException { | |||||
if (refId == null) { | |||||
throw new ExecutionException("\"refid\" attribute of " | |||||
+ "<reference> must be supplied"); | |||||
} | |||||
} | |||||
} | |||||
/** The core's data service for manipulating the properties */ | |||||
private DataService dataService; | |||||
/** The core's ExecutionService for running builds and external programs */ | |||||
private ExecService execService; | |||||
/** | /** | ||||
* flag which indicates if all current properties should be passed to the | * flag which indicates if all current properties should be passed to the | ||||
* subbuild | * subbuild | ||||
@@ -229,9 +77,6 @@ public abstract class AntBase extends AbstractTask { | |||||
*/ | */ | ||||
private boolean inheritRefs = false; | private boolean inheritRefs = false; | ||||
/** The properties which will be passed to the sub-build */ | |||||
private Map properties = new HashMap(); | |||||
/** | /** | ||||
* The key to the subbuild with which the Ant task can manage the subbuild | * The key to the subbuild with which the Ant task can manage the subbuild | ||||
*/ | */ | ||||
@@ -240,51 +85,6 @@ public abstract class AntBase extends AbstractTask { | |||||
/** The name of the target to be evaluated in the sub-build */ | /** The name of the target to be evaluated in the sub-build */ | ||||
private String targetName; | private String targetName; | ||||
/** | |||||
* Add a property to be passed to the subbuild | |||||
* | |||||
* @param property descriptor for the property to be passed | |||||
*/ | |||||
public void addProperty(Property property) { | |||||
properties.put(property.getName(), property.getValue()); | |||||
} | |||||
/** | |||||
* Add a reference to be passed | |||||
* | |||||
* @param reference the descriptor of the reference to be passed | |||||
* @exception ExecutionException if the reference does not reference a | |||||
* valid object | |||||
*/ | |||||
public void addReference(Reference reference) throws ExecutionException { | |||||
String refId = reference.getRefId(); | |||||
if (!dataService.isDataValueSet(refId)) { | |||||
throw new ExecutionException("RefId \"" + refId + "\" is not set"); | |||||
} | |||||
Object value = dataService.getDataValue(refId); | |||||
String toId = reference.getToId(); | |||||
if (toId == null) { | |||||
toId = refId; | |||||
} | |||||
properties.put(toId, value); | |||||
} | |||||
/** | |||||
* Get the core's execution service | |||||
* | |||||
* @return the core's execution service. | |||||
*/ | |||||
protected ExecService getExecService() { | |||||
return execService; | |||||
} | |||||
/** | /** | ||||
* Get the properties to be used with the sub-build | * Get the properties to be used with the sub-build | ||||
* | * | ||||
@@ -292,13 +92,13 @@ public abstract class AntBase extends AbstractTask { | |||||
*/ | */ | ||||
protected Map getProperties() { | protected Map getProperties() { | ||||
if (!inheritAll) { | if (!inheritAll) { | ||||
return properties; | |||||
return super.getProperties(); | |||||
} | } | ||||
// need to combine existing properties with new ones | // need to combine existing properties with new ones | ||||
Map subBuildProperties = dataService.getAllProperties(); | |||||
Map subBuildProperties = getDataService().getAllProperties(); | |||||
subBuildProperties.putAll(properties); | |||||
subBuildProperties.putAll(super.getProperties()); | |||||
return subBuildProperties; | return subBuildProperties; | ||||
} | } | ||||
@@ -331,7 +131,7 @@ public abstract class AntBase extends AbstractTask { | |||||
if (subbuildKey == null) { | if (subbuildKey == null) { | ||||
super.handleSystemErr(line); | super.handleSystemErr(line); | ||||
} else { | } else { | ||||
execService.handleBuildOutput(subbuildKey, line, true); | |||||
getExecService().handleBuildOutput(subbuildKey, line, true); | |||||
} | } | ||||
} | } | ||||
@@ -349,28 +149,11 @@ public abstract class AntBase extends AbstractTask { | |||||
if (subbuildKey == null) { | if (subbuildKey == null) { | ||||
super.handleSystemOut(line); | super.handleSystemOut(line); | ||||
} else { | } else { | ||||
execService.handleBuildOutput(subbuildKey, line, false); | |||||
getExecService().handleBuildOutput(subbuildKey, line, false); | |||||
} | } | ||||
} | } | ||||
/** | |||||
* Initialise this task | |||||
* | |||||
* @param context core's context | |||||
* @param componentType the component type of this component (i.e its | |||||
* defined name in the build file) | |||||
* @exception ExecutionException if we can't access the data service | |||||
*/ | |||||
public void init(AntContext context, String componentType) | |||||
throws ExecutionException { | |||||
super.init(context, componentType); | |||||
dataService = (DataService) getCoreService(DataService.class); | |||||
execService = (ExecService) getCoreService(ExecService.class); | |||||
} | |||||
/** | /** | ||||
* Indicate if all properties should be passed | * Indicate if all properties should be passed | ||||
* | * | ||||
@@ -392,17 +175,6 @@ public abstract class AntBase extends AbstractTask { | |||||
} | } | ||||
/** | |||||
* Set a property for the subbuild | |||||
* | |||||
* @param propertyName the property name | |||||
* @param propertyValue the value of the property | |||||
*/ | |||||
protected void setProperty(String propertyName, Object propertyValue) { | |||||
properties.put(propertyName, propertyValue); | |||||
} | |||||
/** | /** | ||||
* Set the key of the subbuild | * Set the key of the subbuild | ||||
* | * | ||||
@@ -60,6 +60,7 @@ import org.apache.ant.common.antlib.AbstractTask; | |||||
import org.apache.ant.common.antlib.AntContext; | import org.apache.ant.common.antlib.AntContext; | ||||
import org.apache.ant.common.service.ComponentService; | import org.apache.ant.common.service.ComponentService; | ||||
import org.apache.ant.common.util.ExecutionException; | import org.apache.ant.common.util.ExecutionException; | ||||
import org.apache.ant.common.event.MessageLevel; | |||||
import org.apache.ant.init.InitUtils; | import org.apache.ant.init.InitUtils; | ||||
/** | /** | ||||
@@ -153,6 +154,8 @@ public class LibPath extends AbstractTask { | |||||
AntContext context = getAntContext(); | AntContext context = getAntContext(); | ||||
ComponentService componentService = (ComponentService) | ComponentService componentService = (ComponentService) | ||||
context.getCoreService(ComponentService.class); | context.getCoreService(ComponentService.class); | ||||
log("Adding lib path " + url + " for " + libraryId, | |||||
MessageLevel.MSG_DEBUG); | |||||
componentService.addLibPath(libraryId, url); | componentService.addLibPath(libraryId, url); | ||||
} | } | ||||
@@ -0,0 +1,313 @@ | |||||
/* | |||||
* 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.ant.antlib.system; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
import org.apache.ant.common.antlib.AbstractComponent; | |||||
import org.apache.ant.common.antlib.AbstractTask; | |||||
import org.apache.ant.common.antlib.AntContext; | |||||
import org.apache.ant.common.service.DataService; | |||||
import org.apache.ant.common.service.ExecService; | |||||
import org.apache.ant.common.util.ExecutionException; | |||||
/** | |||||
* Common Base class all tasks that can pass references and property overrides | |||||
* to a subbuild | |||||
* | |||||
* @author Conor MacNeill | |||||
* @created 22 April 2002 | |||||
*/ | |||||
public abstract class SubBuild extends AbstractTask { | |||||
/** | |||||
* Simple Property value storing class | |||||
* | |||||
* @author Conor MacNeill | |||||
* @created 5 February 2002 | |||||
*/ | |||||
public static class Property extends AbstractComponent { | |||||
/** The property name */ | |||||
private String name; | |||||
/** The property value */ | |||||
private String value; | |||||
/** | |||||
* Gets the name of the Property | |||||
* | |||||
* @return the name value | |||||
*/ | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
/** | |||||
* Gets the value of the Property | |||||
* | |||||
* @return the value value | |||||
*/ | |||||
public String getValue() { | |||||
return value; | |||||
} | |||||
/** | |||||
* Sets the name of the Property | |||||
* | |||||
* @param name the new name value | |||||
*/ | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
/** | |||||
* Sets the value of the Property | |||||
* | |||||
* @param value the new value value | |||||
*/ | |||||
public void setValue(String value) { | |||||
this.value = value; | |||||
} | |||||
/** | |||||
* Validate this data type instance | |||||
* | |||||
* @exception ExecutionException if either attribute has not been set | |||||
*/ | |||||
public void validateComponent() throws ExecutionException { | |||||
if (name == null) { | |||||
throw new ExecutionException("\"name\" attribute of " | |||||
+ "<property> must be supplied"); | |||||
} | |||||
if (value == null) { | |||||
throw new ExecutionException("\"value\" attribute of " | |||||
+ "<property> must be supplied"); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* A simple class to store information about references being passed | |||||
* | |||||
* @author Conor MacNeill | |||||
* @created 5 February 2002 | |||||
*/ | |||||
public static class Reference extends AbstractComponent { | |||||
/** The id of the reference to be passed */ | |||||
private String refId; | |||||
/** The id to be used in the sub-build for this reference */ | |||||
private String toId; | |||||
/** | |||||
* Gets the refId of the Reference | |||||
* | |||||
* @return the refId value | |||||
*/ | |||||
public String getRefId() { | |||||
return refId; | |||||
} | |||||
/** | |||||
* Gets the toId of the Reference | |||||
* | |||||
* @return the toId value | |||||
*/ | |||||
public String getToId() { | |||||
return toId; | |||||
} | |||||
/** | |||||
* Sets the refId of the Reference | |||||
* | |||||
* @param refId the new refId value | |||||
*/ | |||||
public void setRefId(String refId) { | |||||
this.refId = refId; | |||||
} | |||||
/** | |||||
* Sets the toId of the Reference | |||||
* | |||||
* @param toId the new toId value | |||||
*/ | |||||
public void setToId(String toId) { | |||||
this.toId = toId; | |||||
} | |||||
/** | |||||
* Validate this data type instance | |||||
* | |||||
* @exception ExecutionException if the refid attribute has not been | |||||
* set | |||||
*/ | |||||
public void validateComponent() throws ExecutionException { | |||||
if (refId == null) { | |||||
throw new ExecutionException("\"refid\" attribute of " | |||||
+ "<reference> must be supplied"); | |||||
} | |||||
} | |||||
} | |||||
/** The core's data service for manipulating the properties */ | |||||
private DataService dataService; | |||||
/** The core's ExecutionService for running builds and external programs */ | |||||
private ExecService execService; | |||||
/** The properties which will be passed to the sub-build */ | |||||
private Map properties = new HashMap(); | |||||
/** | |||||
* Add a property to be passed to the subbuild | |||||
* | |||||
* @param property descriptor for the property to be passed | |||||
*/ | |||||
public void addProperty(Property property) { | |||||
properties.put(property.getName(), property.getValue()); | |||||
} | |||||
/** | |||||
* Add a reference to be passed | |||||
* | |||||
* @param reference the descriptor of the reference to be passed | |||||
* @exception ExecutionException if the reference does not reference a | |||||
* valid object | |||||
*/ | |||||
public void addReference(Reference reference) throws ExecutionException { | |||||
String refId = reference.getRefId(); | |||||
if (!dataService.isDataValueSet(refId)) { | |||||
throw new ExecutionException("RefId \"" + refId + "\" is not set"); | |||||
} | |||||
Object value = dataService.getDataValue(refId); | |||||
String toId = reference.getToId(); | |||||
if (toId == null) { | |||||
toId = refId; | |||||
} | |||||
properties.put(toId, value); | |||||
} | |||||
/** | |||||
* Get the core's execution service | |||||
* | |||||
* @return the core's execution service. | |||||
*/ | |||||
protected ExecService getExecService() { | |||||
return execService; | |||||
} | |||||
/** | |||||
* Get the core's date service | |||||
* | |||||
* @return the core's data service. | |||||
*/ | |||||
protected DataService getDataService() { | |||||
return dataService; | |||||
} | |||||
/** | |||||
* Get the properties to be used with the sub-build | |||||
* | |||||
* @return the properties the sub-build will start with | |||||
*/ | |||||
protected Map getProperties() { | |||||
return properties; | |||||
} | |||||
/** | |||||
* Initialise this task | |||||
* | |||||
* @param context core's context | |||||
* @param componentType the component type of this component (i.e its | |||||
* defined name in the build file) | |||||
* @exception ExecutionException if we can't access the data service | |||||
*/ | |||||
public void init(AntContext context, String componentType) | |||||
throws ExecutionException { | |||||
super.init(context, componentType); | |||||
dataService = (DataService) getCoreService(DataService.class); | |||||
execService = (ExecService) getCoreService(ExecService.class); | |||||
} | |||||
/** | |||||
* Set a property for the subbuild | |||||
* | |||||
* @param propertyName the property name | |||||
* @param propertyValue the value of the property | |||||
*/ | |||||
protected void setProperty(String propertyName, Object propertyValue) { | |||||
properties.put(propertyName, propertyValue); | |||||
} | |||||
} | |||||
@@ -25,7 +25,7 @@ public class Ant1CompatBuilder { | |||||
"${lib.dir}/ant1compat", "*.jar"); | "${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.jar"); | |||||
helper.addPathElementToPath("classpath", "${distlib.dir}/syslibs/system.jar"); | |||||
} | } | ||||
protected void check_for_optional_packages(BuildHelper helper) { | protected void check_for_optional_packages(BuildHelper helper) { | ||||
} | } | ||||
@@ -36,6 +36,7 @@ public class Ant1CompatBuilder { | |||||
helper.javac("${bin.dir}/ant1src_copy:${java.dir}/antlibs/ant1compat", "${bin.dir}/ant1compat", "classpath"); | helper.javac("${bin.dir}/ant1src_copy:${java.dir}/antlibs/ant1compat", "${bin.dir}/ant1compat", "classpath"); | ||||
helper.copyFileset("${bin.dir}/ant1src_copy", "${bin.dir}/ant1compat"); | helper.copyFileset("${bin.dir}/ant1src_copy", "${bin.dir}/ant1compat"); | ||||
helper.copyFileset("${ant1etc.dir}", "${bin.dir}/ant1compat/${optional.package}/junit/xsl"); | helper.copyFileset("${ant1etc.dir}", "${bin.dir}/ant1compat/${optional.package}/junit/xsl"); | ||||
helper.mkdir("${distlib.dir}/antlibs/"); | |||||
helper.jar("${bin.dir}/ant1compat", "${distlib.dir}/antlibs/ant1compat.jar", | helper.jar("${bin.dir}/ant1compat", "${distlib.dir}/antlibs/ant1compat.jar", | ||||
"${java.dir}/antlibs/ant1compat", "antlib.xml", null, null); | "${java.dir}/antlibs/ant1compat", "antlib.xml", null, null); | ||||
} | } | ||||
@@ -209,12 +209,7 @@ public class Builder { | |||||
mutantBuilder.antcore(mainBuild); | mutantBuilder.antcore(mainBuild); | ||||
mutantBuilder.start(mainBuild); | mutantBuilder.start(mainBuild); | ||||
mutantBuilder.frontend(mainBuild); | mutantBuilder.frontend(mainBuild); | ||||
BuildHelper systemBuild = new BuildHelper(); | |||||
systemBuild.setProperty("libset", "system"); | |||||
systemBuild.setProperty("dist.dir", "bootstrap"); | |||||
mutantBuilder._init(systemBuild); | |||||
mutantBuilder.build_lib(systemBuild); | |||||
mutantBuilder.systemlib(mainBuild); | |||||
Ant1CompatBuilder ant1Builder = new Ant1CompatBuilder(); | Ant1CompatBuilder ant1Builder = new Ant1CompatBuilder(); | ||||
BuildHelper ant1Build = new BuildHelper(); | BuildHelper ant1Build = new BuildHelper(); | ||||
@@ -78,15 +78,15 @@ public class MutantBuilder { | |||||
} | } | ||||
protected void antlibs(BuildHelper helper) { | protected void antlibs(BuildHelper helper) { | ||||
} | } | ||||
protected void build_lib(BuildHelper helper) { | |||||
helper.mkdir("${bin.dir}/antlibs/${libset}"); | |||||
helper.mkdir("${distlib.dir}/antlibs"); | |||||
protected void systemlib(BuildHelper helper) { | |||||
helper.mkdir("${bin.dir}/antlibs/system"); | |||||
helper.mkdir("${distlib.dir}/syslibs"); | |||||
helper.createPath("classpath.antlibs"); | helper.createPath("classpath.antlibs"); | ||||
helper.addPathElementToPath("classpath.antlibs", "${distlib.dir}/common/common.jar"); | helper.addPathElementToPath("classpath.antlibs", "${distlib.dir}/common/common.jar"); | ||||
helper.addPathToPath("classpath.antlibs", "classpath.common"); | helper.addPathToPath("classpath.antlibs", "classpath.common"); | ||||
helper.javac("${java.dir}/antlibs/${libset}", "${bin.dir}/antlibs/${libset}", "classpath.antlibs"); | |||||
helper.jar("${bin.dir}/antlibs/${libset}", "${distlib.dir}/antlibs/${libset}.jar", | |||||
"${java.dir}/antlibs/${libset}", "antlib.xml", null, null); | |||||
helper.javac("${java.dir}/antlibs/system", "${bin.dir}/antlibs/system", "classpath.antlibs"); | |||||
helper.jar("${bin.dir}/antlibs/system", "${distlib.dir}/syslibs/system.jar", | |||||
"${java.dir}/antlibs/system", "antlib.xml", null, null); | |||||
} | } | ||||
protected void main(BuildHelper helper) { | protected void main(BuildHelper helper) { | ||||
} | } | ||||
@@ -240,6 +240,7 @@ public class LoaderUtils { | |||||
} | } | ||||
if (!location.isDirectory()) { | if (!location.isDirectory()) { | ||||
urls = new URL[1]; | |||||
String path = location.getPath(); | String path = location.getPath(); | ||||
for (int i = 0; i < extensions.length; ++i) { | for (int i = 0; i < extensions.length; ++i) { | ||||
if (path.endsWith(extensions[i])) { | if (path.endsWith(extensions[i])) { | ||||