Upgraded to checkstyle 2.1 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271412 13f79535-47bb-0310-9956-ffa450edef68master
@@ -0,0 +1,4 @@ | |||
bin | |||
dist | |||
bootstrap | |||
@@ -0,0 +1,28 @@ | |||
#!/bin/sh | |||
# Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
# reserved. | |||
# cleanup curretn boot area | |||
rm -rf bin bootstrap | |||
# compile init jar | |||
mkdir -p bin/init | |||
javac -d bin/init src/java/init/org/apache/ant/init/*.java | |||
# compile bootstrap classes | |||
mkdir bin/bootstrap | |||
javac -classpath bin/init -d bin/bootstrap src/java/bootstrap/org/apache/ant/bootstrap/*.java | |||
# compiler builder classes | |||
mkdir bin/builder | |||
javac -classpath bin/init:bin/bootstrap -d bin/builder src/java/bootstrap/org/apache/ant/builder/*.java | |||
# run bootstrap | |||
java -classpath bin/init:bin/bootstrap org.apache.ant.bootstrap.Bootstrap | |||
# run full build using bootstrapped version | |||
java -classpath bootstrap/lib/start.jar:bootstrap/lib/init.jar org.apache.ant.start.Main $* | |||
# Use the full build as the build used by the build script | |||
cp -r dist/* bootstrap |
@@ -0,0 +1,6 @@ | |||
#!/bin/sh | |||
# Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||
# reserved. | |||
java -classpath bootstrap/lib/start.jar:bootstrap/lib/init.jar org.apache.ant.start.Main $* |
@@ -1,4 +1,4 @@ | |||
<project default="main" name="mutant"> | |||
<project default="main" name="Mutant"> | |||
<property name="src.dir" value="src"/> | |||
<property name="lib.dir" value="lib"/> | |||
@@ -103,7 +103,7 @@ | |||
</target> | |||
<target name="ant1compat" depends="common"> | |||
<ant antfile="ant1compat.xml"/> | |||
<ant antfile="build/ant1compat.xml" /> | |||
</target> | |||
<target name="remote" depends="init"> | |||
@@ -130,7 +130,7 @@ | |||
<antcall target="build-lib" inheritall="false"> | |||
<param name="libset" value="system"/> | |||
</antcall> | |||
<ant antfile="script.xml" inheritAll="false"/> | |||
<ant antfile="build/script.xml" inheritAll="false"/> | |||
</target> | |||
<target name="build-lib"> | |||
@@ -174,6 +174,8 @@ | |||
<exclude name="**/org/apache/tools/ant/Task.java"/> | |||
<exclude name="**/org/apache/tools/ant/ProjectComponent.java"/> | |||
<exclude name="**/org/apache/tools/ant/types/DataType.java"/> | |||
<exclude name="**/builder/MutantBuilder.java"/> | |||
<exclude name="**/builder/Ant1CompatBuilder.java"/> | |||
</fileset> | |||
</checkstyle> | |||
<checkstyle maxlinelen="80" | |||
@@ -1,4 +1,4 @@ | |||
<project default="ant1compat" name="mutant Ant 1 compatability library"> | |||
<project default="ant1compat" name="Ant1Compat" basedir=".."> | |||
<property name="src.dir" value="src"/> | |||
<property name="lib.dir" value="lib"/> | |||
@@ -198,8 +198,8 @@ | |||
<classpath refid="classpath"/> | |||
</depend> | |||
<javac destdir="${bin.dir}/ant1compat" | |||
srcdir="${bin.dir}/ant1src;${java.dir}/antlibs/ant1compat" | |||
includeAntRuntime="false" debug="${debug}"> | |||
srcdir="${bin.dir}/ant1src:${java.dir}/antlibs/ant1compat" | |||
debug="${debug}"> | |||
<classpath refid="classpath"/> | |||
<exclude name="${regexp.package}/JakartaRegexp*.java" | |||
unless="jakarta.regexp.present" /> |
@@ -0,0 +1,9 @@ | |||
<project name="mutant-bootstrap" default="main" basedir=".."> | |||
<target name="main"> | |||
<style in="build.xml" out="src/java/bootstrap/org/apache/ant/builder/MutantBuilder.java" | |||
style="build/bootstrap.xsl"/> | |||
<style in="build/ant1compat.xml" out="src/java/bootstrap/org/apache/ant/builder/Ant1CompatBuilder.java" | |||
style="build/bootstrap.xsl"/> | |||
</target> | |||
</project> | |||
@@ -0,0 +1,150 @@ | |||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |||
<xsl:strip-space elements="*"/> | |||
<xsl:output method="text" omit-xml-declaration="yes"/> | |||
<xsl:template match="project"> | |||
<xsl:text>package org.apache.ant.builder; </xsl:text> | |||
<xsl:text>public class </xsl:text> | |||
<xsl:value-of select="attribute::name"/> | |||
<xsl:text>Builder { </xsl:text> | |||
<xsl:text> protected void _init(BuildHelper helper) { </xsl:text> | |||
<xsl:apply-templates select="property"/> | |||
<xsl:apply-templates select="path"/> | |||
<xsl:text> } </xsl:text> | |||
<xsl:apply-templates select="target"/> | |||
<xsl:text>} </xsl:text> | |||
</xsl:template> | |||
<xsl:template match="property"> | |||
<xsl:text> helper.setProperty("</xsl:text> | |||
<xsl:value-of select="attribute::name"/> | |||
<xsl:text>", "</xsl:text> | |||
<xsl:value-of select="attribute::value"/> | |||
<xsl:text>"); </xsl:text> | |||
</xsl:template> | |||
<xsl:template match="path"> | |||
<xsl:text> helper.createPath("</xsl:text> | |||
<xsl:variable name="pathName" select="attribute::id"/> | |||
<xsl:value-of select="$pathName"/> | |||
<xsl:text>"); </xsl:text> | |||
<xsl:for-each select="fileset"> | |||
<xsl:text> </xsl:text> | |||
<xsl:text>helper.addFileSetToPath("</xsl:text> | |||
<xsl:value-of select="$pathName"/> | |||
<xsl:text>", </xsl:text> | |||
<xsl:text> "</xsl:text> | |||
<xsl:value-of select="attribute::dir"/> | |||
<xsl:text>", </xsl:text> | |||
<xsl:choose> | |||
<xsl:when test="attribute::includes"> | |||
<xsl:text>"</xsl:text> | |||
<xsl:value-of select="attribute::includes"/> | |||
<xsl:text>"</xsl:text> | |||
</xsl:when> | |||
<xsl:otherwise> | |||
<xsl:text>null</xsl:text> | |||
</xsl:otherwise> | |||
</xsl:choose> | |||
<xsl:text>); </xsl:text> | |||
</xsl:for-each> | |||
<xsl:for-each select="pathelement"> | |||
<xsl:text> </xsl:text> | |||
<xsl:text>helper.addPathElementToPath("</xsl:text> | |||
<xsl:value-of select="$pathName"/> | |||
<xsl:text>", "</xsl:text> | |||
<xsl:value-of select="attribute::location"/> | |||
<xsl:text>"); </xsl:text> | |||
</xsl:for-each> | |||
<xsl:for-each select="path"> | |||
<xsl:text> </xsl:text> | |||
<xsl:text>helper.addPathToPath("</xsl:text> | |||
<xsl:value-of select="$pathName"/> | |||
<xsl:text>", "</xsl:text> | |||
<xsl:value-of select="attribute::refid"/> | |||
<xsl:text>"); </xsl:text> | |||
</xsl:for-each> | |||
</xsl:template> | |||
<xsl:template match="target"> | |||
<xsl:text> protected void </xsl:text> | |||
<xsl:value-of select="translate(attribute::name, '-', '_')"/> | |||
<xsl:text>(BuildHelper helper) { </xsl:text> | |||
<xsl:apply-templates/> | |||
<xsl:text> } </xsl:text> | |||
</xsl:template> | |||
<xsl:template match="mkdir"> | |||
<xsl:text> helper.mkdir("</xsl:text> | |||
<xsl:value-of select="attribute::dir"/> | |||
<xsl:text>"); </xsl:text> | |||
</xsl:template> | |||
<xsl:template match="javac"> | |||
<xsl:text> helper.javac("</xsl:text> | |||
<xsl:value-of select="attribute::srcdir"/> | |||
<xsl:text>", "</xsl:text> | |||
<xsl:value-of select="attribute::destdir"/> | |||
<xsl:text>", </xsl:text> | |||
<xsl:choose> | |||
<xsl:when test="classpath"> | |||
<xsl:text>"</xsl:text> | |||
<xsl:value-of select="classpath/attribute::refid"/> | |||
<xsl:text>"</xsl:text> | |||
</xsl:when> | |||
<xsl:otherwise> | |||
<xsl:text>null</xsl:text> | |||
</xsl:otherwise> | |||
</xsl:choose> | |||
<xsl:text>); </xsl:text> | |||
</xsl:template> | |||
<xsl:template match="jar"> | |||
<xsl:text> helper.jar("</xsl:text> | |||
<xsl:value-of select="attribute::basedir"/> | |||
<xsl:text>", "</xsl:text> | |||
<xsl:value-of select="attribute::jarfile"/> | |||
<xsl:text>", </xsl:text> | |||
<xsl:choose> | |||
<xsl:when test="metainf"> | |||
<xsl:text>"</xsl:text> | |||
<xsl:value-of select="metainf/attribute::dir"/> | |||
<xsl:text>", </xsl:text> | |||
<xsl:choose> | |||
<xsl:when test="metainf/attribute::includes"> | |||
<xsl:text>"</xsl:text> | |||
<xsl:value-of select="metainf/attribute::includes"/> | |||
<xsl:text>"</xsl:text> | |||
</xsl:when> | |||
<xsl:otherwise> | |||
<xsl:text>null</xsl:text> | |||
</xsl:otherwise> | |||
</xsl:choose> | |||
</xsl:when> | |||
<xsl:otherwise> | |||
<xsl:text>null, null</xsl:text> | |||
</xsl:otherwise> | |||
</xsl:choose> | |||
<xsl:text>); </xsl:text> | |||
</xsl:template> | |||
<xsl:template match="copy/fileset"> | |||
<xsl:choose> | |||
<xsl:when test="attribute::refid"> | |||
<xsl:text> helper.copyFilesetRef("</xsl:text> | |||
<xsl:value-of select="attribute::refid"/> | |||
<xsl:text>", "</xsl:text> | |||
<xsl:value-of select="../attribute::todir"/> | |||
<xsl:text>"); </xsl:text> | |||
</xsl:when> | |||
<xsl:otherwise> | |||
<xsl:text> helper.copyFileset("</xsl:text> | |||
<xsl:value-of select="attribute::dir"/> | |||
<xsl:text>", "</xsl:text> | |||
<xsl:value-of select="../attribute::todir"/> | |||
<xsl:text>"); </xsl:text> | |||
</xsl:otherwise> | |||
</xsl:choose> | |||
</xsl:template> | |||
</xsl:stylesheet> |
@@ -0,0 +1,49 @@ | |||
<project name="build-site" default="docs" basedir="."> | |||
<!-- Initialization properties --> | |||
<property name="project.name" value="mutant"/> | |||
<property name="docs.src" location="xdocs"/> | |||
<property name="docs.dest" location="docs"/> | |||
<property name="project.file" value="stylesheets/project.xml" /> | |||
<property name="site.dir" location="../../../jakarta-site2" /> | |||
<property name="templ.path" location="xdocs/stylesheets" /> | |||
<property name="velocity.props" location="${docs.src}/velocity.properties" /> | |||
<path id="anakia.classpath"> | |||
<fileset dir="${site.dir}/lib"> | |||
<include name="*.jar"/> | |||
</fileset> | |||
</path> | |||
<target name="prepare"> | |||
<available classname="org.apache.velocity.anakia.AnakiaTask" | |||
property="AnakiaTask.present"> | |||
<classpath refid="anakia.classpath"/> | |||
</available> | |||
</target> | |||
<target depends="prepare" name="prepare-error" unless="AnakiaTask.present"> | |||
<echo> | |||
AnakiaTask is not present! Please check to make sure that | |||
velocity.jar is in your classpath. | |||
</echo> | |||
</target> | |||
<target name="docs" depends="prepare-error" if="AnakiaTask.present"> | |||
<taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask"> | |||
<classpath refid="anakia.classpath"/> | |||
</taskdef> | |||
<anakia basedir="${docs.src}" destdir="${docs.dest}/" | |||
extension=".html" style="./site.vsl" | |||
projectFile="${project.file}" | |||
excludes="**/stylesheets/** faq.xml" | |||
includes="**/*.xml" | |||
lastModifiedCheck="true" | |||
templatePath="${templ.path}" | |||
velocityPropertiesFile="${velocity.props}"> | |||
</anakia> | |||
</target> | |||
<target name="all" depends="docs"/> | |||
</project> |
@@ -1,4 +1,4 @@ | |||
<project default="build" name="Ant2 script tasks"> | |||
<project default="build" name="Ant2 script tasks" basedir=".."> | |||
<property name="src.dir" value="src"/> | |||
<property name="lib.dir" value="lib"/> |
@@ -65,24 +65,24 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class AntLibHandler extends ElementHandler { | |||
/** The library identifier attribute name */ | |||
public final static String LIBID_ATTR = "libid"; | |||
public static final String LIBID_ATTR = "libid"; | |||
/** The home attribute name */ | |||
public final static String HOME_ATTR = "home"; | |||
public static final String HOME_ATTR = "home"; | |||
/** | |||
* The name of the attribute which indicates if Ant's XML parser is to | |||
* be made available | |||
*/ | |||
public final static String REQXML_ATTR = "reqxml"; | |||
public static final String REQXML_ATTR = "reqxml"; | |||
/** The extends attribute name */ | |||
public final static String EXTENDS_ATTR = "extends"; | |||
public static final String EXTENDS_ATTR = "extends"; | |||
/** The name of the attribute which indicates tools jar is required */ | |||
public final static String REQTOOLS_ATTR = "reqtools"; | |||
public static final String REQTOOLS_ATTR = "reqtools"; | |||
/** The extends attribute name */ | |||
public final static String ISOLATED_ATTR = "isolated"; | |||
public static final String ISOLATED_ATTR = "isolated"; | |||
/** The list of allowed Attributes */ | |||
public final static String[] ALLOWED_ATTRIBUTES | |||
public static final String[] ALLOWED_ATTRIBUTES | |||
= {LIBID_ATTR, HOME_ATTR, REQXML_ATTR, REQTOOLS_ATTR, | |||
EXTENDS_ATTR, ISOLATED_ATTR}; | |||
@@ -78,7 +78,7 @@ import org.apache.ant.init.LoaderUtils; | |||
public class AntLibManager { | |||
/** The list of extensions which are examined for ant libraries */ | |||
public final static String[] ANTLIB_EXTENSIONS | |||
public static final String[] ANTLIB_EXTENSIONS | |||
= new String[]{".tsk", ".jar", ".zip"}; | |||
/** Flag which indicates whether non-file URLS are used */ | |||
@@ -63,7 +63,7 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class ClassNameHandler extends ElementHandler { | |||
/** The classname attribute name */ | |||
public final static String CLASSNAME_ATTR = "classname"; | |||
public static final String CLASSNAME_ATTR = "classname"; | |||
/** | |||
* Gets the className of the Converter | |||
@@ -64,9 +64,9 @@ import org.apache.ant.common.util.ExecutionException; | |||
*/ | |||
public interface ComponentLibrary { | |||
/** constant indicating a taskdef definition */ | |||
final static int TASKDEF = 1; | |||
public static final int TASKDEF = 1; | |||
/** constant indicating a typedef definition */ | |||
final static int TYPEDEF = 2; | |||
public static final int TYPEDEF = 2; | |||
/** | |||
* Gets the ClassLoader of the AntLibrary | |||
@@ -64,10 +64,10 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class DefinitionHandler extends ElementHandler { | |||
/** The name attribute name */ | |||
public final static String NAME_ATTR = "name"; | |||
public static final String NAME_ATTR = "name"; | |||
/** The classname attribute name */ | |||
public final static String CLASSNAME_ATTR = "classname"; | |||
public static final String CLASSNAME_ATTR = "classname"; | |||
/** the type of the definition */ | |||
private String definitionType; | |||
@@ -65,7 +65,7 @@ import org.apache.ant.common.antlib.AntLibFactory; | |||
*/ | |||
public class DynamicLibrary implements ComponentLibrary { | |||
/** The name profix for naming dynamic libraries */ | |||
public final static String DYNAMIC_LIB_PREFIX = "_internal"; | |||
public static final String DYNAMIC_LIB_PREFIX = "_internal"; | |||
/** A static field used to uniquely name dynamic libraries */ | |||
private static int dynamicIdCounter = 0; | |||
@@ -65,16 +65,16 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class AntConfigHandler extends ElementHandler { | |||
/** The allowRemoteProject attribute name */ | |||
public final static String REMOTE_PROJECT_ATTR = "allow-remote-project"; | |||
public static final String REMOTE_PROJECT_ATTR = "allow-remote-project"; | |||
/** The allowRemoteLibrary attribute name */ | |||
public final static String REMOTE_LIBRARY_ATTR = "allow-remote-library"; | |||
public static final String REMOTE_LIBRARY_ATTR = "allow-remote-library"; | |||
/** The allowReportProject attribute name */ | |||
public final static String UNSET_PROPS_ATTR = "allow-unset-properties"; | |||
public static final String UNSET_PROPS_ATTR = "allow-unset-properties"; | |||
/** The list of allowed Attributes */ | |||
public final static String[] ALLOWED_ATTRIBUTES | |||
public static final String[] ALLOWED_ATTRIBUTES | |||
= {REMOTE_PROJECT_ATTR, REMOTE_LIBRARY_ATTR, UNSET_PROPS_ATTR}; | |||
/** | |||
* The config object which is contructed from the XML representation of | |||
@@ -64,11 +64,11 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class LibPathHandler extends ElementHandler { | |||
/** The library identifier attribute name */ | |||
public final static String LIBID_ATTR = "libid"; | |||
public static final String LIBID_ATTR = "libid"; | |||
/** The path attribute name */ | |||
public final static String PATH_ATTR = "path"; | |||
public static final String PATH_ATTR = "path"; | |||
/** The path attribute name */ | |||
public final static String URL_ATTR = "url"; | |||
public static final String URL_ATTR = "url"; | |||
/** | |||
* Get the libraryId for which the additional path is being defined | |||
@@ -64,7 +64,7 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class LoadLibHandler extends ElementHandler { | |||
/** The location attribute name */ | |||
public final static String LOCATION_ATTR = "location"; | |||
public static final String LOCATION_ATTR = "location"; | |||
/** | |||
* Get the location of the additional search directory | |||
@@ -82,7 +82,7 @@ import org.apache.ant.common.util.ExecutionException; | |||
*/ | |||
public class ComponentManager implements ComponentService { | |||
/** The prefix for library ids that are automatically imported */ | |||
public final static String ANT_LIB_PREFIX = "ant."; | |||
public static final String ANT_LIB_PREFIX = "ant."; | |||
/** | |||
* Type converters for this frame. Converters are used when configuring | |||
@@ -267,6 +267,38 @@ public class ComponentManager implements ComponentService { | |||
addLibraryConverters(library); | |||
} | |||
/** | |||
* Imports a component defined in a nother frame. | |||
* | |||
* @param relativeName the qualified name of the component relative to | |||
* this execution frame | |||
* @param alias the name under which this component will be used in the | |||
* build scripts. If this is null, the components default name is | |||
* used. | |||
* @exception ExecutionException if the component cannot be imported | |||
*/ | |||
public void importFrameComponent(String relativeName, String alias) | |||
throws ExecutionException { | |||
ImportInfo definition | |||
= frame.getReferencedDefinition(relativeName); | |||
if (definition == null) { | |||
throw new ExecutionException("The reference \"relativeName\" does" | |||
+ " not refer to a defined component"); | |||
} | |||
String label = alias; | |||
if (label == null) { | |||
label = frame.getNameInFrame(relativeName); | |||
} | |||
frame.log("Adding referenced component <" + definition.getLocalName() | |||
+ "> as <" + label + "> from library \"" | |||
+ definition.getComponentLibrary().getLibraryId() + "\", class: " | |||
+ definition.getClassName(), MessageLevel.MSG_DEBUG); | |||
definitions.put(label, definition); | |||
} | |||
/** | |||
* Set the standard libraries (i.e. those which are independent of the | |||
* build files) to be used in this component manager | |||
@@ -443,5 +475,6 @@ public class ComponentManager implements ComponentService { | |||
+ className, e); | |||
} | |||
} | |||
} | |||
@@ -82,7 +82,7 @@ public class CoreDataService implements DataService { | |||
* @param allowUnsetProperties true if the reference to an unset | |||
* property should not throw an exception | |||
*/ | |||
public CoreDataService(Frame frame, | |||
protected CoreDataService(Frame frame, | |||
boolean allowUnsetProperties) { | |||
this.frame = frame; | |||
this.allowUnsetProperties = allowUnsetProperties; | |||
@@ -71,7 +71,7 @@ public class CoreEventService implements EventService { | |||
* | |||
* @param frame the frame for which this instance is providing service | |||
*/ | |||
public CoreEventService(Frame frame) { | |||
protected CoreEventService(Frame frame) { | |||
this.frame = frame; | |||
} | |||
@@ -76,7 +76,7 @@ public class CoreFileService implements FileService { | |||
* | |||
* @param frame the frame containing this context | |||
*/ | |||
public CoreFileService(Frame frame) { | |||
protected CoreFileService(Frame frame) { | |||
this.frame = frame; | |||
} | |||
@@ -79,7 +79,7 @@ public class ExecutionContext implements AntContext { | |||
* | |||
* @param frame the frame containing this context | |||
*/ | |||
public ExecutionContext(Frame frame) { | |||
protected ExecutionContext(Frame frame) { | |||
this.frame = frame; | |||
this.eventSupport = frame.getEventSupport(); | |||
} | |||
@@ -89,7 +89,7 @@ public class ExecutionContext implements AntContext { | |||
* | |||
* @param modelElement the model element associated with this context | |||
*/ | |||
public void setModelElement(ModelElement modelElement) { | |||
protected void setModelElement(ModelElement modelElement) { | |||
this.modelElement = modelElement; | |||
} | |||
@@ -94,7 +94,7 @@ import org.apache.ant.init.InitConfig; | |||
*/ | |||
public class Frame { | |||
/** The Ant aspect used to identify Ant metadata */ | |||
public final static String ANT_ASPECT = "ant"; | |||
public static final String ANT_ASPECT = "ant"; | |||
/** the base dir of the project */ | |||
private File baseDir; | |||
@@ -222,8 +222,8 @@ public class Frame { | |||
throws ExecutionException { | |||
Frame frame = getContainingFrame(name); | |||
if (frame == null) { | |||
throw new ExecutionException("There is no project corresponding " | |||
+ "to the name \"" + name + "\""); | |||
throw new ExecutionException("There is no project corresponding " | |||
+ "to the name \"" + name + "\""); | |||
} | |||
if (frame == this) { | |||
if (dataValues.containsKey(name) && !mutable) { | |||
@@ -265,6 +265,31 @@ public class Frame { | |||
initConfig.getAntHome().toString(), true); | |||
} | |||
/** | |||
* Get a definition from a referenced frame | |||
* | |||
* @param definitionName the name of the definition relative to this | |||
* frame | |||
* @return the appropriate import info object from the referenced | |||
* frame's imports | |||
* @exception ExecutionException if the referenced definition cannot be | |||
* found | |||
*/ | |||
protected ImportInfo getReferencedDefinition(String definitionName) | |||
throws ExecutionException { | |||
Frame containingFrame = getContainingFrame(definitionName); | |||
String localName = getNameInFrame(definitionName); | |||
if (containingFrame == null) { | |||
throw new ExecutionException("There is no project corresponding " | |||
+ "to the name \"" + definitionName + "\""); | |||
} | |||
if (containingFrame == this) { | |||
return componentManager.getDefinition(localName); | |||
} else { | |||
return containingFrame.getReferencedDefinition(localName); | |||
} | |||
} | |||
/** | |||
* Gets the project model this frame is working with | |||
* | |||
@@ -404,8 +429,8 @@ public class Frame { | |||
protected Object getDataValue(String name) throws ExecutionException { | |||
Frame frame = getContainingFrame(name); | |||
if (frame == null) { | |||
throw new ExecutionException("There is no project corresponding " | |||
+ "to the name \"" + name + "\""); | |||
throw new ExecutionException("There is no project corresponding " | |||
+ "to the name \"" + name + "\""); | |||
} | |||
if (frame == this) { | |||
return dataValues.get(name); | |||
@@ -426,8 +451,8 @@ public class Frame { | |||
protected boolean isDataValueSet(String name) throws ExecutionException { | |||
Frame frame = getContainingFrame(name); | |||
if (frame == null) { | |||
throw new ExecutionException("There is no project corresponding " | |||
+ "to the name \"" + name + "\""); | |||
throw new ExecutionException("There is no project corresponding " | |||
+ "to the name \"" + name + "\""); | |||
} | |||
if (frame == this) { | |||
return dataValues.containsKey(name); | |||
@@ -436,6 +461,36 @@ public class Frame { | |||
} | |||
} | |||
/** | |||
* Get the execution frame which contains, directly, the named element | |||
* where the name is relative to this frame | |||
* | |||
* @param elementName The name of the element | |||
* @return the execution frame for the project that contains the given | |||
* target | |||
*/ | |||
protected Frame getContainingFrame(String elementName) { | |||
int index = elementName.lastIndexOf(Project.REF_DELIMITER); | |||
if (index == -1) { | |||
return this; | |||
} | |||
Frame currentFrame = this; | |||
String relativeName = elementName.substring(0, index); | |||
StringTokenizer tokenizer | |||
= new StringTokenizer(relativeName, Project.REF_DELIMITER); | |||
while (tokenizer.hasMoreTokens()) { | |||
String refName = tokenizer.nextToken(); | |||
currentFrame = currentFrame.getReferencedFrame(refName); | |||
if (currentFrame == null) { | |||
return null; | |||
} | |||
} | |||
return currentFrame; | |||
} | |||
/** | |||
* Add a collection of properties to this frame | |||
* | |||
@@ -706,36 +761,6 @@ public class Frame { | |||
return setter; | |||
} | |||
/** | |||
* Get the execution frame which contains, directly, the named target | |||
* where the name is relative to this frame | |||
* | |||
* @param targetName The name of the target | |||
* @return the execution frame for the project that contains the given | |||
* target | |||
*/ | |||
private Frame getContainingFrame(String targetName) { | |||
int index = targetName.lastIndexOf(Project.REF_DELIMITER); | |||
if (index == -1) { | |||
return this; | |||
} | |||
Frame currentFrame = this; | |||
String relativeName = targetName.substring(0, index); | |||
StringTokenizer tokenizer | |||
= new StringTokenizer(relativeName, Project.REF_DELIMITER); | |||
while (tokenizer.hasMoreTokens()) { | |||
String refName = tokenizer.nextToken(); | |||
currentFrame = currentFrame.getReferencedFrame(refName); | |||
if (currentFrame == null) { | |||
return null; | |||
} | |||
} | |||
return currentFrame; | |||
} | |||
/** | |||
* Determine the base directory for each frame in the frame hierarchy | |||
* | |||
@@ -964,11 +989,11 @@ public class Frame { | |||
typeInstance = createTypeInstance(nestedType, factory, model, null); | |||
} else { | |||
throw new ExecutionException("The type of the <" | |||
+ nestedElementName + "> nested element is not known. " | |||
+ "Please specify by the type using the \"ant:type\" " | |||
+ "attribute or provide a reference to an instance with " | |||
+ "the \"ant:id\" attribute"); | |||
throw new ExecutionException("The type of the <" | |||
+ nestedElementName + "> nested element is not known. " | |||
+ "Please specify by the type using the \"ant:type\" " | |||
+ "attribute or provide a reference to an instance with " | |||
+ "the \"ant:id\" attribute"); | |||
} | |||
// is the typeInstance compatible with the type expected | |||
@@ -87,7 +87,7 @@ public class TaskContext extends ExecutionContext { | |||
* | |||
* @return the task instance | |||
*/ | |||
public Task getTask() { | |||
protected Task getTask() { | |||
return task; | |||
} | |||
@@ -96,7 +96,7 @@ public class TaskContext extends ExecutionContext { | |||
* | |||
* @return the task's loader | |||
*/ | |||
public ClassLoader getLoader() { | |||
protected ClassLoader getLoader() { | |||
return loader; | |||
} | |||
@@ -108,8 +108,8 @@ public class TaskContext extends ExecutionContext { | |||
* @param modelElement the model element associated with this context | |||
* @exception ExecutionException if the task cannot be initialized | |||
*/ | |||
public void init(ClassLoader loader, Task task, ModelElement modelElement) | |||
throws ExecutionException { | |||
protected void init(ClassLoader loader, Task task, | |||
ModelElement modelElement) throws ExecutionException { | |||
this.task = task; | |||
this.loader = loader; | |||
setModelElement(modelElement); | |||
@@ -122,7 +122,7 @@ public class TaskContext extends ExecutionContext { | |||
* @exception ExecutionException if there is a problem executing the | |||
* task | |||
*/ | |||
public void execute() throws ExecutionException { | |||
protected void execute() throws ExecutionException { | |||
task.execute(); | |||
} | |||
@@ -130,7 +130,7 @@ public class TaskContext extends ExecutionContext { | |||
* Destroy this context. The context can be reused for another task | |||
* after this one | |||
*/ | |||
public void destroy() { | |||
protected void destroy() { | |||
task.destroy(); | |||
task = null; | |||
loader = null; | |||
@@ -69,7 +69,7 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class IncludeHandler extends ElementHandler { | |||
/** The attribute name which identifies the fragment to be included */ | |||
public final static String SYSTEMID_ATTR = "fragment"; | |||
public static final String SYSTEMID_ATTR = "fragment"; | |||
/** The including project */ | |||
private Project project; | |||
@@ -68,13 +68,13 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class ProjectHandler extends ElementHandler { | |||
/** The basedir attribute tag */ | |||
public final static String BASEDIR_ATTR = "basedir"; | |||
public static final String BASEDIR_ATTR = "basedir"; | |||
/** The name attribute */ | |||
public final static String NAME_ATTR = "name"; | |||
public static final String NAME_ATTR = "name"; | |||
/** The default attribute name */ | |||
public final static String DEFAULT_ATTR = "default"; | |||
public static final String DEFAULT_ATTR = "default"; | |||
/** The project being parsed. */ | |||
private Project project; | |||
@@ -70,10 +70,10 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class RefHandler extends ElementHandler { | |||
/** The attribute used to name the ref. */ | |||
public final static String NAME_ATTR = "name"; | |||
public static final String NAME_ATTR = "name"; | |||
/** The attribute name used to locate the project to be referenced. */ | |||
public final static String SYSTEMID_ATTR = "project"; | |||
public static final String SYSTEMID_ATTR = "project"; | |||
/** The project that has been referenced. */ | |||
private Project referencedProject; | |||
@@ -67,19 +67,19 @@ import org.xml.sax.SAXParseException; | |||
*/ | |||
public class TargetHandler extends ElementHandler { | |||
/** The name attribute */ | |||
public final static String NAME_ATTR = "name"; | |||
public static final String NAME_ATTR = "name"; | |||
/** The depends attribute name */ | |||
public final static String DEPENDS_ATTR = "depends"; | |||
public static final String DEPENDS_ATTR = "depends"; | |||
/** The depends attribute name */ | |||
public final static String DESC_ATTR = "description"; | |||
public static final String DESC_ATTR = "description"; | |||
/** The if attribute name */ | |||
public final static String IF_ATTR = "if"; | |||
public static final String IF_ATTR = "if"; | |||
/** The unless attribute name */ | |||
public final static String UNLESS_ATTR = "unless"; | |||
public static final String UNLESS_ATTR = "unless"; | |||
/** The target being configured. */ | |||
private Target target; | |||
@@ -6,6 +6,7 @@ | |||
<converter classname="org.apache.tools.ant.Ant1Converter"/> | |||
<!-- 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"/> | |||
@@ -144,7 +145,14 @@ | |||
<taskdef name="wlstop" classname="org.apache.tools.ant.taskdefs.optional.ejb.WLStop"/> | |||
<taskdef name="xmlvalidate" classname="org.apache.tools.ant.taskdefs.optional.XMLValidateTask"/> | |||
<taskdef name="zip" classname="org.apache.tools.ant.taskdefs.Zip"/> | |||
<!-- Deprecated tasks --> | |||
<taskdef name="copydir" classname="org.apache.tools.ant.taskdefs.Copydir"/> | |||
<taskdef name="copyfile" classname="org.apache.tools.ant.taskdefs.Copyfile"/> | |||
<taskdef name="deltree" classname="org.apache.tools.ant.taskdefs.Deltree"/> | |||
<taskdef name="rename" classname="org.apache.tools.ant.taskdefs.Rename"/> | |||
<!-- typedefs --> | |||
<typedef name="path" classname="org.apache.tools.ant.types.Path"/> | |||
<typedef name="fileset" classname="org.apache.tools.ant.types.FileSet"/> | |||
<typedef name="filelist" classname="org.apache.tools.ant.types.FileList"/> | |||
@@ -83,36 +83,36 @@ import org.apache.tools.ant.util.FileUtils; | |||
public class Project implements org.apache.ant.common.event.BuildListener { | |||
/** String which indicates Java version 1.0 */ | |||
public final static String JAVA_1_0 = "1.0"; | |||
public static final String JAVA_1_0 = "1.0"; | |||
/** String which indicates Java version 1.1 */ | |||
public final static String JAVA_1_1 = "1.1"; | |||
public static final String JAVA_1_1 = "1.1"; | |||
/** String which indicates Java version 1.2 */ | |||
public final static String JAVA_1_2 = "1.2"; | |||
public static final String JAVA_1_2 = "1.2"; | |||
/** String which indicates Java version 1.3 */ | |||
public final static String JAVA_1_3 = "1.3"; | |||
public static final String JAVA_1_3 = "1.3"; | |||
/** String which indicates Java version 1.4 */ | |||
public final static String JAVA_1_4 = "1.4"; | |||
public static final String JAVA_1_4 = "1.4"; | |||
/** | |||
* @see MessageLevel.MSG_ERR | |||
*/ | |||
public final static int MSG_ERR = MessageLevel.MSG_ERR; | |||
public static final int MSG_ERR = MessageLevel.MSG_ERR; | |||
/** | |||
* @see MessageLevel.MSG_WARN | |||
*/ | |||
public final static int MSG_WARN = MessageLevel.MSG_WARN; | |||
public static final int MSG_WARN = MessageLevel.MSG_WARN; | |||
/** | |||
* @see MessageLevel.MSG_INFO | |||
*/ | |||
public final static int MSG_INFO = MessageLevel.MSG_INFO; | |||
public static final int MSG_INFO = MessageLevel.MSG_INFO; | |||
/** | |||
* @see MessageLevel.MSG_VERBOSE | |||
*/ | |||
public final static int MSG_VERBOSE = MessageLevel.MSG_VERBOSE; | |||
public static final int MSG_VERBOSE = MessageLevel.MSG_VERBOSE; | |||
/** | |||
* @see MessageLevel.MSG_DEBUG | |||
*/ | |||
public final static int MSG_DEBUG = MessageLevel.MSG_DEBUG; | |||
public static final int MSG_DEBUG = MessageLevel.MSG_DEBUG; | |||
/** The java version detected that Ant is running on */ | |||
private static String javaVersion; | |||
@@ -69,7 +69,11 @@ public class Import extends AbstractTask { | |||
private String libraryId = null; | |||
/** The name of the component to be imported */ | |||
private String name = null; | |||
/** | |||
* A ref is used to import a task which has been declared in another | |||
* project | |||
*/ | |||
private String ref = null; | |||
/** The alias that is to be used for the name */ | |||
private String alias = null; | |||
@@ -85,16 +89,25 @@ public class Import extends AbstractTask { | |||
/** | |||
* Sets the name of the Import | |||
* | |||
* @param name the new name value | |||
* @param name the new name value | |||
*/ | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
/** | |||
* Set the reference name of a task defined in a referenced frame | |||
* | |||
* @param ref the new ref value | |||
*/ | |||
public void setRef(String ref) { | |||
this.ref = ref; | |||
} | |||
/** | |||
* Sets the alias of the Import | |||
* | |||
* @param alias the new alias value | |||
* @param alias the new alias value | |||
*/ | |||
public void setAlias(String alias) { | |||
this.alias = alias; | |||
@@ -106,13 +119,21 @@ public class Import extends AbstractTask { | |||
* @exception ExecutionException if the task is not configured correctly | |||
*/ | |||
public void validateComponent() throws ExecutionException { | |||
if (libraryId == null) { | |||
throw new ExecutionException("You must specify a library identifier" | |||
+ " with the \"libraryid\" attribute"); | |||
} | |||
if (alias != null && name == null) { | |||
throw new ExecutionException("You may only specify an alias" | |||
+ " when you specify the component name"); | |||
if (ref != null) { | |||
if (libraryId != null || name != null) { | |||
throw new ExecutionException("The \"ref\" attribute can only " | |||
+ "be used when \"libraryId\" and \"name\" attributes are " | |||
+ "not present"); | |||
} | |||
} else { | |||
if (libraryId == null) { | |||
throw new ExecutionException("You must specify a library " | |||
+ "identifier with the \"libraryid\" attribute"); | |||
} | |||
if (alias != null && name == null) { | |||
throw new ExecutionException("You may only specify an alias" | |||
+ " when you specify the \"name\" or \"ref\" attributes"); | |||
} | |||
} | |||
} | |||
@@ -125,7 +146,9 @@ public class Import extends AbstractTask { | |||
AntContext context = getContext(); | |||
ComponentService componentService = (ComponentService) | |||
context.getCoreService(ComponentService.class); | |||
if (name == null) { | |||
if (ref != null) { | |||
componentService.importFrameComponent(ref, alias); | |||
} else if (name == null) { | |||
componentService.importLibrary(libraryId); | |||
} else { | |||
componentService.importComponent(libraryId, name, alias); | |||
@@ -0,0 +1,94 @@ | |||
/* | |||
* 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.bootstrap; | |||
import java.lang.reflect.Method; | |||
import java.net.URL; | |||
import java.net.URLClassLoader; | |||
import org.apache.ant.init.ClassLocator; | |||
/** | |||
* The Bootstrap class initailses the boot strap build, then loads the | |||
* Builder class to perform the bootstrap build. | |||
* | |||
* @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||
* @created 18 February 2002 | |||
*/ | |||
public class Bootstrap { | |||
/** | |||
* The main program - adds tools.jar and runs build | |||
* | |||
* @param args The command line arguments | |||
* @exception Exception if there is a bootstrap problem | |||
*/ | |||
public static void main(String[] args) throws Exception { | |||
System.out.println("Bootstrapping mutant"); | |||
URL bootstrapURL = ClassLocator.getClassLocationURL(Bootstrap.class); | |||
URL builderURL = new URL(bootstrapURL, "../builder/"); | |||
URL toolsJarURL = ClassLocator.getToolsJarURL(); | |||
URL[] urls = new URL[]{builderURL, toolsJarURL}; | |||
ClassLoader builderLoader = new URLClassLoader(urls); | |||
// org.apache.ant.init.LoaderUtils.dumpLoader(System.out, | |||
// builderLoader); | |||
Class builderClass = Class.forName("org.apache.ant.builder.Builder", | |||
true, builderLoader); | |||
final Class[] param = {Class.forName("[Ljava.lang.String;")}; | |||
final Method main = builderClass.getMethod("main", param); | |||
final Object[] argument = {args}; | |||
main.invoke(null, argument); | |||
} | |||
} | |||
@@ -0,0 +1,37 @@ | |||
package org.apache.ant.builder; | |||
public class Ant1CompatBuilder { | |||
protected void _init(BuildHelper helper) { | |||
helper.setProperty("src.dir", "src"); | |||
helper.setProperty("lib.dir", "lib"); | |||
helper.setProperty("java.dir", "${src.dir}/java"); | |||
helper.setProperty("bin.dir", "bin"); | |||
helper.setProperty("dist.dir", "dist"); | |||
helper.setProperty("javadocs.dir", "${dist.dir}/javadocs"); | |||
helper.setProperty("distlib.dir", "${dist.dir}/lib"); | |||
helper.setProperty("debug", "true"); | |||
helper.setProperty("ant.package", "org/apache/tools/ant"); | |||
helper.setProperty("optional.package", "${ant.package}/taskdefs/optional"); | |||
helper.setProperty("optional.type.package", "${ant.package}/types/optional"); | |||
helper.setProperty("util.package", "${ant.package}/util"); | |||
helper.setProperty("regexp.package", "${util.package}/regexp"); | |||
helper.createPath("classpath"); | |||
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}/common/common.jar"); | |||
} | |||
protected void check_for_optional_packages(BuildHelper helper) { | |||
} | |||
protected void ant1compat(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}/ant1src"); | |||
helper.mkdir("${bin.dir}/ant1compat"); | |||
helper.copyFilesetRef("ant1src", "${bin.dir}/ant1src"); | |||
helper.javac("${bin.dir}/ant1src:${java.dir}/antlibs/ant1compat", "${bin.dir}/ant1compat", "classpath"); | |||
helper.copyFileset("${bin.dir}/ant1src", "${bin.dir}/ant1compat"); | |||
helper.jar("${bin.dir}/ant1compat", "${distlib.dir}/antlibs/ant1compat.jar", | |||
"${java.dir}/antlibs/ant1compat", "antlib.xml"); | |||
} | |||
protected void clean(BuildHelper helper) { | |||
} | |||
} |
@@ -0,0 +1,504 @@ | |||
/* | |||
* 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.builder; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.FileOutputStream; | |||
import java.io.FilenameFilter; | |||
import java.io.IOException; | |||
import java.lang.reflect.Method; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.StringTokenizer; | |||
import java.util.jar.JarOutputStream; | |||
import java.util.zip.ZipEntry; | |||
/** | |||
* A helper class which allows the build files which have been converted to | |||
* code to be built. | |||
* | |||
* @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||
* @created 16 February 2002 | |||
*/ | |||
public class BuildHelper { | |||
/** | |||
* Simple data class for storing info about a fileset. | |||
* | |||
* @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||
* @created 18 February 2002 | |||
*/ | |||
private static class FileSetInfo { | |||
/** The root directory of this fileset */ | |||
private File root; | |||
/** the list of files in the file set */ | |||
private File[] files; | |||
} | |||
/** The properties which have been defined in the build */ | |||
private Map properties = new HashMap(); | |||
/** Path objects created in the build */ | |||
private Map paths = new HashMap(); | |||
/** Filesets created in the build */ | |||
private Map filesets = new HashMap(); | |||
/** | |||
* Set a property for the build | |||
* | |||
* @param propertyName the name of the property | |||
* @param propertyValue the value of the property | |||
*/ | |||
protected void setProperty(String propertyName, String propertyValue) { | |||
if (!properties.containsKey(propertyName)) { | |||
String value = resolve(propertyValue); | |||
properties.put(propertyName, value); | |||
} | |||
} | |||
/** | |||
* Create a Jar | |||
* | |||
* @param basedir the base directpory from which files are added to the | |||
* jar | |||
* @param metaInfDir the directory containing the META-INF for the jar | |||
* @param metaInfIncludes the files to be included in the META-INF area | |||
* of the jar | |||
* @param jarFile the file in which the Jar is created | |||
*/ | |||
protected void jar(String basedir, String jarFile, String metaInfDir, | |||
String metaInfIncludes) { | |||
try { | |||
File base = new File(resolve(basedir)); | |||
File jar = new File(resolve(jarFile)); | |||
JarOutputStream jos | |||
= new JarOutputStream(new FileOutputStream(jar)); | |||
addToJar(jos, base, null); | |||
if (metaInfDir != null) { | |||
File[] metaFileSet = buildFileSet(metaInfDir, metaInfIncludes); | |||
addFilesToJar(jos, new File(resolve(metaInfDir)), | |||
metaFileSet, "META-INF"); | |||
} | |||
jos.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
throw new RuntimeException("Unable to Jar file"); | |||
} | |||
} | |||
/** | |||
* Compile a set of files | |||
* | |||
* @param srcDir the source directory | |||
* @param destDir where the compiled classes will go | |||
* @param classpathRef the id of a path object with the classpath for | |||
* the build | |||
*/ | |||
protected void javac(String srcDir, String destDir, String classpathRef) { | |||
List javaFiles = new ArrayList(); | |||
String src = resolve(srcDir); | |||
StringTokenizer tokenizer = new StringTokenizer(src, ":"); | |||
while (tokenizer.hasMoreTokens()) { | |||
File srcLocation = new File(tokenizer.nextToken()); | |||
getJavaFiles(srcLocation, javaFiles); | |||
} | |||
File dest = new File(resolve(destDir)); | |||
int numArgs = javaFiles.size() + 2; | |||
if (classpathRef != null) { | |||
numArgs += 2; | |||
} | |||
String[] args = new String[numArgs]; | |||
int index = 0; | |||
args[index++] = "-d"; | |||
args[index++] = dest.getPath(); | |||
if (classpathRef != null) { | |||
String path = (String)paths.get(resolve(classpathRef)); | |||
args[index++] = "-classpath"; | |||
args[index++] = path; | |||
} | |||
for (Iterator i = javaFiles.iterator(); i.hasNext(); ) { | |||
args[index++] = ((File)i.next()).getPath(); | |||
} | |||
try { | |||
Class c = Class.forName("com.sun.tools.javac.Main"); | |||
Object compiler = c.newInstance(); | |||
Method compile = c.getMethod("compile", | |||
new Class[]{(new String[]{}).getClass()}); | |||
compile.invoke(compiler, new Object[]{args}); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
throw new RuntimeException("Compile failed"); | |||
} | |||
} | |||
/** | |||
* Copy a directory | |||
* | |||
* @param fromDir the source directory name | |||
* @param toDir the destination directory name | |||
*/ | |||
protected void copyFileset(String fromDir, String toDir) { | |||
File from = new File(resolve(fromDir)); | |||
File to = new File(resolve(toDir)); | |||
copyDir(from, to); | |||
} | |||
/** | |||
* Add a fileset to this build helper | |||
* | |||
* @param name the name of the fileset (its id) | |||
* @param root the root directory of the fileset | |||
* @param files the files in the fileset | |||
*/ | |||
protected void addFileSet(String name, File root, File[] files) { | |||
FileSetInfo info = new FileSetInfo(); | |||
info.root = root; | |||
info.files = files; | |||
filesets.put(name, info); | |||
} | |||
/** | |||
* Copy a fileset given a reference to the source fileset | |||
* | |||
* @param toDir the name of the destination directory | |||
* @param fileSetRef the fileset to be copied | |||
*/ | |||
protected void copyFilesetRef(String fileSetRef, String toDir) { | |||
FileSetInfo fileset = (FileSetInfo)filesets.get(resolve(fileSetRef)); | |||
if (fileset != null) { | |||
File to = new File(resolve(toDir)); | |||
copyFileList(fileset.root, fileset.files, to); | |||
} | |||
} | |||
/** | |||
* Make a directory | |||
* | |||
* @param dirName the name of the directory path to be created. | |||
*/ | |||
protected void mkdir(String dirName) { | |||
File dir = new File(resolve(dirName)); | |||
dir.mkdirs(); | |||
} | |||
/** | |||
* Create a path object | |||
* | |||
* @param pathName the name of the path object in the build | |||
*/ | |||
protected void createPath(String pathName) { | |||
String path = ""; | |||
paths.put(pathName, path); | |||
} | |||
/** | |||
* Add a fileset to a path | |||
* | |||
* @param pathName the name of the path | |||
* @param filesetDir the base directory of the fileset | |||
* @param filesetIncludes the files to be included in the fileset | |||
*/ | |||
protected void addFileSetToPath(String pathName, String filesetDir, | |||
String filesetIncludes) { | |||
File[] files = buildFileSet(filesetDir, filesetIncludes); | |||
String currentPath = (String)paths.get(pathName); | |||
for (int i = 0; i < files.length; ++i) { | |||
if (currentPath == null || currentPath.length() == 0) { | |||
currentPath = files[i].getPath(); | |||
} else { | |||
currentPath = currentPath + File.pathSeparator | |||
+ files[i].getPath(); | |||
} | |||
} | |||
paths.put(pathName, currentPath); | |||
} | |||
/** | |||
* Add a new element to a path | |||
* | |||
* @param pathName the name of the path object to be updated | |||
* @param location the location to be added to the path | |||
*/ | |||
protected void addPathElementToPath(String pathName, String location) { | |||
String pathElement = resolve(location).replace('/', File.separatorChar); | |||
String currentPath = (String)paths.get(pathName); | |||
if (currentPath == null || currentPath.length() == 0) { | |||
currentPath = pathElement; | |||
} else { | |||
currentPath = currentPath + File.pathSeparator + pathElement; | |||
} | |||
paths.put(pathName, currentPath); | |||
} | |||
/** | |||
* Add an existing path to another path | |||
* | |||
* @param pathName the name of the path to which the path is to be added | |||
* @param pathNameToAdd the name of the path to be added. | |||
*/ | |||
protected void addPathToPath(String pathName, String pathNameToAdd) { | |||
String pathToAdd = (String)paths.get(pathNameToAdd); | |||
if (pathToAdd == null || pathToAdd.length() == 0) { | |||
return; | |||
} | |||
String currentPath = (String)paths.get(pathName); | |||
if (currentPath == null || currentPath.length() == 0) { | |||
currentPath = pathToAdd; | |||
} else { | |||
currentPath = currentPath + File.pathSeparator + pathToAdd; | |||
} | |||
paths.put(pathName, currentPath); | |||
} | |||
/** | |||
* Get the set of Java files to be compiled | |||
* | |||
* @param srcDir the directory to search (recursively searched) | |||
* @param javaFiles the list of files to which Java files are added | |||
*/ | |||
private void getJavaFiles(File srcDir, List javaFiles) { | |||
File[] files = srcDir.listFiles(); | |||
for (int i = 0; i < files.length; ++i) { | |||
if (files[i].isDirectory()) { | |||
getJavaFiles(files[i], javaFiles); | |||
} else if (files[i].getPath().endsWith(".java")) { | |||
javaFiles.add(files[i]); | |||
} | |||
} | |||
} | |||
/** | |||
* Copy a file | |||
* | |||
* @param from the source location | |||
* @param dest the destination location | |||
*/ | |||
private void copyFile(File from, File dest) { | |||
if (from.exists()) { | |||
dest.getParentFile().mkdirs(); | |||
try { | |||
FileInputStream in = new FileInputStream(from); | |||
FileOutputStream out = new FileOutputStream(dest); | |||
byte[] buf = new byte[1024 * 16]; | |||
int count = 0; | |||
count = in.read(buf, 0, buf.length); | |||
while (count != -1) { | |||
out.write(buf, 0, count); | |||
count = in.read(buf, 0, buf.length); | |||
} | |||
in.close(); | |||
out.close(); | |||
} catch (IOException ioe) { | |||
ioe.printStackTrace(); | |||
throw new RuntimeException("Unable to copy files"); | |||
} | |||
} | |||
} | |||
/** | |||
* Copy a list of files from one directory to another, preserving the | |||
* relative paths | |||
* | |||
* @param root the root of the source directory | |||
* @param files the files to be copied | |||
* @param to the destination directory | |||
*/ | |||
private void copyFileList(File root, File[] files, File to) { | |||
for (int i = 0; i < files.length; ++i) { | |||
if (files[i].getName().equals("CVS")) { | |||
continue; | |||
} | |||
String name | |||
= files[i].getPath().substring(root.getPath().length() + 1); | |||
File dest = new File(to, name); | |||
if (files[i].isDirectory()) { | |||
copyDir(files[i], dest); | |||
} else { | |||
copyFile(files[i], dest); | |||
} | |||
} | |||
} | |||
/** | |||
* Copy a directory | |||
* | |||
* @param from the source directory | |||
* @param to the destination directory | |||
*/ | |||
private void copyDir(File from, File to) { | |||
to.mkdirs(); | |||
File[] files = from.listFiles(); | |||
copyFileList(from, files, to); | |||
} | |||
/** | |||
* Add a directory to a Jar | |||
* | |||
* @param jos the JarOutputStream representing the Jar being created | |||
* @param dir the directory to be added to the jar | |||
* @param prefix the prefix in the jar at which the directory is to be | |||
* added | |||
* @exception IOException if the files cannot be added to the jar | |||
*/ | |||
private void addToJar(JarOutputStream jos, File dir, String prefix) | |||
throws IOException { | |||
File[] files = dir.listFiles(); | |||
addFilesToJar(jos, dir, files, prefix); | |||
} | |||
/** | |||
* Add a set of files to a jar | |||
* | |||
* @param jos the JarOutputStream representing the Jar being created | |||
* @param dir the directory fro which the files are taken | |||
* @param prefix the prefix in the jar at which the directory is to be | |||
* added | |||
* @param files the list of files to be added to the jar | |||
* @exception IOException if the files cannot be added to the jar | |||
*/ | |||
private void addFilesToJar(JarOutputStream jos, File dir, | |||
File[] files, String prefix) throws IOException { | |||
for (int i = 0; i < files.length; i++) { | |||
String name = files[i].getPath().replace('\\', '/'); | |||
name = name.substring(dir.getPath().length() + 1); | |||
if (prefix != null) { | |||
name = prefix + "/" + name; | |||
} | |||
ZipEntry ze = new ZipEntry(name); | |||
jos.putNextEntry(ze); | |||
if (files[i].isDirectory()) { | |||
addToJar(jos, files[i], name); | |||
} else { | |||
FileInputStream fis = new FileInputStream(files[i]); | |||
int count = 0; | |||
byte[] buf = new byte[8 * 1024]; | |||
count = fis.read(buf, 0, buf.length); | |||
while (count != -1) { | |||
jos.write(buf, 0, count); | |||
count = fis.read(buf, 0, buf.length); | |||
} | |||
fis.close(); | |||
} | |||
} | |||
} | |||
/** | |||
* Build a simple fileset. Only simple inclusion filtering is supported | |||
* - no complicated patterns. | |||
* | |||
* @param filesetDir the base directory of the fileset | |||
* @param filesetIncludes the simple includes spec for the fileset | |||
* @return the fileset expressed as an array of File instances. | |||
*/ | |||
private File[] buildFileSet(String filesetDir, String filesetIncludes) { | |||
if (filesetDir == null) { | |||
return new File[0]; | |||
} | |||
final String includes = resolve(filesetIncludes); | |||
if (includes.indexOf("**") != -1) { | |||
throw new RuntimeException("Simple fileset cannot handle ** " | |||
+ "style includes"); | |||
} | |||
int index = 0; | |||
if (includes.charAt(0) == '*') { | |||
index = 1; | |||
} | |||
if (includes.indexOf("*", index) != -1) { | |||
throw new RuntimeException("Simple fileset cannot handle * " | |||
+ "style includes except at start"); | |||
} | |||
File base = new File(resolve(filesetDir)); | |||
return base.listFiles( | |||
new FilenameFilter() { | |||
public boolean accept(File dir, String name) { | |||
if (includes.startsWith("*")) { | |||
return name.endsWith(includes.substring(1)); | |||
} else { | |||
return name.equals(includes); | |||
} | |||
} | |||
}); | |||
} | |||
/** | |||
* Resolve the property references in a string | |||
* | |||
* @param propertyValue the string to be resolved | |||
* @return the string with property references replaced by their current | |||
* value. | |||
*/ | |||
private String resolve(String propertyValue) { | |||
String newValue = propertyValue; | |||
while (newValue.indexOf("${") != -1) { | |||
int index = newValue.indexOf("${"); | |||
int endIndex = newValue.indexOf("}", index); | |||
String propertyName = newValue.substring(index + 2, endIndex); | |||
String repValue = (String)properties.get(propertyName); | |||
newValue = newValue.substring(0, index) + | |||
repValue + newValue.substring(endIndex + 1); | |||
} | |||
return newValue; | |||
} | |||
} | |||
@@ -0,0 +1,241 @@ | |||
/* | |||
* 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.builder; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* The Builder object builds the code for bootstrap purposes. It invokes the | |||
* mathods of the required targets in the converted build files. | |||
* | |||
* @author <a href="mailto:conor@apache.org">Conor MacNeill</a> | |||
* @created 18 February 2002 | |||
*/ | |||
public class Builder { | |||
/** The root of the Ant1 source tree */ | |||
private static final File ANT1_SRC_ROOT = new File("../../src/main"); | |||
/** the root of the Ant package in the Ant1 source tree */ | |||
private static final File PACKAGE_ROOT | |||
= new File(ANT1_SRC_ROOT, "org/apache/tools/ant"); | |||
/** The zip utilities root */ | |||
private static final File ZIP_ROOT | |||
= new File(ANT1_SRC_ROOT, "org/apache/tools/zip"); | |||
/** the taskdefs root */ | |||
private static final File TASKDEFS_ROOT | |||
= new File(PACKAGE_ROOT, "taskdefs"); | |||
/** the root forthe depend task's support classes */ | |||
private static final File DEPEND_ROOT | |||
= new File(TASKDEFS_ROOT, "optional/depend"); | |||
/** | |||
* The main program - create a builder and run the build | |||
* | |||
* @param args the command line arguments - not currently used | |||
*/ | |||
public static void main(String[] args) { | |||
Builder builder = new Builder(); | |||
builder.runBuild(args); | |||
} | |||
/** | |||
* Get the Ant1 files currently required to build a bootstrap build. | |||
* | |||
* @return an array of files which need to be copied into the bootstrap | |||
* build. | |||
*/ | |||
private File[] getAnt1Files() { | |||
List files = new ArrayList(); | |||
files.add(new File(PACKAGE_ROOT, "types/EnumeratedAttribute.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/Path.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/FileSet.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/PatternSet.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/Reference.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/FilterSet.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/FilterSetCollection.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/Mapper.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/ZipFileSet.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/ZipScanner.java")); | |||
files.add(new File(PACKAGE_ROOT, "util/FileNameMapper.java")); | |||
files.add(new File(PACKAGE_ROOT, "util/FlatFileNameMapper.java")); | |||
files.add(new File(PACKAGE_ROOT, "util/SourceFileScanner.java")); | |||
files.add(new File(PACKAGE_ROOT, "util/IdentityMapper.java")); | |||
files.add(new File(PACKAGE_ROOT, "util/MergingMapper.java")); | |||
files.add(new File(PACKAGE_ROOT, "util/GlobPatternMapper.java")); | |||
files.add(new File(PACKAGE_ROOT, "types/Commandline.java")); | |||
files.add(new File(PACKAGE_ROOT, "BuildException.java")); | |||
files.add(new File(PACKAGE_ROOT, "Location.java")); | |||
files.add(new File(PACKAGE_ROOT, "AntClassLoader.java")); | |||
files.add(new File(PACKAGE_ROOT, "BuildListener.java")); | |||
files.add(new File(PACKAGE_ROOT, "BuildEvent.java")); | |||
files.add(new File(PACKAGE_ROOT, "DirectoryScanner.java")); | |||
files.add(new File(PACKAGE_ROOT, "FileScanner.java")); | |||
files.add(new File(PACKAGE_ROOT, "PathTokenizer.java")); | |||
files.add(new File(PACKAGE_ROOT, "util/FileUtils.java")); | |||
files.add(new File(PACKAGE_ROOT, "defaultManifest.mf")); | |||
files.add(new File(TASKDEFS_ROOT, "defaults.properties")); | |||
files.add(new File(PACKAGE_ROOT, "types/defaults.properties")); | |||
files.add(new File(TASKDEFS_ROOT, "Property.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Execute.java")); | |||
files.add(new File(TASKDEFS_ROOT, "ExecuteStreamHandler.java")); | |||
files.add(new File(TASKDEFS_ROOT, "ExecuteWatchdog.java")); | |||
files.add(new File(TASKDEFS_ROOT, "ProcessDestroyer.java")); | |||
files.add(new File(TASKDEFS_ROOT, "PumpStreamHandler.java")); | |||
files.add(new File(TASKDEFS_ROOT, "StreamPumper.java")); | |||
files.add(new File(TASKDEFS_ROOT, "LogStreamHandler.java")); | |||
files.add(new File(TASKDEFS_ROOT, "LogOutputStream.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/Os.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/Condition.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Available.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Mkdir.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Copy.java")); | |||
files.add(new File(TASKDEFS_ROOT, "MatchingTask.java")); | |||
files.add(new File(DEPEND_ROOT, "Depend.java")); | |||
files.add(new File(DEPEND_ROOT, "ClassFile.java")); | |||
files.add(new File(DEPEND_ROOT, "ClassFileUtils.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/ClassCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/ConstantPool.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/ConstantPoolEntry.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/Utf8CPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/ConstantCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/MethodRefCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, | |||
"constantpool/InterfaceMethodRefCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/FieldRefCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/NameAndTypeCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/IntegerCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/FloatCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/LongCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/StringCPInfo.java")); | |||
files.add(new File(DEPEND_ROOT, "constantpool/DoubleCPInfo.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Javac.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/CompilerAdapter.java")); | |||
files.add(new File(TASKDEFS_ROOT, | |||
"compilers/DefaultCompilerAdapter.java")); | |||
files.add(new File(TASKDEFS_ROOT, | |||
"compilers/CompilerAdapterFactory.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/Jikes.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/JavacExternal.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/Javac12.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/Javac13.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/Kjc.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/Gcj.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/Jvc.java")); | |||
files.add(new File(TASKDEFS_ROOT, "compilers/Sj.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Jar.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Zip.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Manifest.java")); | |||
files.add(new File(TASKDEFS_ROOT, "ManifestException.java")); | |||
files.add(new File(ZIP_ROOT, "ZipOutputStream.java")); | |||
files.add(new File(ZIP_ROOT, "ZipOutputStream.java")); | |||
files.add(new File(ZIP_ROOT, "ZipEntry.java")); | |||
files.add(new File(ZIP_ROOT, "ZipLong.java")); | |||
files.add(new File(ZIP_ROOT, "ZipShort.java")); | |||
files.add(new File(ZIP_ROOT, "ZipExtraField.java")); | |||
files.add(new File(ZIP_ROOT, "ExtraFieldUtils.java")); | |||
files.add(new File(ZIP_ROOT, "AsiExtraField.java")); | |||
files.add(new File(ZIP_ROOT, "UnrecognizedExtraField.java")); | |||
files.add(new File(ZIP_ROOT, "UnixStat.java")); | |||
files.add(new File(TASKDEFS_ROOT, "ConditionTask.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/ConditionBase.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Checksum.java")); | |||
files.add(new File(TASKDEFS_ROOT, "UpToDate.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/Not.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/And.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/Equals.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/Or.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/IsSet.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/Http.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/Socket.java")); | |||
files.add(new File(TASKDEFS_ROOT, "condition/FilesMatch.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Taskdef.java")); | |||
files.add(new File(TASKDEFS_ROOT, "Definer.java")); | |||
return (File[])files.toArray(new File[0]); | |||
} | |||
/** | |||
* Run the build | |||
* | |||
* @param args the command line arguments for the build - currently not | |||
* used. | |||
*/ | |||
private void runBuild(String[] args) { | |||
BuildHelper mainBuild = new BuildHelper(); | |||
mainBuild.setProperty("dist.dir", "bootstrap"); | |||
MutantBuilder mutantBuilder = new MutantBuilder(); | |||
mutantBuilder._init(mainBuild); | |||
mutantBuilder.buildsetup(mainBuild); | |||
mutantBuilder.init(mainBuild); | |||
mutantBuilder.common(mainBuild); | |||
mutantBuilder.antcore(mainBuild); | |||
mutantBuilder.start(mainBuild); | |||
mutantBuilder.cli(mainBuild); | |||
BuildHelper systemBuild = new BuildHelper(); | |||
systemBuild.setProperty("libset", "system"); | |||
systemBuild.setProperty("dist.dir", "bootstrap"); | |||
mutantBuilder._init(systemBuild); | |||
mutantBuilder.build_lib(systemBuild); | |||
Ant1CompatBuilder ant1Builder = new Ant1CompatBuilder(); | |||
BuildHelper ant1Build = new BuildHelper(); | |||
ant1Build.setProperty("dist.dir", "bootstrap"); | |||
ant1Build.addFileSet("ant1src", ANT1_SRC_ROOT, getAnt1Files()); | |||
ant1Builder._init(ant1Build); | |||
ant1Builder.ant1compat(ant1Build); | |||
} | |||
} | |||
@@ -0,0 +1,97 @@ | |||
package org.apache.ant.builder; | |||
public class MutantBuilder { | |||
protected void _init(BuildHelper helper) { | |||
helper.setProperty("src.dir", "src"); | |||
helper.setProperty("lib.dir", "lib"); | |||
helper.setProperty("java.dir", "${src.dir}/java"); | |||
helper.setProperty("bin.dir", "bin"); | |||
helper.setProperty("dist.dir", "dist"); | |||
helper.setProperty("javadocs.dir", "${dist.dir}/javadocs"); | |||
helper.setProperty("distlib.dir", "${dist.dir}/lib"); | |||
helper.setProperty("debug", "true"); | |||
helper.createPath("classpath.parser"); | |||
helper.addFileSetToPath("classpath.parser", "${lib.dir}/parser", "*.jar"); | |||
helper.createPath("classpath.common"); | |||
helper.addPathElementToPath("classpath.common", "${distlib.dir}/init.jar"); | |||
helper.createPath("classpath.antcore"); | |||
helper.addPathElementToPath("classpath.antcore", "${distlib.dir}/common/common.jar"); | |||
helper.addPathToPath("classpath.antcore", "classpath.common"); | |||
helper.addPathToPath("classpath.antcore", "classpath.parser"); | |||
helper.createPath("classpath.cli"); | |||
helper.addPathElementToPath("classpath.cli", "${distlib.dir}/antcore/antcore.jar"); | |||
helper.addPathToPath("classpath.cli", "classpath.antcore"); | |||
helper.createPath("classpath.start"); | |||
helper.addPathElementToPath("classpath.start", "${distlib.dir}/init.jar"); | |||
} | |||
protected void buildsetup(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}"); | |||
helper.mkdir("${distlib.dir}"); | |||
helper.copyFileset("${lib.dir}/parser", "${distlib.dir}/parser"); | |||
} | |||
protected void init(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}/init"); | |||
helper.javac("${java.dir}/init", "${bin.dir}/init", null); | |||
helper.jar("${bin.dir}/init", "${distlib.dir}/init.jar", | |||
null, null); | |||
} | |||
protected void common(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}/common"); | |||
helper.mkdir("${distlib.dir}/common"); | |||
helper.javac("${java.dir}/common", "${bin.dir}/common", "classpath.common"); | |||
helper.jar("${bin.dir}/common", "${distlib.dir}/common/common.jar", | |||
null, null); | |||
} | |||
protected void antcore(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}/antcore"); | |||
helper.mkdir("${distlib.dir}/antcore"); | |||
helper.javac("${java.dir}/antcore", "${bin.dir}/antcore", "classpath.antcore"); | |||
helper.jar("${bin.dir}/antcore", "${distlib.dir}/antcore/antcore.jar", | |||
null, null); | |||
} | |||
protected void cli(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}/cli"); | |||
helper.mkdir("${distlib.dir}/cli"); | |||
helper.javac("${java.dir}/cli", "${bin.dir}/cli", "classpath.cli"); | |||
helper.jar("${bin.dir}/cli", "${distlib.dir}/cli/cli.jar", | |||
null, null); | |||
} | |||
protected void start(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}/start"); | |||
helper.javac("${java.dir}/start", "${bin.dir}/start", "classpath.start"); | |||
helper.jar("${bin.dir}/start", "${distlib.dir}/start.jar", | |||
null, null); | |||
} | |||
protected void ant1compat(BuildHelper helper) { | |||
} | |||
protected void remote(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}/remote"); | |||
helper.javac("${java.dir}/remote", "${bin.dir}/remote", "classpath.start"); | |||
helper.jar("${bin.dir}/remote", "${distlib.dir}/remote.jar", | |||
null, null); | |||
} | |||
protected void clean(BuildHelper helper) { | |||
} | |||
protected void antlibs(BuildHelper helper) { | |||
} | |||
protected void build_lib(BuildHelper helper) { | |||
helper.mkdir("${bin.dir}/antlibs/${libset}"); | |||
helper.mkdir("${distlib.dir}/antlibs"); | |||
helper.createPath("classpath.antlibs"); | |||
helper.addPathElementToPath("classpath.antlibs", "${distlib.dir}/common/common.jar"); | |||
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}.tsk", | |||
"${java.dir}/antlibs/${libset}", "antlib.xml"); | |||
} | |||
protected void main(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"); | |||
} | |||
protected void javadocs(BuildHelper helper) { | |||
helper.mkdir("${javadocs.dir}"); | |||
} | |||
} |
@@ -70,10 +70,11 @@ import org.apache.ant.antcore.execution.ExecutionManager; | |||
import org.apache.ant.antcore.modelparser.XMLProjectParser; | |||
import org.apache.ant.antcore.xml.ParseContext; | |||
import org.apache.ant.antcore.xml.XMLParseException; | |||
import org.apache.ant.common.event.BuildEvent; | |||
import org.apache.ant.common.event.BuildListener; | |||
import org.apache.ant.common.event.MessageLevel; | |||
import org.apache.ant.common.model.Project; | |||
import org.apache.ant.common.util.ConfigException; | |||
import org.apache.ant.common.event.MessageLevel; | |||
import org.apache.ant.init.InitConfig; | |||
import org.apache.ant.init.InitUtils; | |||
@@ -85,10 +86,10 @@ import org.apache.ant.init.InitUtils; | |||
*/ | |||
public class Commandline { | |||
/** The default build file name */ | |||
public final static String DEFAULT_BUILD_FILENAME = "build.ant"; | |||
public static final String DEFAULT_BUILD_FILENAME = "build.ant"; | |||
/** The default build file name */ | |||
public final static String DEFAULT_ANT1_FILENAME = "build.xml"; | |||
public static final String DEFAULT_ANT1_FILENAME = "build.xml"; | |||
/** The initialisation configuration for Ant */ | |||
private InitConfig initConfig; | |||
@@ -127,6 +128,9 @@ public class Commandline { | |||
/** Our current message output status. Follows MessageLevel values */ | |||
private int messageOutputLevel = MessageLevel.MSG_INFO; | |||
/** The logger that will be used for the build */ | |||
private BuildLogger logger = null; | |||
/** | |||
* Start the command line front end for mutant. | |||
* | |||
@@ -152,7 +156,7 @@ public class Commandline { | |||
throws ConfigException { | |||
// Add the default listener | |||
execManager.addBuildListener(createLogger()); | |||
execManager.addBuildListener(logger); | |||
for (Iterator i = listeners.iterator(); i.hasNext(); ) { | |||
String className = (String)i.next(); | |||
@@ -259,8 +263,11 @@ public class Commandline { | |||
*/ | |||
private void process(String[] args, InitConfig initConfig) { | |||
this.initConfig = initConfig; | |||
ExecutionManager executionManager = null; | |||
Project project = null; | |||
try { | |||
parseArguments(args); | |||
createLogger(); | |||
determineBuildFile(); | |||
AntConfig config = new AntConfig(); | |||
@@ -287,12 +294,23 @@ public class Commandline { | |||
+ buildFileURL); | |||
} | |||
Project project = parseProject(); | |||
project = parseProject(); | |||
// create the execution manager to execute the build | |||
ExecutionManager executionManager | |||
= new ExecutionManager(initConfig, config); | |||
executionManager = new ExecutionManager(initConfig, config); | |||
addBuildListeners(executionManager); | |||
} catch (Throwable e) { | |||
if (logger != null) { | |||
BuildEvent finishedEvent | |||
= new BuildEvent(this, BuildEvent.BUILD_FINISHED, e); | |||
logger.buildFinished(finishedEvent); | |||
} else { | |||
e.printStackTrace(); | |||
} | |||
System.exit(1); | |||
} | |||
try { | |||
executionManager.init(); | |||
executionManager.runBuild(project, targets, definedProperties); | |||
System.exit(0); | |||
@@ -448,11 +466,9 @@ public class Commandline { | |||
* Creates the default build logger for sending build events to the ant | |||
* log. | |||
* | |||
* @return the logger instance to be used for the build | |||
* @exception ConfigException if the logger cannot be instantiatd | |||
*/ | |||
private BuildLogger createLogger() throws ConfigException { | |||
BuildLogger logger = null; | |||
private void createLogger() throws ConfigException { | |||
if (loggerClassname != null) { | |||
try { | |||
Class loggerClass = Class.forName(loggerClassname); | |||
@@ -477,8 +493,6 @@ public class Commandline { | |||
logger.setMessageOutputLevel(messageOutputLevel); | |||
logger.setOutputPrintStream(out); | |||
logger.setErrorPrintStream(err); | |||
return logger; | |||
} | |||
} | |||
@@ -85,7 +85,7 @@ public class DefaultLogger implements BuildLogger { | |||
/** Standard field separator */ | |||
private static String lSep = System.getProperty("line.separator"); | |||
/** spacing to allow for task tags */ | |||
private final static int LEFT_COLUMN_SIZE = 12; | |||
private static final int LEFT_COLUMN_SIZE = 12; | |||
/** | |||
* Set the messageOutputLevel this logger is to respond to. Only | |||
@@ -68,19 +68,19 @@ import org.apache.ant.common.model.ModelElement; | |||
public class BuildEvent extends EventObject { | |||
/** Build Started Event type */ | |||
public final static int BUILD_STARTED = 1; | |||
public static final int BUILD_STARTED = 1; | |||
/** Build Finished Event Type */ | |||
public final static int BUILD_FINISHED = 2; | |||
public static final int BUILD_FINISHED = 2; | |||
/** Start of target event type */ | |||
public final static int TARGET_STARTED = 3; | |||
public static final int TARGET_STARTED = 3; | |||
/** Target finished event type */ | |||
public final static int TARGET_FINISHED = 4; | |||
public static final int TARGET_FINISHED = 4; | |||
/** Start of task event type */ | |||
public final static int TASK_STARTED = 5; | |||
public static final int TASK_STARTED = 5; | |||
/** end of task event type */ | |||
public final static int TASK_FINISHED = 6; | |||
public static final int TASK_FINISHED = 6; | |||
/** message event type */ | |||
public final static int MESSAGE = 7; | |||
public static final int MESSAGE = 7; | |||
/** The type of this event */ | |||
private int eventType; | |||
@@ -97,7 +97,7 @@ public class BuildEvent extends EventObject { | |||
* @param eventType the type of the buildEvent. | |||
* @param source the element with which this event is associated | |||
*/ | |||
public BuildEvent(ModelElement source, int eventType) { | |||
public BuildEvent(Object source, int eventType) { | |||
super(source); | |||
this.eventType = eventType; | |||
} | |||
@@ -109,7 +109,7 @@ public class BuildEvent extends EventObject { | |||
* @param cause An exception if associated with the event | |||
* @param source the object with which this event is associated | |||
*/ | |||
public BuildEvent(ModelElement source, int eventType, | |||
public BuildEvent(Object source, int eventType, | |||
Throwable cause) { | |||
this(source, eventType); | |||
this.cause = cause; | |||
@@ -61,14 +61,14 @@ package org.apache.ant.common.event; | |||
*/ | |||
public class MessageLevel { | |||
/** Error message level */ | |||
public final static int MSG_ERR = 0; | |||
public static final int MSG_ERR = 0; | |||
/** Warnign message level */ | |||
public final static int MSG_WARN = 1; | |||
public static final int MSG_WARN = 1; | |||
/** Informational message level */ | |||
public final static int MSG_INFO = 2; | |||
public static final int MSG_INFO = 2; | |||
/** Verbose message level */ | |||
public final static int MSG_VERBOSE = 3; | |||
public static final int MSG_VERBOSE = 3; | |||
/** Debug Message level */ | |||
public final static int MSG_DEBUG = 4; | |||
public static final int MSG_DEBUG = 4; | |||
} | |||
@@ -79,7 +79,7 @@ public class Project extends ModelElement { | |||
* The delimiter used to separate reference names in target names, data | |||
* values, etc | |||
*/ | |||
public final static String REF_DELIMITER = ":"; | |||
public static final String REF_DELIMITER = ":"; | |||
/** The default target in this project. */ | |||
private String defaultTarget = null; | |||
@@ -145,5 +145,18 @@ public interface ComponentService { | |||
* @exception ExecutionException if the library cannot be imported | |||
*/ | |||
void importLibrary(String libraryId) throws ExecutionException; | |||
/** | |||
* Imports a component defined in a nother frame. | |||
* | |||
* @param relativeName the qualified name of the component relative to | |||
* this execution frame | |||
* @param alias the name under which this component will be used in the | |||
* build scripts. If this is null, the components default name is | |||
* used. | |||
* @exception ExecutionException if the component cannot be imported | |||
*/ | |||
void importFrameComponent(String relativeName, String alias) | |||
throws ExecutionException; | |||
} | |||
@@ -64,9 +64,9 @@ public class MagicProperties { | |||
* This property describes the basedir which is being used for an Ant | |||
* run. | |||
*/ | |||
public final static String BASEDIR = "basedir"; | |||
public static final String BASEDIR = "basedir"; | |||
/** This property provides the location of Ant's home directory */ | |||
public final static String ANT_HOME = "ant.home"; | |||
public static final String ANT_HOME = "ant.home"; | |||
} | |||
@@ -62,7 +62,7 @@ package org.apache.ant.common.util; | |||
public class Location { | |||
/** Standard unknown location constant; */ | |||
public final static Location UNKNOWN_LOCATION = new Location(); | |||
public static final Location UNKNOWN_LOCATION = new Location(); | |||
/** The source URL to which this location relates. */ | |||
private String source; | |||
@@ -66,7 +66,7 @@ import java.util.ArrayList; | |||
public final class StringUtils { | |||
/** the line separator for this OS */ | |||
public final static String LINE_SEP = System.getProperty("line.separator"); | |||
public static final String LINE_SEP = System.getProperty("line.separator"); | |||
/** | |||
* Convenient method to retrieve the full stacktrace from a given | |||
@@ -55,6 +55,7 @@ package org.apache.ant.init; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.io.File; | |||
/** | |||
* The ClassLocator is a utility class which is used to determine the URL | |||
@@ -103,5 +104,42 @@ public class ClassLocator { | |||
return classRawURL; | |||
} | |||
} | |||
/** | |||
* Get the URLs necessary to load the Sun compiler tools. In some JVMs | |||
* this is available in the VM's system loader, in others we have to | |||
* find it ourselves | |||
* | |||
* @return the URL to the tools jar if available, null otherwise | |||
* @throws InitException if the URL to the tools jar cannot be formed. | |||
*/ | |||
public static URL getToolsJarURL() | |||
throws InitException { | |||
try { | |||
// just check whether this throws an exception | |||
Class.forName("sun.tools.javac.Main"); | |||
// tools jar is on system classpath - no need for URL | |||
return null; | |||
} catch (ClassNotFoundException cnfe) { | |||
try { | |||
// couldn't find compiler - try to find tools.jar | |||
// based on java.home setting | |||
String javaHome = System.getProperty("java.home"); | |||
if (javaHome.endsWith("jre")) { | |||
javaHome = javaHome.substring(0, javaHome.length() - 4); | |||
} | |||
File toolsjar = new File(javaHome + "/lib/tools.jar"); | |||
if (!toolsjar.exists()) { | |||
System.out.println("Unable to locate tools.jar. " | |||
+ "Expected to find it in " + toolsjar.getPath()); | |||
return null; | |||
} | |||
URL toolsJarURL = InitUtils.getFileURL(toolsjar); | |||
return toolsJarURL; | |||
} catch (MalformedURLException e) { | |||
throw new InitException(e); | |||
} | |||
} | |||
} | |||
} | |||
@@ -77,7 +77,7 @@ public class LoaderUtils { | |||
* This is the file that is consulted on remote systems to specify | |||
* available jars | |||
*/ | |||
public final static String LIST_FILE = "file.list"; | |||
public static final String LIST_FILE = "file.list"; | |||
/** | |||
@@ -73,7 +73,7 @@ import org.apache.ant.init.LoaderUtils; | |||
*/ | |||
public class Main { | |||
/** The actual class that implements the command line front end. */ | |||
public final static String COMMANDLINE_CLASS | |||
public static final String COMMANDLINE_CLASS | |||
= "org.apache.ant.cli.Commandline"; | |||
@@ -127,43 +127,6 @@ public class Main { | |||
} | |||
/** | |||
* Get the URLs necessary to load the Sun compiler tools. In some JVMs | |||
* this is available in the VM's system loader, in others we have to | |||
* find it ourselves | |||
* | |||
* @return the URL to the tools jar if available, null otherwise | |||
* @throws InitException if the URL to the tools jar cannot be formed. | |||
*/ | |||
private URL getToolsJarURL() | |||
throws InitException { | |||
try { | |||
// just check whether this throws an exception | |||
Class.forName("sun.tools.javac.Main"); | |||
// tools jar is on system classpath - no need for URL | |||
return null; | |||
} catch (ClassNotFoundException cnfe) { | |||
try { | |||
// couldn't find compiler - try to find tools.jar | |||
// based on java.home setting | |||
String javaHome = System.getProperty("java.home"); | |||
if (javaHome.endsWith("jre")) { | |||
javaHome = javaHome.substring(0, javaHome.length() - 4); | |||
} | |||
File toolsjar = new File(javaHome + "/lib/tools.jar"); | |||
if (!toolsjar.exists()) { | |||
System.out.println("Unable to locate tools.jar. " | |||
+ "Expected to find it in " + toolsjar.getPath()); | |||
return null; | |||
} | |||
URL toolsJarURL = InitUtils.getFileURL(toolsjar); | |||
return toolsJarURL; | |||
} catch (MalformedURLException e) { | |||
throw new InitException(e); | |||
} | |||
} | |||
} | |||
/** | |||
* Get the location of AntHome | |||
@@ -211,7 +174,7 @@ public class Main { | |||
// set up the class loaders that will be used when running Ant | |||
ClassLoader systemLoader = getClass().getClassLoader(); | |||
config.setSystemLoader(systemLoader); | |||
URL toolsJarURL = getToolsJarURL(); | |||
URL toolsJarURL = ClassLocator.getToolsJarURL(); | |||
config.setToolsJarURL(toolsJarURL); | |||
URL commonJarLib = new URL(libraryURL, "common/"); | |||