Index: org/apache/tools/ant/Main.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/Main.java,v retrieving revision 1.80 diff -u -r1.80 Main.java --- org/apache/tools/ant/Main.java 12 Feb 2003 05:04:31 -0000 1.80 +++ org/apache/tools/ant/Main.java 7 Mar 2003 05:59:45 -0000 @@ -176,6 +176,7 @@ try { Diagnostics.validateVersion(); + ProjectFactory.setProjectClassName("org.apache.tools.ant.Project"); m = new Main(args); } catch (Throwable exc) { handleLogfile(); @@ -383,6 +384,15 @@ "using the -propertyfile argument"; throw new BuildException(msg); } + } else if (arg.startsWith("-projectclass")) { + try { + ProjectFactory.setProjectClassName(args[i + 1]); + i++; + } catch (ArrayIndexOutOfBoundsException aioobe) { + String msg = "You must specify a class name when " + + "using the -projectclass argument"; + throw new BuildException(msg); + } } else if (arg.startsWith("-")) { // we don't have any more args to recognize! String msg = "Unknown argument: " + arg; @@ -546,7 +556,7 @@ return; } - final Project project = new Project(); + final Project project = ProjectFactory.getProjectInstance(); project.setCoreLoader(coreLoader); Throwable error = null; @@ -754,6 +764,13 @@ msg.append(" -inputhandler the class which will handle input requests" + lSep); msg.append(" -find search for buildfile towards the root of the" + lSep); msg.append(" filesystem and use it" + lSep); + msg.append(" -projectclass fully qualified name of a user supplied class" + lSep); + msg.append(" derived from org.apache.tools.ant.Project." + lSep); + msg.append(" If specified, ant will create instances of" + lSep); + msg.append(" this class to represent a project instead of the" + lSep); + msg.append(" default class org.apache.tools.ant.Project." + lSep); + msg.append(" The derived class must implement a public no argument" + lSep); + msg.append(" constructor." + lSep); System.out.println(msg.toString()); } Index: org/apache/tools/ant/ProjectFactory.java =================================================================== RCS file: org/apache/tools/ant/ProjectFactory.java diff -N org/apache/tools/ant/ProjectFactory.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ org/apache/tools/ant/ProjectFactory.java 7 Mar 2003 05:59:49 -0000 @@ -0,0 +1,86 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000-2003 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 "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 + * . + */ + +package org.apache.tools.ant; + +public class ProjectFactory { + private static String projectClassName; + /** + * @return String + */ + public static String getProjectClassName() { + return projectClassName; + } + + /** + * Sets the projectClassName. + * @param projectClassName The projectClassName to set + */ + public static void setProjectClassName(String projectClassName) { + ProjectFactory.projectClassName = projectClassName; + } + + public static Project getProjectInstance() { + try { + Class projectCls = Class.forName(projectClassName); + return (Project)projectCls.newInstance(); + } catch (ClassNotFoundException e) { + throw new BuildException(e); + } catch (InstantiationException e) { + throw new BuildException(e); + } catch (IllegalAccessException e) { + throw new BuildException(e); + } + } +} Index: org/apache/tools/ant/taskdefs/Ant.java =================================================================== RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v retrieving revision 1.75 diff -u -r1.75 Ant.java --- org/apache/tools/ant/taskdefs/Ant.java 10 Feb 2003 14:13:34 -0000 1.75 +++ org/apache/tools/ant/taskdefs/Ant.java 7 Mar 2003 06:00:07 -0000 @@ -67,6 +67,7 @@ import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; +import org.apache.tools.ant.ProjectFactory; import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.Task; import org.apache.tools.ant.util.FileUtils; @@ -149,7 +150,7 @@ * Creates a Project instance for the project to call. */ public void init() { - newProject = new Project(); + newProject = ProjectFactory.getProjectInstance(); newProject.setJavaVersionProperty(); newProject.addTaskDefinition("property", (Class) getProject().getTaskDefinitions()