git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272190 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -55,7 +55,6 @@ package org.apache.ant.antcore.modelparser; | |||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import org.apache.ant.common.model.BuildElement; | import org.apache.ant.common.model.BuildElement; | ||||
| import org.apache.ant.antcore.xml.ElementHandler; | |||||
| import org.xml.sax.Attributes; | import org.xml.sax.Attributes; | ||||
| import org.xml.sax.SAXParseException; | import org.xml.sax.SAXParseException; | ||||
| @@ -66,7 +65,7 @@ import org.xml.sax.SAXParseException; | |||||
| * @author Conor MacNeill | * @author Conor MacNeill | ||||
| * @created 9 January 2002 | * @created 9 January 2002 | ||||
| */ | */ | ||||
| public class BuildElementHandler extends ElementHandler { | |||||
| public class BuildElementHandler extends ModelElementHandler { | |||||
| /** The task element being parsed by this handler. */ | /** The task element being parsed by this handler. */ | ||||
| private BuildElement buildElement; | private BuildElement buildElement; | ||||
| @@ -87,7 +86,8 @@ public class BuildElementHandler extends ElementHandler { | |||||
| public void processElement(String elementName) { | public void processElement(String elementName) { | ||||
| buildElement | buildElement | ||||
| = new BuildElement(getLocation(), elementName); | = new BuildElement(getLocation(), elementName); | ||||
| setModelElement(buildElement); | |||||
| for (Iterator i = getAttributes(); i.hasNext(); ) { | for (Iterator i = getAttributes(); i.hasNext(); ) { | ||||
| String attributeName = (String)i.next(); | String attributeName = (String)i.next(); | ||||
| buildElement.addAttribute(attributeName, | buildElement.addAttribute(attributeName, | ||||
| @@ -0,0 +1,88 @@ | |||||
| /* | |||||
| * 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.modelparser; | |||||
| import org.apache.ant.antcore.xml.ElementHandler; | |||||
| import org.apache.ant.common.model.ModelElement; | |||||
| /** | |||||
| * A BuildElementHandler parses the task elements of a build. Task elements | |||||
| * include tasks themselves plus all their nested elements to any depth. | |||||
| * | |||||
| * @author Conor MacNeill | |||||
| * @created 9 January 2002 | |||||
| */ | |||||
| public abstract class ModelElementHandler extends ElementHandler { | |||||
| /** The model element being parsed by this handler. */ | |||||
| private ModelElement modelElement; | |||||
| /** | |||||
| * Set the model element being handled by this handler | |||||
| * | |||||
| * @param modelElement The new modelElement value | |||||
| */ | |||||
| protected void setModelElement(ModelElement modelElement) { | |||||
| this.modelElement = modelElement; | |||||
| } | |||||
| /** Set the end location of the element. */ | |||||
| protected void finish() { | |||||
| if (modelElement != null) { | |||||
| modelElement.setEndLocation(getLocation()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -54,7 +54,6 @@ | |||||
| package org.apache.ant.antcore.modelparser; | package org.apache.ant.antcore.modelparser; | ||||
| import org.apache.ant.common.model.ModelException; | import org.apache.ant.common.model.ModelException; | ||||
| import org.apache.ant.common.model.Project; | import org.apache.ant.common.model.Project; | ||||
| import org.apache.ant.antcore.xml.ElementHandler; | |||||
| import org.xml.sax.Attributes; | import org.xml.sax.Attributes; | ||||
| import org.xml.sax.SAXParseException; | import org.xml.sax.SAXParseException; | ||||
| @@ -66,7 +65,7 @@ import org.xml.sax.SAXParseException; | |||||
| * @author Conor MacNeill | * @author Conor MacNeill | ||||
| * @created 9 January 2002 | * @created 9 January 2002 | ||||
| */ | */ | ||||
| public class ProjectHandler extends ElementHandler { | |||||
| public class ProjectHandler extends ModelElementHandler { | |||||
| /** The basedir attribute tag */ | /** The basedir attribute tag */ | ||||
| public static final String BASEDIR_ATTR = "basedir"; | public static final String BASEDIR_ATTR = "basedir"; | ||||
| @@ -129,7 +128,8 @@ public class ProjectHandler extends ElementHandler { | |||||
| throws SAXParseException { | throws SAXParseException { | ||||
| if (project == null) { | if (project == null) { | ||||
| project = new Project(getElementSource(), getLocation()); | project = new Project(getElementSource(), getLocation()); | ||||
| setModelElement(project); | |||||
| project.setDefaultTarget(getAttribute(DEFAULT_ATTR)); | project.setDefaultTarget(getAttribute(DEFAULT_ATTR)); | ||||
| project.setBase(getAttribute(BASEDIR_ATTR)); | project.setBase(getAttribute(BASEDIR_ATTR)); | ||||
| project.setName(getAttribute(NAME_ATTR)); | project.setName(getAttribute(NAME_ATTR)); | ||||
| @@ -55,7 +55,6 @@ package org.apache.ant.antcore.modelparser; | |||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import org.apache.ant.common.model.Target; | import org.apache.ant.common.model.Target; | ||||
| import org.apache.ant.antcore.xml.ElementHandler; | |||||
| import org.xml.sax.Attributes; | import org.xml.sax.Attributes; | ||||
| import org.xml.sax.SAXParseException; | import org.xml.sax.SAXParseException; | ||||
| @@ -65,7 +64,7 @@ import org.xml.sax.SAXParseException; | |||||
| * @author Conor MacNeill | * @author Conor MacNeill | ||||
| * @created 9 January 2002 | * @created 9 January 2002 | ||||
| */ | */ | ||||
| public class TargetHandler extends ElementHandler { | |||||
| public class TargetHandler extends ModelElementHandler { | |||||
| /** The name attribute */ | /** The name attribute */ | ||||
| public static final String NAME_ATTR = "name"; | public static final String NAME_ATTR = "name"; | ||||
| @@ -104,6 +103,7 @@ public class TargetHandler extends ElementHandler { | |||||
| public void processElement(String elementName) | public void processElement(String elementName) | ||||
| throws SAXParseException { | throws SAXParseException { | ||||
| target = new Target(getLocation(), getAttribute(NAME_ATTR)); | target = new Target(getLocation(), getAttribute(NAME_ATTR)); | ||||
| setModelElement(target); | |||||
| target.setDescription(getAttribute(DESC_ATTR)); | target.setDescription(getAttribute(DESC_ATTR)); | ||||
| target.setAspects(getAspects()); | target.setAspects(getAspects()); | ||||
| @@ -122,8 +122,8 @@ public class RootHandler extends DefaultHandler { | |||||
| /** | /** | ||||
| * Start a new element in the root. This must be a project element All | |||||
| * other elements are invalid. | |||||
| * Start a new element in the root. This must be an allowed root element. | |||||
| * All other elements are invalid. | |||||
| * | * | ||||
| * @param uri The Namespace URI. | * @param uri The Namespace URI. | ||||
| * @param localName The local name (without prefix). | * @param localName The local name (without prefix). | ||||
| @@ -131,7 +131,7 @@ public class Ant extends Task { | |||||
| } | } | ||||
| /** | /** | ||||
| * XXX Sets the output of the Ant | |||||
| * Set the output file in which Ant stores output | |||||
| * | * | ||||
| * @param s name of the file to store output. | * @param s name of the file to store output. | ||||
| */ | */ | ||||
| @@ -158,7 +158,8 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Do the execution. | * Do the execution. | ||||
| * | * | ||||
| * @exception BuildException XXX Description of Exception | |||||
| * @exception BuildException if the execution of the sub-build has a | |||||
| * problem | |||||
| */ | */ | ||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| for (Iterator i = properties.iterator(); i.hasNext(); ) { | for (Iterator i = properties.iterator(); i.hasNext(); ) { | ||||
| @@ -70,8 +70,11 @@ public abstract class ModelElement { | |||||
| /** The aspects defined for this element. */ | /** The aspects defined for this element. */ | ||||
| private Map aspectMaps; | private Map aspectMaps; | ||||
| /** The location of this element */ | |||||
| private Location location; | |||||
| /** The starting location of this element */ | |||||
| private Location location = Location.UNKNOWN_LOCATION; | |||||
| /** The ending location of this element */ | |||||
| private Location endLocation = Location.UNKNOWN_LOCATION; | |||||
| /** A comment associated with this element, if any */ | /** A comment associated with this element, if any */ | ||||
| private String comment; | private String comment; | ||||
| @@ -94,6 +97,15 @@ public abstract class ModelElement { | |||||
| this.comment = comment; | this.comment = comment; | ||||
| } | } | ||||
| /** | |||||
| * Set the end location of this element | |||||
| * | |||||
| * @param endLocation the location where this element's definition ends | |||||
| */ | |||||
| public void setEndLocation(Location endLocation) { | |||||
| this.endLocation = endLocation; | |||||
| } | |||||
| /** | /** | ||||
| * Set the aspects of this element | * Set the aspects of this element | ||||
| * | * | ||||
| @@ -128,6 +140,15 @@ public abstract class ModelElement { | |||||
| return location; | return location; | ||||
| } | } | ||||
| /** | |||||
| * Get the location of the source where this element's definition fiunishes | |||||
| * | |||||
| * @return the element's end location | |||||
| */ | |||||
| public Location getEndLocation() { | |||||
| return endLocation; | |||||
| } | |||||
| /** | /** | ||||
| * Get the comment associated with this element. | * Get the comment associated with this element. | ||||
| * | * | ||||
| @@ -63,6 +63,7 @@ public class Location { | |||||
| /** Standard unknown location constant; */ | /** Standard unknown location constant; */ | ||||
| public static final Location UNKNOWN_LOCATION = new Location(); | public static final Location UNKNOWN_LOCATION = new Location(); | ||||
| /** The source URL to which this location relates. */ | /** The source URL to which this location relates. */ | ||||
| private String source; | private String source; | ||||
| @@ -114,9 +114,9 @@ public class InitConfig { | |||||
| private File userConfigArea; | private File userConfigArea; | ||||
| /** | /** | ||||
| * XXX Constructor for the InitConfig object | |||||
| * Constructor for the Initialization configuration | |||||
| * | * | ||||
| * @exception InitException XXX Description of Exception | |||||
| * @exception InitException if the configuration cannot be initialized | |||||
| */ | */ | ||||
| public InitConfig() throws InitException { | public InitConfig() throws InitException { | ||||
| try { | try { | ||||
| @@ -1,55 +1,55 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | * | ||||
| * Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * 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: | |||||
| * 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. | |||||
| * 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. | |||||
| * 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. | |||||
| * 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. | |||||
| * 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. | |||||
| * 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 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/>. | |||||
| * 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.start; | package org.apache.ant.start; | ||||
| @@ -57,93 +57,151 @@ import java.io.IOException; | |||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.util.jar.Manifest; | |||||
| import java.util.jar.Attributes; | import java.util.jar.Attributes; | ||||
| import java.util.jar.JarInputStream; | import java.util.jar.JarInputStream; | ||||
| import java.util.jar.Manifest; | |||||
| import org.apache.ant.init.InitConfig; | import org.apache.ant.init.InitConfig; | ||||
| import org.apache.ant.init.InitException; | |||||
| import java.io.File; | |||||
| /** | /** | ||||
| * This is the main startup class for the command line interface of Ant. It | |||||
| * establishes the classloaders used by the other components of Ant. | |||||
| * This is the main startup class for the command line interface of Ant. It | |||||
| * establishes the classloaders used by the other components of Ant. | |||||
| * | * | ||||
| * @author Conor MacNeill | |||||
| * @created 9 January 2002 | |||||
| * @author Conor MacNeill | |||||
| * @created 9 January 2002 | |||||
| */ | */ | ||||
| public class Main { | public class Main { | ||||
| /** The actual class that implements the command line front end. */ | |||||
| /** The actual class that implements the command line front end. */ | |||||
| public static final String DEFAULT_COMMANDLINE_CLASS | public static final String DEFAULT_COMMANDLINE_CLASS | ||||
| = "org.apache.ant.cli.Commandline"; | = "org.apache.ant.cli.Commandline"; | ||||
| /** The default front end name */ | |||||
| /** The default front end name */ | |||||
| public static final String DEFAULT_FRONTEND = "cli"; | public static final String DEFAULT_FRONTEND = "cli"; | ||||
| /** | /** | ||||
| * Entry point for starting command line Ant | |||||
| * Entry point for starting command line Ant | |||||
| * | * | ||||
| * @param args commandline arguments | |||||
| * @param args commandline arguments | |||||
| * @exception Exception if there is a problem running Ant | |||||
| */ | */ | ||||
| public static void main(String[] args) { | |||||
| public static void main(String[] args) throws Exception { | |||||
| Main main = new Main(); | Main main = new Main(); | ||||
| main.start(DEFAULT_FRONTEND, args); | |||||
| int frontendIndex = -1; | |||||
| String frontend = DEFAULT_FRONTEND; | |||||
| for (int i = 0; i < args.length; ++i) { | |||||
| if (args[i].equals("-frontend")) { | |||||
| frontendIndex = i; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (frontendIndex != -1) { | |||||
| try { | |||||
| frontend = args[frontendIndex + 1]; | |||||
| } catch (IndexOutOfBoundsException e) { | |||||
| throw new InitException("You must specify a value for the " | |||||
| + "-frontend argument"); | |||||
| } | |||||
| String[] newArgs = new String[args.length - 2]; | |||||
| System.arraycopy(args, 0, newArgs, 0, frontendIndex); | |||||
| if (args.length > (frontendIndex + 2)) { | |||||
| System.arraycopy(args, frontendIndex + 2, newArgs, | |||||
| frontendIndex, args.length - frontendIndex - 2); | |||||
| } | |||||
| args = newArgs; | |||||
| } | |||||
| String defaultClass = frontend.equals(DEFAULT_FRONTEND) | |||||
| ? DEFAULT_COMMANDLINE_CLASS : null; | |||||
| main.start(frontend, defaultClass, args); | |||||
| } | } | ||||
| /** | /** | ||||
| * Internal start method used to initialise front end | |||||
| * Internal start method used to initialise front end | |||||
| * | * | ||||
| * @param frontend the frontend jar to launch | |||||
| * @param args commandline arguments | |||||
| * @param frontend the frontend jar to launch | |||||
| * @param args commandline arguments | |||||
| * @param defaultClass the default class to use if it cannot be determined | |||||
| * from the jar itself | |||||
| * @exception InitException if the front end cannot be started | |||||
| */ | */ | ||||
| public void start(String frontend, String[] args) { | |||||
| try { | |||||
| public void start(String frontend, String defaultClass, String[] args) | |||||
| throws InitException { | |||||
| try { | |||||
| InitConfig config = new InitConfig(); | InitConfig config = new InitConfig(); | ||||
| URL frontendJar = new URL(config.getLibraryURL(), | |||||
| URL frontendJar = new URL(config.getLibraryURL(), | |||||
| "frontend/" + frontend + ".jar"); | "frontend/" + frontend + ".jar"); | ||||
| URL[] frontendJars = new URL[]{frontendJar}; | URL[] frontendJars = new URL[]{frontendJar}; | ||||
| ClassLoader frontEndLoader | |||||
| = new URLClassLoader(frontendJars, config.getCoreLoader()); | |||||
| ClassLoader frontEndLoader | |||||
| = new URLClassLoader(frontendJars, config.getCoreLoader()); | |||||
| //System.out.println("Front End Loader config"); | //System.out.println("Front End Loader config"); | ||||
| //LoaderUtils.dumpLoader(System.out, frontEndLoader); | //LoaderUtils.dumpLoader(System.out, frontEndLoader); | ||||
| if (frontendJar.getProtocol().equals("file")) { | |||||
| File jarFile = new File(frontendJar.getFile()); | |||||
| if (!jarFile.exists()) { | |||||
| throw new InitException("Could not jar for frontend \"" | |||||
| + frontend + "\""); | |||||
| } | |||||
| } | |||||
| String mainClass = getMainClass(frontendJar); | String mainClass = getMainClass(frontendJar); | ||||
| System.out.println("Front end main class = " + mainClass); | |||||
| if (mainClass == null) { | if (mainClass == null) { | ||||
| mainClass = DEFAULT_COMMANDLINE_CLASS; | |||||
| mainClass = defaultClass; | |||||
| } | } | ||||
| if (mainClass == null) { | |||||
| throw new InitException("Unable to determine main class " | |||||
| + " for \"" + frontend + "\" frontend"); | |||||
| } | |||||
| // Now start the front end by reflection. | // Now start the front end by reflection. | ||||
| Class commandLineClass = Class.forName(mainClass, true, | |||||
| Class frontendClass = Class.forName(mainClass, true, | |||||
| frontEndLoader); | frontEndLoader); | ||||
| final Class[] param = {Class.forName("[Ljava.lang.String;"), | final Class[] param = {Class.forName("[Ljava.lang.String;"), | ||||
| InitConfig.class}; | InitConfig.class}; | ||||
| final Method startMethod | final Method startMethod | ||||
| = commandLineClass.getMethod("start", param); | |||||
| = frontendClass.getMethod("start", param); | |||||
| final Object[] argument = {args, config}; | final Object[] argument = {args, config}; | ||||
| startMethod.invoke(null, argument); | startMethod.invoke(null, argument); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| e.printStackTrace(); | |||||
| throw new InitException(e); | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Pick up the main class from a jar's manifest | |||||
| * Pick up the main class from a jar's manifest | |||||
| * | * | ||||
| * @param jarURL the URL to the jar | |||||
| * @return the jar's main-class or null if it is not specified or cannot be | |||||
| * determined. | |||||
| * @param jarURL the URL to the jar | |||||
| * @return the jar's main-class or null if it is not specified or | |||||
| * cannot be determined. | |||||
| */ | */ | ||||
| private String getMainClass(URL jarURL) { | private String getMainClass(URL jarURL) { | ||||
| try { | try { | ||||
| JarInputStream stream = null; | JarInputStream stream = null; | ||||
| try { | try { | ||||
| stream = new JarInputStream(jarURL.openStream()); | stream = new JarInputStream(jarURL.openStream()); | ||||
| Manifest manifest = stream.getManifest(); | Manifest manifest = stream.getManifest(); | ||||
| if (manifest == null) { | if (manifest == null) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| Attributes mainAttributes = manifest.getMainAttributes(); | Attributes mainAttributes = manifest.getMainAttributes(); | ||||
| return mainAttributes.getValue("Main-Class"); | return mainAttributes.getValue("Main-Class"); | ||||
| } finally { | } finally { | ||||
| if (stream != null) { | if (stream != null) { | ||||
| @@ -151,7 +209,7 @@ public class Main { | |||||
| } | } | ||||
| } | } | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| // ignore | |||||
| // ignore | |||||
| return null; | return null; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,70 +1,72 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | * | ||||
| * Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * 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: | |||||
| * 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. | |||||
| * 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. | |||||
| * 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. | |||||
| * 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. | |||||
| * 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. | |||||
| * 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 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/>. | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | */ | ||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| /** | /** | ||||
| * Old Ant1 entry point | |||||
| * Old Ant1 entry point | |||||
| * | * | ||||
| * @author Conor MacNeill | |||||
| * @author Conor MacNeill | |||||
| * @created 4 April 2002 | |||||
| */ | */ | ||||
| public class Main { | public class Main { | ||||
| /** | |||||
| * Entry point for starting command line Ant | |||||
| /** | |||||
| * Entry point for starting command line Ant | |||||
| * | * | ||||
| * @param args commandline arguments | |||||
| * @param args commandline arguments | |||||
| * @exception Exception if there is a problem running Ant | |||||
| */ | */ | ||||
| public static void main(String[] args) { | |||||
| public static void main(String[] args) throws Exception { | |||||
| org.apache.ant.start.Main.main(args); | org.apache.ant.start.Main.main(args); | ||||
| } | } | ||||
| } | } | ||||