conor 02/04/17 08:51:07
Modified: proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
CoreExecService.java Frame.java
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser
ProjectHandler.java
proposal/mutant/src/java/antlibs/system antlib.xml
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system
Ant.java
proposal/mutant/src/java/bootstrap/org/apache/ant/builder
BuildHelper.java
proposal/mutant/src/java/common/org/apache/ant/common/model
Project.java
proposal/mutant/src/java/common/org/apache/ant/common/service
ComponentService.java ExecService.java
proposal/mutant/src/java/frontend/org/apache/ant/cli
Commandline.java
Added:
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system
Ref.java
Removed:
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser
RefHandler.java
Log:
Make Projectref's dynamic and task based
Revision Changes Path
1.12 +39 -4
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreExecService.java
Index: CoreExecService.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreExecService.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -u -r1.11 -r1.12
--- CoreExecService.java 12 Apr 2002 14:59:56 -0000 1.11
+++ CoreExecService.java 17 Apr 2002 15:51:06 -0000 1.12
@@ -199,13 +199,50 @@
/**
+ * Parse an XML file into a build model.
+ *
+ * @param xmlBuildFile The file containing the XML build description.
+ * @return A Project model for the build.
+ * @exception ExecutionException if the build cannot be parsed
+ */
+ public Project parseXMLBuildFile(File xmlBuildFile)
+ throws ExecutionException {
+ try {
+ // Parse the build file into a project
+ XMLProjectParser parser = new XMLProjectParser();
+
+ return parser.parseBuildFile(InitUtils.getFileURL(xmlBuildFile));
+ } catch (MalformedURLException e) {
+ throw new ExecutionException(e);
+ } catch (XMLParseException e) {
+ throw new ExecutionException(e);
+ }
+ }
+
+
+ /**
+ * Create a project reference.
+ *
+ * @param referenceName the name under which the project will be
+ * referenced.
+ * @param model the project model.
+ * @exception ExecutionException if the project cannot be referenced.
+ */
+ public void createProjectReference(String referenceName, Project model)
+ throws ExecutionException {
+ frame.createProjectReference(referenceName, model);
+ }
+
+
+ /**
* Setup a sub-build.
*
- * @param antFile the file containing the XML description of the model
* @param properties the initiali properties to be used in the build
+ * @param model XXX Description of the Parameter
* @return Description of the Return Value
* @exception ExecutionException if the subbuild cannot be run
*/
+ /*
public Object setupBuild(File antFile, Map properties)
throws ExecutionException {
try {
@@ -213,7 +250,6 @@
XMLProjectParser parser = new XMLProjectParser();
Project project
= parser.parseBuildFile(InitUtils.getFileURL(antFile));
-
return setupBuild(project, properties);
} catch (MalformedURLException e) {
throw new ExecutionException(e);
@@ -221,8 +257,7 @@
throw new ExecutionException(e);
}
}
-
-
+*/
/**
* Setup a sub-build.
*
1.19 +100 -38
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
Index: Frame.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -w -u -r1.18 -r1.19
--- Frame.java 12 Apr 2002 14:59:56 -0000 1.18
+++ Frame.java 17 Apr 2002 15:51:06 -0000 1.19
@@ -56,9 +56,10 @@
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import java.util.List;
+import java.util.ArrayList;
import org.apache.ant.antcore.config.AntConfig;
import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.event.BuildListener;
@@ -72,7 +73,6 @@
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.service.FileService;
import org.apache.ant.common.service.MagicProperties;
-import org.apache.ant.common.util.ConfigException;
import org.apache.ant.common.util.DemuxOutputReceiver;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.util.FileUtils;
@@ -173,7 +173,8 @@
* @return the string with all property references replaced
* @exception ExecutionException if any of the properties do not exist
*/
- public String replacePropertyRefs(String value) throws
ExecutionException {
+ protected String replacePropertyRefs(String value)
+ throws ExecutionException {
return dataService.replacePropertyRefs(value);
}
@@ -189,15 +190,6 @@
this.project = project;
referencedFrames = new HashMap();
- for (Iterator i = project.getReferencedProjectNames(); i.hasNext();)
{
- String referenceName = (String) i.next();
- Project referencedProject
- = project.getReferencedProject(referenceName);
- Frame referencedFrame = createFrame(referencedProject);
-
- referencedFrames.put(referenceName, referencedFrame);
- }
-
configureServices();
componentManager.setStandardLibraries(standardLibs);
setMagicProperties();
@@ -209,7 +201,7 @@
*
* @return the project's name
*/
- public String getProjectName() {
+ protected String getProjectName() {
if (project != null) {
return project.getName();
}
@@ -547,6 +539,20 @@
}
}
+ /**
+ * Create a project reference.
+ *
+ * @param name the name under which the project will be
+ * referenced.
+ * @param project the project model.
+ * @exception ExecutionException if the project cannot be referenced.
+ */
+ protected void createProjectReference(String name, Project project)
+ throws ExecutionException {
+ Frame referencedFrame = createFrame(project);
+ referencedFrames.put(name, referencedFrame);
+ referencedFrame.initialize();
+ }
/**
* Create a new frame for a given project
@@ -618,8 +624,6 @@
* @exception ExecutionException if there is a problem in the build
*/
protected void runBuild(List targets) throws ExecutionException {
- determineBaseDirs();
-
initialize();
if (targets.isEmpty()) {
// we just execute the default target if any
@@ -641,6 +645,77 @@
}
+
+ /**
+ * Given a fully qualified target name, this method returns the fully
+ * qualified name of the project
+ *
+ * @param fullTargetName the full qualified target name
+ * @return the full name of the containing project
+ */
+ private String getFullProjectName(String fullTargetName) {
+ int index = fullTargetName.lastIndexOf(Project.REF_DELIMITER);
+ if (index == -1) {
+ return null;
+ }
+
+ return fullTargetName.substring(0, index);
+ }
+
+ /**
+ * Flatten the dependencies to the given target
+ *
+ * @param flattenedList the List of targets that must be executed before
+ * the given target
+ * @param fullTargetName the fully qualified name of the target
+ * @exception ExecutionException if the given target does not exist in
the
+ * project hierarchy
+ */
+ private void flattenDependency(List flattenedList, String fullTargetName)
+ throws ExecutionException {
+ if (flattenedList.contains(fullTargetName)) {
+ return;
+ }
+ String fullProjectName = getFullProjectName(fullTargetName);
+ Frame frame = getContainingFrame(fullTargetName);
+ String localTargetName = getNameInFrame(fullTargetName);
+ Target target = frame.getProject().getTarget(localTargetName);
+ if (target == null) {
+ throw new ExecutionException("Target " + fullTargetName
+ + " does not exist");
+ }
+ for (Iterator i = target.getDependencies(); i.hasNext();) {
+ String localDependencyName = (String) i.next();
+ String fullDependencyName = localDependencyName;
+ if (fullProjectName != null) {
+ fullDependencyName = fullProjectName + Project.REF_DELIMITER
+ + localDependencyName;
+ }
+ flattenDependency(flattenedList, fullDependencyName);
+ if (!flattenedList.contains(fullDependencyName)) {
+ flattenedList.add(fullDependencyName);
+ }
+ }
+ }
+
+ /**
+ * get the list of dependent targets which must be evaluated for the
+ * given target.
+ *
+ * @param fullTargetName the full name (in reference space) of the
+ * target
+ * @return the flattened list of targets
+ * @exception ExecutionException if the given target could not be found
+ */
+ protected List getTargetDependencies(String fullTargetName)
+ throws ExecutionException {
+ List flattenedList = new ArrayList();
+ flattenDependency(flattenedList, fullTargetName);
+ flattenedList.add(fullTargetName);
+ return flattenedList;
+ }
+
+
/**
* Execute the tasks of a target in this frame with the given name
*
@@ -649,12 +724,12 @@
* of the target
*/
protected void executeTarget(String targetName) throws
ExecutionException {
+
// to execute a target we must determine its dependencies and
// execute them in order.
- try {
// firstly build a list of fully qualified target names to
execute.
- List dependencyOrder = project.getTargetDependencies(targetName);
+ List dependencyOrder = getTargetDependencies(targetName);
for (Iterator i = dependencyOrder.iterator(); i.hasNext();) {
String fullTargetName = (String) i.next();
@@ -663,9 +738,6 @@
frame.executeTargetTasks(localTargetName);
}
- } catch (ConfigException e) {
- throw new ExecutionException(e);
- }
}
@@ -767,11 +839,7 @@
* failed
*/
protected void initialize() throws ExecutionException {
- for (Iterator i = getReferencedFrames(); i.hasNext();) {
- Frame referencedFrame = (Frame) i.next();
-
- referencedFrame.initialize();
- }
+ determineBaseDir();
Iterator taskIterator = project.getTasks();
@@ -785,7 +853,7 @@
* @exception ExecutionException if the base directories cannot be
* determined
*/
- private void determineBaseDirs() throws ExecutionException {
+ private void determineBaseDir() throws ExecutionException {
if (isDataValueSet(MagicProperties.BASEDIR)) {
baseDir
= new
File(getDataValue(MagicProperties.BASEDIR).toString());
@@ -809,12 +877,6 @@
}
}
setDataValue(MagicProperties.BASEDIR, baseDir.getAbsolutePath(),
true);
-
- for (Iterator i = getReferencedFrames(); i.hasNext();) {
- Frame refFrame = (Frame) i.next();
-
- refFrame.determineBaseDirs();
- }
}
1.6 +2 -13
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/ProjectHandler.java
Index: ProjectHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/ProjectHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -u -r1.5 -r1.6
--- ProjectHandler.java 4 Apr 2002 04:36:13 -0000 1.5
+++ ProjectHandler.java 17 Apr 2002 15:51:06 -0000 1.6
@@ -158,18 +158,7 @@
Attributes attributes)
throws SAXParseException {
- if (qualifiedName.equals(REF_ELEMENT)) {
- RefHandler refHandler = new RefHandler();
- refHandler.start(getParseContext(), getXMLReader(), this,
- getLocator(), attributes, getElementSource(),
- qualifiedName);
- try {
- project.referenceProject(refHandler.getRefName(),
- refHandler.getReferencedProject());
- } catch (ModelException e) {
- throw new SAXParseException(e.getMessage(), getLocator(), e);
- }
- } else if (qualifiedName.equals(INCLUDE_ELEMENT)) {
+ if (qualifiedName.equals(INCLUDE_ELEMENT)) {
IncludeHandler includeHandler = new IncludeHandler(project);
includeHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(),
@@ -193,7 +182,7 @@
project.addTask(buildElementHandler.getBuildElement());
} else {
// ignore namespaced elements
- throw new SAXParseException("Only the \"ant\" namespace is "
+ throw new SAXParseException("namespace support is not "
+ "currently recognized (" + qualifiedName + ")", getLocator());
}
}
1.7 +2 -0
jakarta-ant/proposal/mutant/src/java/antlibs/system/antlib.xml
Index: antlib.xml
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/system/antlib.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- antlib.xml 25 Mar 2002 13:27:18 -0000 1.6
+++ antlib.xml 17 Apr 2002 15:51:06 -0000 1.7
@@ -7,6 +7,8 @@
<taskdef name="ant" classname="org.apache.ant.antlib.system.Ant"/>
<taskdef name="antcall" classname="org.apache.ant.antlib.system.AntCall"/>
+
+ <taskdef name="ref" classname="org.apache.ant.antlib.system.Ref"/>
<taskdef name="parallel"
classname="org.apache.ant.antlib.system.Parallel"/>
<taskdef name="sequential"
classname="org.apache.ant.antlib.system.Sequential"/>
1.9 +18 -8
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java
Index: Ant.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -u -r1.8 -r1.9
--- Ant.java 9 Apr 2002 12:23:53 -0000 1.8
+++ Ant.java 17 Apr 2002 15:51:06 -0000 1.9
@@ -53,8 +53,10 @@
*/
package org.apache.ant.antlib.system;
import java.io.File;
-import org.apache.ant.common.util.ExecutionException;
+import org.apache.ant.common.model.Project;
+import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.service.MagicProperties;
+import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.util.FileUtils;
/**
@@ -71,6 +73,7 @@
/** File to capture any output */
private File outputFile;
+
/**
* sets the file containing the XML representation model to build
*
@@ -80,6 +83,7 @@
this.antFileName = antFileName;
}
+
/**
* Set the base directory for the execution of the build
*
@@ -89,6 +93,7 @@
this.baseDir = baseDir;
}
+
/**
* The output file for capturing the build output
*
@@ -98,6 +103,7 @@
this.outputFile = outputFile;
}
+
/**
* Run the sub-build
*
@@ -109,6 +115,7 @@
}
File antFile = null;
+
if (antFileName == null) {
antFile = new File(baseDir, "build.ant");
if (!antFile.exists()) {
@@ -121,9 +128,12 @@
setProperty(MagicProperties.BASEDIR, baseDir.getAbsolutePath());
- Object key = getExecService().setupBuild(antFile, getProperties());
+ ExecService execService = getExecService();
+ Project model = execService.parseXMLBuildFile(antFile);
+ Object key = execService.setupBuild(model, getProperties());
+
setSubBuildKey(key);
- getExecService().runBuild(key, getTargets());
+ execService.runBuild(key, getTargets());
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ref.java
Index: Ref.java
===================================================================
/*
* 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 [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.io.File;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.model.Project;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.util.ExecutionException;
/**
* A Task to create a project reference.
*
* @author Conor MacNeill
* @created 17 April 2002
*/
public class Ref extends AbstractTask {
/** The project file containing the project to be referenced. */
private File projectFile;
/** THe name under which this project is to be referenced. */
private String name;
/** The core's ExecutionService for running builds and external programs
*/
private ExecService execService;
/**
* Initialise this task
*
* @param context core's context
* @param componentType the component type of this component (i.e its
* defined name in the build file)
* @exception ExecutionException if we can't access the data service
*/
public void init(AntContext context, String componentType)
throws ExecutionException {
super.init(context, componentType);
execService = (ExecService) getCoreService(ExecService.class);
}
/**
* Sets the file containing the XML representation model of the referenced
* project
*
* @param projectFile the file to build
*/
public void setProject(File projectFile) {
this.projectFile = projectFile;
}
/**
* Set the name under which the project will be referenced
*
* @param name the reference label
*/
public void setName(String name) {
this.name = name;
}
/**
* Create the project reference
*
* @exception ExecutionException if the project cannot be referenced.
*/
public void execute() throws ExecutionException {
Project model = execService.parseXMLBuildFile(projectFile);
execService.createProjectReference(name, model);
}
}
1.6 +1 -1
jakarta-ant/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/BuildHelper.java
Index: BuildHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/BuildHelper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -u -r1.5 -r1.6
1.9 +43 -253
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/model/Project.java
Index: Project.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/model/Project.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -u -r1.8 -r1.9
--- Project.java 7 Apr 2002 14:38:07 -0000 1.8
+++ Project.java 17 Apr 2002 15:51:07 -0000 1.9
@@ -60,10 +60,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.StringTokenizer;
import org.apache.ant.common.util.CircularDependencyChecker;
import org.apache.ant.common.util.CircularDependencyException;
-import org.apache.ant.common.util.ConfigException;
import org.apache.ant.common.util.Location;
/**
@@ -98,25 +96,17 @@
/**
* These are the targets which belong to the project. They will have
- * interdependencies which are used to determine which targets need to
- * be executed before a given target.
+ * interdependencies which are used to determine which targets need to be
+ * executed before a given target.
*/
private Map targets = new HashMap();
/**
* The global tasks for this project. These are the tasks that will get
- * executed whenever an execution context is associated with this
- * project.
+ * executed whenever an execution context is associated with this
project.
*/
private List tasks = new ArrayList();
- /**
- * The projects referenced into this project. Each referenced project is
- * given a name which is used to identify access to that project's
- * elements.
- */
- private Map referencedProjects = new HashMap();
-
/** The URL where the project is defined. */
private URL sourceURL;
@@ -192,6 +182,7 @@
return base;
}
+
/**
* Get the name of the project element
*
@@ -201,6 +192,7 @@
return name;
}
+
/**
* Get the targets in this project.
*
@@ -224,29 +216,6 @@
/**
- * Get the names of the referenced projects.
- *
- * @return an iterator which returns the name sof the referenced
- * projects.
- */
- public Iterator getReferencedProjectNames() {
- return referencedProjects.keySet().iterator();
- }
-
-
- /**
- * Get a referenced project by name
- *
- * @param alias the name under which the project was referenced.
- * @return the project asscociated with the given reference alias or
- * null if there is no such project.
- */
- public Project getReferencedProject(String alias) {
- return (Project) referencedProjects.get(alias);
- }
-
-
- /**
* Get the initialisation tasks for this project
*
* @return an iterator over the set of tasks for this project.
@@ -256,85 +225,6 @@
}
/**
- * Get a target by its reference name - references may span multiple
- * references.
- *
- * @param fullTargetName The name of the target relative to this project
- * @return the Target object with the given name
- * @exception ModelException if the given target does not exist in this
- * project
- */
- public Target getRefTarget(String fullTargetName) throws ModelException {
- Project containingProject = getRefProject(fullTargetName);
- if (containingProject == null) {
- throw new ModelException("The target name \"" + fullTargetName
- + "\" does not exist in this project");
- }
-
- if (containingProject == this) {
- return getTarget(fullTargetName);
- }
-
- int index = fullTargetName.lastIndexOf(REF_DELIMITER);
- String targetName
- = fullTargetName.substring(index + REF_DELIMITER.length());
-
- return containingProject.getTarget(targetName);
- }
-
- /**
- * Get the project which directly contains the target specified by its
- * full name.
- *
- * @param fullTargetName the full name of the target for which the
- * containing project is required.
- * @return The RefProject value
- */
- public Project getRefProject(String fullTargetName) {
- int index = fullTargetName.lastIndexOf(REF_DELIMITER);
- if (index == -1) {
- return this;
- }
-
- Project currentProject = this;
- String relativeName = fullTargetName.substring(0, index);
- StringTokenizer tokenizer
- = new StringTokenizer(relativeName, REF_DELIMITER);
- while (tokenizer.hasMoreTokens()) {
- String refName = tokenizer.nextToken();
- currentProject = currentProject.getReferencedProject(refName);
- if (currentProject == null) {
- return null;
- }
- }
-
- return currentProject;
- }
-
- /**
- * get the list of dependent targets which must be evaluated for the
- * given target.
- *
- * @param fullTargetName the full name (in reference space) of the
- * target
- * @return the flattened list of targets
- * @exception ConfigException if the given target could not be found
- */
- public List getTargetDependencies(String fullTargetName)
- throws ConfigException {
- try {
- List flattenedList = new ArrayList();
- flattenDependency(flattenedList, fullTargetName);
- flattenedList.add(fullTargetName);
- return flattenedList;
- } catch (ConfigException e) {
- throw new ConfigException(fullTargetName
- + " does not exist in project");
- }
- }
-
-
- /**
* Add a target to the project.
*
* @param target the Target to be added
@@ -361,47 +251,44 @@
tasks.add(task);
}
-
- /**
- * Reference a project using the given name.
- *
- * @param referenceName the name under which the project will be
- * referenced.
- * @param project the referenced project.
- * @throws ModelException if an existing project has already been
- * referenced with that name.
- */
- public void referenceProject(String referenceName, Project project)
- throws ModelException {
- if (referencedProjects.containsKey(referenceName)) {
- throw new ModelException("A project has already been "
- + "introduced with name '" + referenceName + "'");
- }
- referencedProjects.put(referenceName, project);
- }
-
/**
* Validate this project
*
* @exception ModelException if the project is not valid
*/
public void validate() throws ModelException {
- validate(null);
+ // check whether all of dependencies for our targets
+ // exist in the model
+
+ // visited contains the targets we have already visited and verified
+ Set visited = new HashSet();
+ // checker records the targets we are currently visiting
+ CircularDependencyChecker checker
+ = new CircularDependencyChecker("checking target dependencies");
+ // dependency order is purely recorded for debug purposes
+ List dependencyOrder = new ArrayList();
+
+ for (Iterator i = getTargets(); i.hasNext();) {
+ Target target = (Target) i.next();
+
+ target.validate();
+ fillinDependencyOrder(target, dependencyOrder,
+ visited, checker);
}
+ }
+
/**
- * Determine target dependency order within this porject and verify that
- * references to targets in other projects are valid
+ * Determine target dependency order within this project.
*
- * @param globalName The global name of this project
* @param target The target being examined
* @param dependencyOrder The dependency order of targets
* @param visited Set of targets in this project already visited.
* @param checker A circular dependency checker
- * @exception ModelException if the dependencies of the project's
- * targets are not valid.
+ * @exception ModelException if the dependencies of the project's targets
+ * are not valid.
*/
- public void fillinDependencyOrder(String globalName, Target target,
+ public void fillinDependencyOrder(Target target,
List dependencyOrder, Set visited,
CircularDependencyChecker checker)
throws ModelException {
@@ -411,38 +298,31 @@
try {
String targetName = target.getName();
- String targetGlobalName = targetName;
- if (globalName != null) {
- targetGlobalName = globalName + REF_DELIMITER + targetName;
- }
- checker.visitNode(targetGlobalName);
+ checker.visitNode(targetName);
+
for (Iterator i = target.getDependencies(); i.hasNext();) {
String dependency = (String) i.next();
boolean localTarget = (dependency.indexOf(REF_DELIMITER) ==
-1);
- Target dependencyTarget
- = localTarget ? getTarget(dependency)
- : getRefTarget(dependency);
+ if (localTarget) {
+ Target dependencyTarget = getTarget(dependency);
if (dependencyTarget == null) {
StringBuffer sb = new StringBuffer("Target '");
- if (globalName != null) {
- sb.append(globalName + REF_DELIMITER);
- }
+
sb.append(dependency);
sb.append("' does not exist in this project. ");
throw new ModelException(new String(sb),
target.getLocation());
}
- if (localTarget) {
// need to check the targets we depend on
- fillinDependencyOrder(globalName, dependencyTarget,
+ fillinDependencyOrder(dependencyTarget,
dependencyOrder, visited, checker);
}
}
visited.add(targetName);
- checker.leaveNode(targetGlobalName);
+ checker.leaveNode(targetName);
dependencyOrder.add(targetName);
} catch (CircularDependencyException e) {
throw new ModelException(e.getMessage(),
@@ -450,95 +330,5 @@
}
}
- /**
- * Validate that this build element is configured correctly
- *
- * @param globalName The name of this project in the reference name
- * space
- * @exception ModelException if the element is invalid
- */
- protected void validate(String globalName) throws ModelException {
- Set keys = referencedProjects.keySet();
- for (Iterator i = keys.iterator(); i.hasNext();) {
- String refName = (String) i.next();
- Project referencedProject
- = (Project) referencedProjects.get(refName);
- String refGlobalName = refName;
- if (globalName != null) {
- refGlobalName = globalName + REF_DELIMITER + refName;
- }
- referencedProject.validate(refGlobalName);
- }
-
- // we now check whether all of dependencies for our targets
- // exist in the model
-
- // visited contains the targets we have already visited and verified
- Set visited = new HashSet();
- // checker records the targets we are currently visiting
- CircularDependencyChecker checker
- = new CircularDependencyChecker("checking target dependencies");
- // dependency order is purely recorded for debug purposes
- List dependencyOrder = new ArrayList();
-
- for (Iterator i = getTargets(); i.hasNext();) {
- Target target = (Target) i.next();
- target.validate();
- fillinDependencyOrder(globalName, target, dependencyOrder,
- visited, checker);
- }
- }
-
- /**
- * Given a fully qualified target name, this method returns the fully
- * qualified name of the project
- *
- * @param fullTargetName the full qualified target name
- * @return the full name of the containing project
- */
- private String getFullProjectName(String fullTargetName) {
- int index = fullTargetName.lastIndexOf(REF_DELIMITER);
- if (index == -1) {
- return null;
- }
-
- return fullTargetName.substring(0, index);
- }
-
- /**
- * Flatten the dependencies to the given target
- *
- * @param flattenedList the List of targets that must be executed before
- * the given target
- * @param fullTargetName the fully qualified name of the target
- * @exception ConfigException if the given target does not exist in the
- * project hierarchy
- */
- private void flattenDependency(List flattenedList, String fullTargetName)
- throws ConfigException {
- if (flattenedList.contains(fullTargetName)) {
- return;
- }
- try {
- String fullProjectName = getFullProjectName(fullTargetName);
- Target target = getRefTarget(fullTargetName);
- if (target == null) {
- throw new ConfigException("Target " + fullTargetName
- + " does not exist");
- }
- for (Iterator i = target.getDependencies(); i.hasNext();) {
- String localDependencyName = (String) i.next();
- String fullDependencyName
- = fullProjectName == null ? localDependencyName
- : fullProjectName + REF_DELIMITER + localDependencyName;
- flattenDependency(flattenedList, fullDependencyName);
- if (!flattenedList.contains(fullDependencyName)) {
- flattenedList.add(fullDependencyName);
- }
- }
- } catch (ModelException e) {
- throw new ConfigException(e);
- }
- }
}
1.11 +1 -1
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java
Index: ComponentService.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -u -r1.10 -r1.11
1.8 +35 -19
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ExecService.java
Index: ExecService.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ExecService.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -u -r1.7 -r1.8
--- ExecService.java 9 Apr 2002 12:23:53 -0000 1.7
+++ ExecService.java 17 Apr 2002 15:51:07 -0000 1.8
@@ -67,37 +67,50 @@
*/
public interface ExecService {
/**
- * Setup a sub-build.
+ * Parse an XML file into a build model.
*
- * @param antFile the file containing the XML description of the model
- * @param properties the initiali properties to be used in the build
- * @exception ExecutionException if the subbuild cannot be setup
- * @return a key to the build allowing it to be executed and managed
+ * @param xmlBuildFile The file containing the XML build description.
+ * @return A Project model for the build.
+ * @exception ExecutionException if the build cannot be parsed
*/
- Object setupBuild(File antFile, Map properties)
+ Project parseXMLBuildFile(File xmlBuildFile) throws ExecutionException;
+
+
+ /**
+ * Create a project reference.
+ *
+ * @param referenceName the name under which the project will be
+ * referenced.
+ * @param model the project model.
+ * @exception ExecutionException if the project cannot be referenced.
+ */
+ void createProjectReference(String referenceName, Project model)
throws ExecutionException;
+
/**
* Setup a sub-build.
*
* @param model the project model to be used for the build
* @param properties the initiali properties to be used in the build
- * @exception ExecutionException if the subbuild cannot be setup
* @return a key to the build allowing it to be executed and managed
+ * @exception ExecutionException if the subbuild cannot be setup
*/
Object setupBuild(Project model, Map properties)
throws ExecutionException;
+
/**
* Setup a sub-build using the current frame's project model
*
* @param properties the initiali properties to be used in the build
- * @exception ExecutionException if the subbuild cannot be setup
* @return a key to the build allowing it to be executed and managed
+ * @exception ExecutionException if the subbuild cannot be setup
*/
Object setupBuild(Map properties)
throws ExecutionException;
+
/**
* Run a build which have been previously setup
*
@@ -108,15 +121,17 @@
*/
void runBuild(Object buildKey, List targets) throws ExecutionException;
+
/**
- * execute a task. The task should have already been initialised by
- * the core
+ * execute a task. The task should have already been initialised by the
+ * core
*
* @param task the task to be executed.
* @exception ExecutionException if there is a problem in execution.
*/
void executeTask(Task task) throws ExecutionException;
+
/**
* get the name of the project associated with this execution.
*
@@ -124,6 +139,7 @@
*/
String getProjectName();
+
/**
* Get the basedir for the current execution
*
@@ -131,13 +147,13 @@
*/
File getBaseDir();
+
/**
* Handle subbuild output.
*
* @param subbuildKey the core's key for managing the subbuild.
* @param line the content produce by the current thread.
* @param isErr true if this content is from the thread's error stream.
- *
* @exception ExecutionException if the subbuild cannot be found.
*/
void handleBuildOutput(Object subbuildKey, String line, boolean isErr)
1.2 +0 -3
jakarta-ant/proposal/mutant/src/java/frontend/org/apache/ant/cli/Commandline.java
Index: Commandline.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/frontend/org/apache/ant/cli/Commandline.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- Commandline.java 16 Apr 2002 14:07:47 -0000 1.1
+++ Commandline.java 17 Apr 2002 15:51:07 -0000 1.2
@@ -53,7 +53,6 @@
*/
package org.apache.ant.cli;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
@@ -66,10 +65,8 @@
import java.util.List;
import java.util.Map;
import org.apache.ant.antcore.config.AntConfig;
-import org.apache.ant.antcore.config.AntConfigHandler;
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;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>