You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ad...@apache.org on 2002/06/02 16:08:07 UTC
cvs commit: jakarta-ant-myrmidon/framework/src/todo/org/apache/tools/todo/taskdefs/text FixCRLF.java
adammurdoch 2002/06/02 07:08:07
Modified: . build.xml
antlib/src/java/org/apache/antlib/core
LoadPropertyFileTask.java
antlib/src/java/org/apache/antlib/project
AbstractWorkspaceTask.java AntCallTask.java
DefaultProjectListener.java Resources.properties
TargetTask.java
container/src/java/org/apache/myrmidon/components/builder
DefaultProject.java DefaultProjectBuilder.java
Resources.properties
container/src/java/org/apache/myrmidon/components/embeddor
DefaultEmbeddor.java
container/src/java/org/apache/myrmidon/components/workspace
DefaultWorkspace.java Resources.properties
container/src/java/org/apache/myrmidon/interfaces
EmbeddedAnt.java Resources.properties
container/src/java/org/apache/myrmidon/interfaces/embeddor
Embeddor.java
container/src/java/org/apache/myrmidon/interfaces/model
Module.java
container/src/java/org/apache/myrmidon/interfaces/oldmodel
Project.java Target.java
container/src/java/org/apache/myrmidon/interfaces/workspace
Workspace.java
container/src/test/org/apache/myrmidon/components/builder/test
DefaultProjectBuilderTestCase.java defaults.ant
set-base-dir.ant set-project-name.ant
container/src/test/org/apache/myrmidon/components/embeddor/test
DefaultEmbeddorTest.java
framework/src/java/org/apache/myrmidon/framework
ExecuteTarget.java
framework/src/java/org/apache/myrmidon/framework/listener
AbstractProjectListener.java
framework/src/todo/org/apache/tools/todo/taskdefs/text
FixCRLF.java
Log:
A bunch of changes to the project model:
* Moved responsibility for workspace creation from Embeddor to Module, and
removed Module.executeTarget().
* Trimmed Workspace down to a single executeTarget( TargetMetaData ) method.
* Reverted Project.getProjectRef() back to Project.getProject(). Still
does the on-demand loading of referenced projects, but the workspace is
no longer responsible for doing so.
* Removed Project.setWorkspace(), getName(), and getImplicitTarget(). Replaced
getDefaultTargetName() with getDefaultTarget().
* Added Target.getProject(). Not sure about this one.
* Moved execution of the implicit target from DefaultWorkspace to TargetTask.
Revision Changes Path
1.19 +4 -0 jakarta-ant-myrmidon/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/build.xml,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- build.xml 19 May 2002 08:28:39 -0000 1.18
+++ build.xml 2 Jun 2002 14:08:05 -0000 1.19
@@ -84,6 +84,10 @@
<param name="build-subproject.target" value="test"/>
</antcall>
</target>
+ <target name="taskdoc" description="Generates the taskdoc for all projects" depends="build-files">
+ <ant dir="buildtools" antfile="${buildfile.name}" target="jars"/>
+ <ant dir="myrmidon" antfile="${buildfile.name}" target="taskdoc"/>
+ </target>
<target name="dist-lite" description="Creates a minimal distribution">
<antcall target="-for-all-projects">
<param name="build-subproject.target" value="dist-lite"/>
1.3 +3 -0 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/LoadPropertyFileTask.java
Index: LoadPropertyFileTask.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/LoadPropertyFileTask.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LoadPropertyFileTask.java 24 May 2002 04:30:59 -0000 1.2
+++ LoadPropertyFileTask.java 2 Jun 2002 14:08:05 -0000 1.3
@@ -28,6 +28,9 @@
private File m_file;
+ /**
+ * Sets the file to load properties from.
+ */
public void setFile( final File file )
{
m_file = file;
1.3 +17 -29 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractWorkspaceTask.java
Index: AbstractWorkspaceTask.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractWorkspaceTask.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractWorkspaceTask.java 24 May 2002 06:50:26 -0000 1.2
+++ AbstractWorkspaceTask.java 2 Jun 2002 14:08:05 -0000 1.3
@@ -12,14 +12,14 @@
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.AbstractContainerTask;
import org.apache.myrmidon.interfaces.oldmodel.Project;
-import org.apache.myrmidon.interfaces.oldmodel.ProjectRef;
+import org.apache.myrmidon.interfaces.oldmodel.Target;
import org.apache.myrmidon.interfaces.workspace.Workspace;
/**
* An abstract class used to execute Ant files within same workspace.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.2 $ $Date: 2002/05/24 06:50:26 $
+ * @version $Revision: 1.3 $ $Date: 2002/06/02 14:08:05 $
*/
abstract class AbstractWorkspaceTask
extends AbstractContainerTask
@@ -28,7 +28,7 @@
ResourceManager.getPackageResources( AbstractWorkspaceTask.class );
/**
- * Execute specified Dependency in the current Workspace.
+ * Execute specified Dependency in the same Workspace as this task.
*
* @param dependency the dependency to execute
* @throws TaskException if error occurs executing dependency
@@ -41,60 +41,48 @@
dependency );
getContext().debug( message );
- final String uri = getProjectURI( dependency );
+ // Locate the referenced target
+ final Project project = getProject( dependency );
final String targetName = dependency.getTargetName();
- executeTarget( uri, targetName );
+ final Target target = project.getTarget( targetName );
+
+ executeTarget( target );
}
/**
- * Utility method to execute target in project file specified
- * by URI. The execution is take place in the same Workspace
- * as the current task.
+ * Utility method to execute a target. The execution takes place in the
+ * same Workspace as this task.
*
- * @param uri the projects URI
- * @param targetName the name of target to execute
+ * @param target the name of target to execute
* @throws TaskException if error occurs executing target
*/
- protected final void executeTarget( final String uri,
- final String targetName )
+ protected final void executeTarget( final Target target )
throws TaskException
{
final Workspace workspace =
(Workspace)getContext().getService( Workspace.class );
- workspace.executeTarget( uri, targetName );
+ workspace.executeTarget( target );
}
/**
- * Get the URI for project that specified in dependency.
+ * Get the project referenced in a dependency.
*
* @param dependency the dependency
* @return
* @throws TaskException
*/
- protected final String getProjectURI( final Dependency dependency )
+ protected final Project getProject( final Dependency dependency )
throws TaskException
{
final Project project = (Project)getContext().getService( Project.class );
final String projectName = dependency.getProjectName();
if( null == projectName )
{
- return project.getURI();
+ return project;
}
else
{
- final ProjectRef projectRef = project.getProjectRef( projectName );
- if( null != projectRef )
- {
- return projectRef.getUri();
- }
- else
- {
- final String message =
- REZ.getString( "workspace.missing-dependency.error",
- getContext().getLocation(),
- projectName );
- throw new TaskException( message );
- }
+ return project.getProject( projectName );
}
}
}
1.3 +3 -14 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntCallTask.java
Index: AntCallTask.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntCallTask.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AntCallTask.java 21 May 2002 07:57:14 -0000 1.2
+++ AntCallTask.java 2 Jun 2002 14:08:05 -0000 1.3
@@ -20,7 +20,7 @@
* or a referenced project.
*
* @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
- * @version $Revision: 1.2 $ $Date: 2002/05/21 07:57:14 $
+ * @version $Revision: 1.3 $ $Date: 2002/06/02 14:08:05 $
* @ant.task name="ant-call"
*/
public class AntCallTask
@@ -56,19 +56,8 @@
}
else
{
- final ProjectRef projectRef = currentProject.getProjectRef( m_project );
- if( projectRef == null )
- {
- final String message =
- REZ.getString( "antcall.invalid-project.error" );
- throw new TaskException( message );
- }
-
- //Warning next line will not work in all cases
- //We need to assume that all references are to file
- //based URIS which is true now but maybe not in the future.
- final File file = new File( projectRef.getUri() );
- exe.setProjectFile( file, null );
+ final Project refProject = currentProject.getProject( m_project );
+ exe.setProject( refProject );
}
}
}
1.3 +2 -2 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/DefaultProjectListener.java
Index: DefaultProjectListener.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/DefaultProjectListener.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultProjectListener.java 29 May 2002 13:03:31 -0000 1.2
+++ DefaultProjectListener.java 2 Jun 2002 14:08:05 -0000 1.3
@@ -14,10 +14,10 @@
import org.apache.myrmidon.framework.listener.ProjectEvent;
/**
- * Default listener that emulates the Ant 1.x no banner listener.
+ * A listener that emulates Ant 1.x logging.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.2 $ $Date: 2002/05/29 13:03:31 $
+ * @version $Revision: 1.3 $ $Date: 2002/06/02 14:08:05 $
* @ant.type type="project-listener" name="default"
*/
public class DefaultProjectListener
1.10 +0 -3 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/Resources.properties,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Resources.properties 28 May 2002 03:51:07 -0000 1.9
+++ Resources.properties 2 Jun 2002 14:08:05 -0000 1.10
@@ -6,13 +6,10 @@
target.bad-dependency.error=Discovered empty dependency in target "{0}" at {1}.
workspace.exec-depends.notice=Executing dependency: {0}
-workspace.missing-dependency.error=Dependency "{1}" at location "{0}" is missing.
depends.no-target.error=No target specified in <depends/> task.
param.noname.error=Missing name from parameter.
param.novalue.error=Missing value from parameter "{0}".
-
-antcall.invalid-project.error=Project-reference "{0}" not found.
project.no-project-element.error=Project file must be enclosed in project element.
1.11 +9 -5 jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/TargetTask.java
Index: TargetTask.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/TargetTask.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TargetTask.java 29 May 2002 06:42:25 -0000 1.10
+++ TargetTask.java 2 Jun 2002 14:08:05 -0000 1.11
@@ -21,7 +21,7 @@
* A simple task to task to execute a group of tasks.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.10 $ $Date: 2002/05/29 06:42:25 $
+ * @version $Revision: 1.11 $ $Date: 2002/06/02 14:08:05 $
* @ant.task name="target"
*/
public class TargetTask
@@ -146,14 +146,18 @@
private void executeDependencies()
throws TaskException
{
- if( null == m_dependencies )
+ // Execute implicit target first
+ if( ! m_name.equals( Project.IMPLICIT_TARGET_NAME ) )
{
- return;
+ executeDependency( new Dependency( null, Project.IMPLICIT_TARGET_NAME ) );
}
- for( int i = 0; i < m_dependencies.length; i++ )
+ if( null != m_dependencies )
{
- executeDependency( m_dependencies[ i ] );
+ for( int i = 0; i < m_dependencies.length; i++ )
+ {
+ executeDependency( m_dependencies[ i ] );
+ }
}
}
1.18 +98 -80 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProject.java
Index: DefaultProject.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProject.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DefaultProject.java 23 May 2002 06:08:58 -0000 1.17
+++ DefaultProject.java 2 Jun 2002 14:08:05 -0000 1.18
@@ -11,24 +11,32 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import java.util.Iterator;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.myrmidon.api.TaskException;
+import org.apache.myrmidon.components.workspace.DefaultWorkspace;
+import org.apache.myrmidon.interfaces.embeddor.Embeddor;
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
import org.apache.myrmidon.interfaces.model.TargetMetaData;
import org.apache.myrmidon.interfaces.oldmodel.Project;
-import org.apache.myrmidon.interfaces.oldmodel.Target;
import org.apache.myrmidon.interfaces.oldmodel.ProjectRef;
+import org.apache.myrmidon.interfaces.oldmodel.Target;
import org.apache.myrmidon.interfaces.workspace.Workspace;
/**
* Default project implementation.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.17 $ $Date: 2002/05/23 06:08:58 $
+ * @version $Revision: 1.18 $ $Date: 2002/06/02 14:08:05 $
*/
public class DefaultProject
+ extends AbstractLogEnabled
implements Project, TargetMetaData
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( DefaultProject.class );
+
/**
* The project name
*/
@@ -52,60 +60,51 @@
/**
* The project references in this project
*/
- private final HashMap m_references;
+ private final Map m_references = new HashMap();
+
+ /**
+ * Other projects referenced by this project
+ */
+ private final Map m_projects = new HashMap();
/**
* The targets contained by this project
*/
- private final HashMap m_targets;
+ private final Map m_targets = new HashMap();
- private Workspace m_workspace;
+ private Embeddor m_embeddor;
public DefaultProject( final String name,
final String uri,
final File baseDirectory,
final String defaultTarget,
- final Map references,
- final Map targets )
+ final Embeddor embeddor )
{
m_name = name;
m_uri = uri;
m_baseDirectory = baseDirectory;
m_defaultTarget = defaultTarget;
+ m_embeddor = embeddor;
+ }
- m_references = new HashMap();
- final Iterator refKeys = references.keySet().iterator();
- while( refKeys.hasNext() )
- {
- final Object key = refKeys.next();
- final Object ref = references.get( key );
- if( ref instanceof ProjectRef )
- {
- m_references.put( key, ref );
- }
- else
- {
- final String message = key + " instanceof " + ref.getClass().getName();
- throw new ClassCastException( message );
- }
- }
-
- m_targets = new HashMap();
- final Iterator targetKeys = targets.keySet().iterator();
- while( targetKeys.hasNext() )
- {
- final Object key = targetKeys.next();
- final Object target = targets.get( key );
- if( target instanceof Target )
- {
- m_targets.put( key, target );
- }
- else
- {
- final String message = key + " instanceof " + target.getClass().getName();
- throw new ClassCastException( message );
- }
+ /**
+ * Adds a project reference to this project.
+ */
+ public void addProjectRef( final ProjectRef ref )
+ {
+ m_references.put( ref.getName(), ref );
+ }
+
+ /**
+ * Adds a target to this project.
+ */
+ public void addTarget( final Target target )
+ {
+ if( target.getProject() != this )
+ {
+ throw new IllegalArgumentException();
}
+ m_targets.put( target.getName(), target);
}
public String getURI()
@@ -114,15 +113,49 @@
}
/**
- * Retrieve project reference for specified name.
- * The name is local name of project.
+ * Returns a referenced project.
*
- * @param name the name project referenced with
- * @return the ProjectRef
+ * @param name the project name
+ * @return the project.
+ * @throws TaskException if the request project is unknown.
*/
- public ProjectRef getProjectRef( final String name )
+ public Project getProject( final String name ) throws TaskException
{
- return (ProjectRef)m_references.get( name );
+ // TODO - this does not handle dependency cycles between projects
+ Project other = (Project)m_projects.get( name );
+ if( null == other )
+ {
+ other = createProject( name );
+ m_projects.put( name, other );
+ }
+
+ return other;
+ }
+
+ /**
+ * Creates project referenced by this project.
+ */
+ private Project createProject( final String name )
+ throws TaskException
+ {
+ final ProjectRef ref = (ProjectRef)m_references.get( name );
+ if( ref == null )
+ {
+ final String message = REZ.getString( "project.unknown-ref.error", name );
+ throw new TaskException( message );
+ }
+
+ final String uri = ref.getUri();
+ try
+ {
+ return m_embeddor.createProject( uri, null, null );
+ }
+ catch( final Exception e )
+ {
+ final String message =
+ REZ.getString( "project.nobuild-project.error", uri );
+ throw new TaskException( message, e );
+ }
}
/**
@@ -136,36 +169,29 @@
}
/**
- * Retrieve implicit target.
- * The implicit target contains all the top level tasks.
+ * Return the default target for this project.
*
- * @return the Target
+ * @return the default target name
+ * @throws TaskException if the project has no default target.
*/
- public final Target getImplicitTarget()
+ public Target getDefaultTarget() throws TaskException
{
- return getTarget( Project.IMPLICIT_TARGET_NAME );
+ return getTarget( m_defaultTarget );
}
-
/**
* Retrieve a target by name.
- *
- * @param targetName the name of target
- * @return the Target or null if no target exists with name
*/
public final Target getTarget( final String targetName )
+ throws TaskException
{
- return (Target)m_targets.get( targetName );
- }
-
- /**
- * Get name of default target.
- *
- * @return the default target name
- */
- public final String getDefaultTargetName()
- {
- return m_defaultTarget;
+ final Target target = (Target)m_targets.get( targetName );
+ if( target == null )
+ {
+ final String message = REZ.getString( "project.unknown-target.error", targetName );
+ throw new TaskException( message );
+ }
+ return target;
}
/**
@@ -214,22 +240,14 @@
}
/**
- * Execute the specified target in module
- * using specified {@link ExecutionFrame}.
- *
- * @param frame the frame in which to execute
- * @param target the target to execute
- * @throws TaskException if an error occurs executing module
+ * Creates a new workspace to execute this project in.
*/
- public void execute( final ExecutionFrame frame, final TargetMetaData target )
+ public Workspace createWorkspace( final ExecutionFrame frame )
throws TaskException
{
- m_workspace.setFrame( frame );
- m_workspace.executeProject( this, target.getName() );
- }
-
- public void setWorkspace( final Workspace workspace )
- {
- m_workspace = workspace;
+ final DefaultWorkspace workspace = new DefaultWorkspace();
+ setupLogger( workspace );
+ workspace.setFrame( frame );
+ return workspace;
}
}
1.65 +18 -20 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
Index: DefaultProjectBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- DefaultProjectBuilder.java 29 May 2002 06:42:26 -0000 1.64
+++ DefaultProjectBuilder.java 2 Jun 2002 14:08:05 -0000 1.65
@@ -11,7 +11,6 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.HashMap;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.io.FileUtil;
@@ -29,12 +28,13 @@
import org.apache.myrmidon.interfaces.oldmodel.Target;
import org.apache.myrmidon.interfaces.property.NameValidator;
import org.apache.myrmidon.interfaces.property.NameValidatorManager;
+import org.apache.myrmidon.interfaces.embeddor.Embeddor;
/**
* Default implementation to construct project from a build file.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.64 $ $Date: 2002/05/29 06:42:26 $
+ * @version $Revision: 1.65 $ $Date: 2002/06/02 14:08:05 $
*
* @ant.type type="project-builder" name="ant2"
*/
@@ -55,10 +55,12 @@
// Use a name validator with the default rules.
private NameValidator m_nameValidator;
private ModelBuilder m_modelBuilder;
+ private Embeddor m_embeddor;
public void service( final ServiceManager manager )
throws ServiceException
{
+ m_embeddor = (Embeddor)manager.lookup( Embeddor.ROLE );
m_modelBuilder = (ModelBuilder)manager.lookup( ModelBuilder.ROLE );
final NameValidatorManager validatorManager =
(NameValidatorManager)manager.lookup( NameValidatorManager.ROLE );
@@ -145,18 +147,16 @@
verifyVersion( version );
- final HashMap refs = new HashMap();
- final HashMap targets = new HashMap();
- buildTopLevelProject( baseDirectory, model, refs, targets );
-
- // Build the project model and add to cache
-
- return new DefaultProject( projectName,
- uri,
- baseDirectory,
- defaultTarget,
- refs,
- targets );
+ DefaultProject project =
+ new DefaultProject( projectName,
+ uri,
+ baseDirectory,
+ defaultTarget,
+ m_embeddor );
+ setupLogger( project );
+ buildTopLevelProject( baseDirectory, model, project );
+
+ return project;
}
catch( Exception e )
{
@@ -346,8 +346,7 @@
*/
private void buildTopLevelProject( final File baseDirectory,
final ModelElement model,
- final HashMap refs,
- final HashMap targets )
+ final DefaultProject project )
throws Exception
{
final ModelElement implicit = new ModelElement( "target", model.getLocation() );
@@ -367,7 +366,7 @@
if( name.equals( "projectref" ) )
{
final ProjectRef ref = buildProjectRef( baseDirectory, element );
- refs.put( ref.getName(), ref );
+ project.addProjectRef( ref );
continue;
}
else
@@ -392,8 +391,7 @@
if( name.equals( "target" ) )
{
- final String target = element.getAttribute( "name" );
- targets.put( target, new Target( element ) );
+ project.addTarget( new Target( project, element ) );
}
else
{
@@ -403,7 +401,7 @@
throw new ProjectException( message );
}
}
- targets.put( Project.IMPLICIT_TARGET_NAME, new Target( implicit ) );
+ project.addTarget( new Target( project, implicit ) );
}
private ProjectRef buildProjectRef( final File baseDirectory,
1.12 +5 -1 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/Resources.properties,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Resources.properties 27 May 2002 13:39:34 -0000 1.11
+++ Resources.properties 2 Jun 2002 14:08:05 -0000 1.12
@@ -29,4 +29,8 @@
duplicate-project.error=Can not have two projects referenced in a file with the name {0}.
duplicate-target.error=Can not have two targets in a file with the name {0}.
-saxhandler.mixedmodel.error={0}: Cannot mix nested elements and text content.
\ No newline at end of file
+saxhandler.mixedmodel.error={0}: Cannot mix nested elements and text content.
+
+project.unknown-ref.error=Unknown project reference "{0}".
+project.nobuild-project.error=Could not load referenced project "{0}".
+project.unknown-target.error=Unknown target "{0}".
\ No newline at end of file
1.80 +1 -15 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
Index: DefaultEmbeddor.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- DefaultEmbeddor.java 29 May 2002 13:03:32 -0000 1.79
+++ DefaultEmbeddor.java 2 Jun 2002 14:08:06 -0000 1.80
@@ -58,14 +58,13 @@
import org.apache.myrmidon.interfaces.type.TypeFactory;
import org.apache.myrmidon.interfaces.type.TypeManager;
import org.apache.myrmidon.interfaces.type.TypeRegistry;
-import org.apache.myrmidon.interfaces.workspace.Workspace;
/**
* Default implementation of Embeddor.
* Instantiate this to embed inside other applications.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.79 $ $Date: 2002/05/29 13:03:32 $
+ * @version $Revision: 1.80 $ $Date: 2002/06/02 14:08:06 $
*/
public class DefaultEmbeddor
extends AbstractLogEnabled
@@ -171,19 +170,6 @@
return new DefaultExecutionFrame( "",
new File( "." ),
manager );
- }
-
- /**
- * Creates a workspace.
- */
- public Workspace createWorkspace()
- throws Exception
- {
- final Workspace workspace =
- (Workspace)createService( Workspace.class, PREFIX + "workspace.DefaultWorkspace" );
- setupObject( workspace, null, null );
-
- return workspace;
}
/**
1.73 +16 -131 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
Index: DefaultWorkspace.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- DefaultWorkspace.java 27 May 2002 08:30:30 -0000 1.72
+++ DefaultWorkspace.java 2 Jun 2002 14:08:06 -0000 1.73
@@ -7,36 +7,36 @@
*/
package org.apache.myrmidon.components.workspace;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.DefaultServiceManager;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.metadata.ModelElement;
+import org.apache.myrmidon.interfaces.configurer.Configurer;
import org.apache.myrmidon.interfaces.deployer.Deployer;
-import org.apache.myrmidon.interfaces.embeddor.Embeddor;
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
import org.apache.myrmidon.interfaces.executor.Executor;
+import org.apache.myrmidon.interfaces.model.TargetMetaData;
import org.apache.myrmidon.interfaces.oldmodel.Project;
import org.apache.myrmidon.interfaces.oldmodel.Target;
import org.apache.myrmidon.interfaces.service.ScopedService;
import org.apache.myrmidon.interfaces.type.TypeManager;
import org.apache.myrmidon.interfaces.type.TypeRegistry;
import org.apache.myrmidon.interfaces.workspace.Workspace;
-import org.apache.myrmidon.interfaces.configurer.Configurer;
/**
* This is the default implementation of Workspace.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.72 $ $Date: 2002/05/27 08:30:30 $
+ * @version $Revision: 1.73 $ $Date: 2002/06/02 14:08:06 $
* @todo Merge m_entries and m_projects
*/
public class DefaultWorkspace
@@ -46,74 +46,35 @@
private static final Resources REZ =
ResourceManager.getPackageResources( DefaultWorkspace.class );
- /**
- * Name of implicit target.
- */
- private static final String IMPLICIT_TARGET_NAME = "<init>";
-
- /** A map from Project object -> ProjectEntry for that project. */
+ /** A map from Project uri -> ProjectEntry for that project. */
private HashMap m_entries = new HashMap();
- /** A cach of Project objects. */
- private HashMap m_projects = new HashMap();
-
/**
* The root execution frame.
*/
private ExecutionFrame m_frame;
/**
- * The embeddor to use to build projects.
+ * Sets the root execution frame for this workspace.
*/
- private Embeddor m_embeddor;
-
public void setFrame( final ExecutionFrame frame )
- throws TaskException
{
m_frame = frame;
- try
- {
- m_embeddor = (Embeddor)frame.getServiceManager().lookup( Embeddor.ROLE );
- }
- catch( final ServiceException se )
- {
- throw new TaskException( se.getMessage(), se );
- }
}
/**
- * Execute a target in a particular project.
- * Execute in the project context.
- *
- * @param project the Project
- * @param target the name of the target
- * @throws TaskException if an error occurs
+ * Executes a target.
*/
- public void executeProject( final Project project,
- final String target )
+ public void executeTarget( final TargetMetaData metaData )
throws TaskException
{
+ final Target target = (Target)metaData;
+ final Project project = target.getProject();
final ProjectEntry entry = getProjectEntry( project, m_frame );
- m_projects.put( project.getURI(), project );
executeTarget( entry, target );
}
/**
- * Executes a target in context of workspace.
- * The project is specified by URI.
- *
- * @param uri the URI of the Project
- * @param targetName the name of the target to execute
- * @throws TaskException if an error occurs
- */
- public void executeTarget( String uri, String targetName )
- throws TaskException
- {
- final Project project = getProject( uri );
- executeProject( project, targetName );
- }
-
- /**
* Creates an execution frame for a project.
*/
private ExecutionFrame createExecutionFrame( final Project project,
@@ -144,7 +105,7 @@
serviceManager.put( Workspace.ROLE, this );
serviceManager.put( Project.ROLE, project );
- return frame.createChildFrame( project.getName(),
+ return frame.createChildFrame( project.getMetaData().getName(),
project.getBaseDirectory(),
serviceManager,
true );
@@ -227,85 +188,19 @@
return entry;
}
- private Project getProject( final String uri )
- throws TaskException
- {
- Project other = (Project)m_projects.get( uri );
- if( null == other )
- {
- other = createProject( uri );
- m_projects.put( uri, other );
- }
-
- return other;
- }
-
- /**
- * Create project referred to by specified name and located
- * at specified URI.
- *
- * @param uri the URI of project
- * @return the created project
- * @throws TaskException if there is an error creating project
- */
- private Project createProject( final String uri )
- throws TaskException
- {
- Project other;
- try
- {
- other = m_embeddor.createProject( uri, null, null );
- }
- catch( final Exception e )
- {
- final String message =
- REZ.getString( "workspace.nobuild-project.error",
- uri,
- e );
- throw new TaskException( message, e );
- }
- return other;
- }
-
- /**
- * Helper method to execute a target.
- *
- * @param entry the project to execute
- * @param targetName the name of the target to execute
- * @throws TaskException if an error occurs
- */
- private void executeTarget( final ProjectEntry entry,
- final String targetName )
- throws TaskException
- {
- // Locate the target
- final Target target = entry.getProject().getTarget( targetName );
- if( null == target )
- {
- final String message = REZ.getString( "no-target.error", targetName );
- throw new TaskException( message );
- }
-
- executeTarget( entry, targetName, target );
- }
-
/**
* Executes a target. Does not execute the target if it has already been
* executed. Executes the dependencies of the target, before executing
* the target itself.
*
- * @param name the name of target
* @param target the target
* @param entry the project in which to execute
* @throws TaskException if an error occurs
*/
private void executeTarget( final ProjectEntry entry,
- final String name,
final Target target )
throws TaskException
{
- final Project project = entry.getProject();
-
// Check target state, to see if it has already been executed, and
// to check for dependency cycles
final TargetState state = entry.getTargetState( target );
@@ -317,23 +212,15 @@
else if( state == TargetState.TRAVERSING )
{
// Cycle in target dependencies
- final String message = REZ.getString( "target-dependency-cycle.error", name );
+ final String message = REZ.getString( "target-dependency-cycle.error", target.getName() );
throw new TaskException( message );
}
// Set state to indicate this target has been started
entry.setTargetState( target, TargetState.TRAVERSING );
- // Execute the target's dependencies
-
- // Implicit target first
- if( target != project.getImplicitTarget() )
- {
- executeTarget( entry, IMPLICIT_TARGET_NAME, project.getImplicitTarget() );
- }
-
// Now execute the target itself
- executeTargetNoDeps( entry, name, target );
+ executeTargetNoDeps( entry, target );
// Mark target as complete
entry.setTargetState( target, TargetState.FINISHED );
@@ -345,18 +232,16 @@
* executed.
*
* @param entry the project to execute the target in.
- * @param name the name of the target.
* @param target the target itself
*/
private void executeTargetNoDeps( final ProjectEntry entry,
- final String name,
final Target target )
throws TaskException
{
final ModelElement targetModel = target.getModel();
final ExecutionFrame frame =
- entry.getFrame().createChildFrame( name, null, null, false );
+ entry.getFrame().createChildFrame( target.getName(), null, null, false );
Executor executor;
try
{
1.14 +0 -2 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/Resources.properties,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Resources.properties 23 May 2002 04:31:15 -0000 1.13
+++ Resources.properties 2 Jun 2002 14:08:06 -0000 1.14
@@ -2,11 +2,9 @@
bad-deployer-config.error=Error configuring deployer.
bad-frame.error=Error setting up ExecutionFrame.
no-project.error=Project {0} not found.
-no-target.error=Target {0} not found.
exec-target.notice=Executing project {0}, target {1}.
exec-task.notice=Executing task {0}.
target-dependency-cycle.error=Cycle in dependencies for target {0}.
-workspace.nobuild-project.error=Unable to build project located at "{0}". (Reason: {1}).
#DefaultTaskContext
unknown-prop.error=Unknown property {0}.
1.15 +6 -34 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/EmbeddedAnt.java
Index: EmbeddedAnt.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/EmbeddedAnt.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- EmbeddedAnt.java 29 May 2002 13:03:32 -0000 1.14
+++ EmbeddedAnt.java 2 Jun 2002 14:08:06 -0000 1.15
@@ -40,7 +40,7 @@
*
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.14 $ $Date: 2002/05/29 13:03:32 $
+ * @version $Revision: 1.15 $ $Date: 2002/06/02 14:08:06 $
*/
public class EmbeddedAnt
extends AbstractLogEnabled
@@ -195,11 +195,10 @@
prepareListeners( embeddor, frame );
// Create a new workspace
- final Workspace workspace = embeddor.createWorkspace();
- project.setWorkspace( workspace );
+ final Workspace workspace = project.createWorkspace( frame );
//execute the project
- executeTargets( workspace, frame, project, targets );
+ executeTargets( workspace, project, targets );
}
/**
@@ -226,50 +225,23 @@
* Actually do the build.
*/
private void executeTargets( final Workspace workspace,
- final ExecutionFrame frame,
final Project project,
final String[] targets )
throws TaskException
{
- //HACK: What a huge one!!!
- project.setWorkspace( workspace );
-
//if we didn't specify a target, then choose default
if( targets == null || targets.length == 0 )
{
- final String defaultTargetName = project.getDefaultTargetName();
- final TargetMetaData target = project.getTarget( defaultTargetName );
- checkNotNullTarget( defaultTargetName, target );
- project.execute( frame, target );
+ final TargetMetaData target = project.getDefaultTarget();
+ workspace.executeTarget( target );
}
else
{
for( int i = 0; i < targets.length; i++ )
{
final TargetMetaData target = project.getTarget( targets[ i ] );
- checkNotNullTarget( targets[ i ], target );
- project.execute( frame, target );
+ workspace.executeTarget( target );
}
- }
- }
-
- /**
- * Verify target not nhull and if it is throw an exception.
- *
- * @param name the name we were looking up
- * @param target the target to check
- * @throws TaskException if target is null
- */
- private void checkNotNullTarget( final String name,
- final TargetMetaData target )
- throws TaskException
- {
- if( null == target )
- {
- final String message =
- REZ.getString( "embed.missing-target.error",
- name );
- throw new TaskException( message );
}
}
1.3 +1 -2 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/Resources.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Resources.properties 23 May 2002 06:21:47 -0000 1.2
+++ Resources.properties 2 Jun 2002 14:08:06 -0000 1.3
@@ -6,5 +6,4 @@
home-dir.name=Ant home directory
lib-dir.name=Library directory
task-lib-dir.name=Antlib directory
-ext-dir.name=Extension directory
-embed.missing-target.error=Unable to locate target named "{0}".
\ No newline at end of file
+ext-dir.name=Extension directory
\ No newline at end of file
1.19 +2 -12 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java
Index: Embeddor.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Embeddor.java 29 May 2002 13:03:32 -0000 1.18
+++ Embeddor.java 2 Jun 2002 14:08:06 -0000 1.19
@@ -11,15 +11,14 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.myrmidon.api.event.TaskListener;
import org.apache.myrmidon.api.metadata.ModelElement;
-import org.apache.myrmidon.interfaces.oldmodel.Project;
-import org.apache.myrmidon.interfaces.workspace.Workspace;
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
+import org.apache.myrmidon.interfaces.oldmodel.Project;
/**
* Interface through which you embed Myrmidon into applications.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.18 $ $Date: 2002/05/29 13:03:32 $
+ * @version $Revision: 1.19 $ $Date: 2002/06/02 14:08:06 $
*/
public interface Embeddor
{
@@ -51,15 +50,6 @@
* @throws Exception If the listener could not be created.
*/
TaskListener createListener( ModelElement model )
- throws Exception;
-
- /**
- * Creates a {@link Workspace} that can be used to execute projects.
- *
- * @return the Workspace
- * @throws Exception If the workspace could not be created.
- */
- Workspace createWorkspace()
throws Exception;
/**
1.2 +6 -10 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/Module.java
Index: Module.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/Module.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Module.java 28 Apr 2002 05:44:34 -0000 1.1
+++ Module.java 2 Jun 2002 14:08:06 -0000 1.2
@@ -7,8 +7,9 @@
*/
package org.apache.myrmidon.interfaces.model;
-import org.apache.myrmidon.api.TaskException;
+import org.apache.myrmidon.interfaces.workspace.Workspace;
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
+import org.apache.myrmidon.api.TaskException;
/**
* A Module represents a executable module that Myrmidon is
@@ -18,7 +19,7 @@
* object implement the Module interface.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.1 $ $Date: 2002/04/28 05:44:34 $
+ * @version $Revision: 1.2 $ $Date: 2002/06/02 14:08:06 $
*/
public interface Module
{
@@ -32,15 +33,10 @@
TargetMetaData getMetaData();
/**
- * Execute the specified target in module
- * using specified {@link ExecutionFrame}.
+ * Creates a new workspace to execute this module in.
*
- * @param frame the frame in which to execute
- * @param target the target to execute
- * @throws TaskException if an error occurs executing module
+ * @param frame the execution frame to use for the workspace.
*/
- void execute( ExecutionFrame frame,
- TargetMetaData target )
+ Workspace createWorkspace( ExecutionFrame frame )
throws TaskException;
}
-
1.12 +14 -30 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/oldmodel/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/oldmodel/Project.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Project.java 23 May 2002 06:05:56 -0000 1.11
+++ Project.java 2 Jun 2002 14:08:06 -0000 1.12
@@ -9,14 +9,14 @@
import java.io.File;
import org.apache.myrmidon.interfaces.model.Module;
-import org.apache.myrmidon.interfaces.workspace.Workspace;
+import org.apache.myrmidon.api.TaskException;
/**
* Abstraction used to interact with projects.
* Implementations may choose to structure it anyway they choose.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.11 $ $Date: 2002/05/23 06:05:56 $
+ * @version $Revision: 1.12 $ $Date: 2002/06/02 14:08:06 $
*/
public interface Project
extends Module
@@ -30,47 +30,35 @@
String IMPLICIT_TARGET_NAME = "<init>";
/**
- * @return the project name.
- *
- * TODO: Determine if projects should carry their own name. Breaks IOC but
- * Can be useful as project files embed own name (or should that be description).
+ * Returns the URI of this project.
*/
- String getName();
-
String getURI();
/**
- * Retrieve project reference for specified name.
- * The name is local name of project.
+ * Returns a referenced project.
*
- * @param name the name project referenced with
- * @return the ProjectRef
+ * @param name the project name
+ * @return the project.
+ * @throws TaskException if the request project is unknown.
*/
- ProjectRef getProjectRef( String name );
+ Project getProject( String name ) throws TaskException;
/**
- * Get name of default target.
+ * Return the default target for this project.
*
* @return the default target name
+ * @throws TaskException if the project has no default target.
*/
- String getDefaultTargetName();
-
- /**
- * Retrieve implicit target.
- * The implicit target is top level tasks.
- * Currently restricted to property tasks.
- *
- * @return the Target
- */
- Target getImplicitTarget();
+ Target getDefaultTarget() throws TaskException;
/**
* Retrieve a target by name.
*
* @param name the name of target
- * @return the Target or null if no target exists with name
+ * @return the Target
+ * @throws TaskException if the requested target is unknown
*/
- Target getTarget( String name );
+ Target getTarget( String name ) throws TaskException;
/**
* Retrieve base directory of project.
@@ -79,8 +67,4 @@
*/
File getBaseDirectory();
- /**
- * UGLY HACK!!!! Remove in future.
- */
- void setWorkspace( Workspace workspace );
}
1.6 +14 -3 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/oldmodel/Target.java
Index: Target.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/oldmodel/Target.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Target.java 23 May 2002 04:49:26 -0000 1.5
+++ Target.java 2 Jun 2002 14:08:06 -0000 1.6
@@ -14,11 +14,12 @@
* Targets in build file.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.5 $ $Date: 2002/05/23 04:49:26 $
+ * @version $Revision: 1.6 $ $Date: 2002/06/02 14:08:06 $
*/
public class Target
implements TargetMetaData
{
+ private final Project m_project;
private final ModelElement m_target;
/**
@@ -26,12 +27,22 @@
*
* @param target the ModelElement representing target
*/
- public Target( final ModelElement target )
+ public Target( final Project project,
+ final ModelElement target )
{
+ m_project = project;
m_target = target;
}
/**
+ * Get the project for this target.
+ */
+ public Project getProject()
+ {
+ return m_project;
+ }
+
+ /**
* Get tasks in target
*
* @return the target list
@@ -58,7 +69,7 @@
*/
public String getDescription()
{
- return null;
+ return m_target.getAttribute( "description" );
}
/**
1.15 +5 -25 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java
Index: Workspace.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Workspace.java 23 May 2002 04:29:45 -0000 1.14
+++ Workspace.java 2 Jun 2002 14:08:06 -0000 1.15
@@ -8,14 +8,13 @@
package org.apache.myrmidon.interfaces.workspace;
import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
-import org.apache.myrmidon.interfaces.oldmodel.Project;
+import org.apache.myrmidon.interfaces.model.TargetMetaData;
/**
- * This is the abstraction through which Projects are executed.
+ * This is the abstraction through which Modules are executed.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Revision: 1.14 $ $Date: 2002/05/23 04:29:45 $
+ * @version $Revision: 1.15 $ $Date: 2002/06/02 14:08:06 $
*/
public interface Workspace
{
@@ -23,27 +22,8 @@
String ROLE = Workspace.class.getName();
/**
- * Executes a target in a particular project.
- *
- * @param project the Project
- * @param target the name of the target
- * @throws TaskException if an error occurs
+ * Executes a target.
*/
- void executeProject( Project project, String target )
- throws TaskException;
-
- //Yet another temporary hack
- void setFrame( ExecutionFrame frame )
- throws TaskException;
-
- /**
- * Executes a target in context of workspace.
- * The project is specified by URI.
- *
- * @param uri the URI of the Project
- * @param targetName the name of the target to execute
- * @throws TaskException if an error occurs
- */
- void executeTarget( String uri, String targetName )
+ void executeTarget( TargetMetaData target )
throws TaskException;
}
1.12 +47 -27 jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java
Index: DefaultProjectBuilderTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DefaultProjectBuilderTestCase.java 29 May 2002 06:42:26 -0000 1.11
+++ DefaultProjectBuilderTestCase.java 2 Jun 2002 14:08:06 -0000 1.12
@@ -9,26 +9,26 @@
import java.io.File;
import java.io.IOException;
-import java.util.Collections;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.service.DefaultServiceManager;
-import org.apache.myrmidon.AbstractContainerTestCase;
-import org.apache.myrmidon.components.builder.DefaultModelBuilder;
+import org.apache.myrmidon.components.AbstractComponentTest;
+import org.apache.myrmidon.components.embeddor.DefaultEmbeddor;
import org.apache.myrmidon.components.builder.DefaultProject;
import org.apache.myrmidon.components.builder.DefaultProjectBuilder;
-import org.apache.myrmidon.components.AbstractComponentTest;
-import org.apache.myrmidon.interfaces.builder.ModelBuilder;
import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
import org.apache.myrmidon.interfaces.builder.ProjectException;
+import org.apache.myrmidon.interfaces.model.TargetMetaData;
import org.apache.myrmidon.interfaces.oldmodel.Project;
+import org.apache.myrmidon.interfaces.oldmodel.Target;
+import org.apache.myrmidon.interfaces.embeddor.Embeddor;
+import org.apache.myrmidon.api.metadata.ModelElement;
/**
* Test cases for {@link DefaultProjectBuilder}.
*
* @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
- * @version $Revision: 1.11 $ $Date: 2002/05/29 06:42:26 $
+ * @version $Revision: 1.12 $ $Date: 2002/06/02 14:08:06 $
*/
public class DefaultProjectBuilderTestCase
extends AbstractComponentTest
@@ -45,6 +45,8 @@
protected void setUp() throws Exception
{
super.setUp();
+ DefaultEmbeddor embeddor = new DefaultEmbeddor();
+ getServiceManager().put( Embeddor.ROLE, embeddor );
m_builder = new DefaultProjectBuilder();
ContainerUtil.enableLogging( m_builder, getLogger() );
ContainerUtil.service( m_builder, getServiceManager() );
@@ -130,16 +132,24 @@
final Project project = m_builder.build( projFile.getAbsolutePath() );
// Compare against expected project
- DefaultProject expected =
+ final DefaultProject expected =
new DefaultProject( getNameFor( projFile ),
getURIFor( projFile ),
getTestDirectory(),
"main",
- Collections.EMPTY_MAP,
- Collections.EMPTY_MAP);
+ null );
+ addTarget( expected, "main" );
+ addTarget( expected, Project.IMPLICIT_TARGET_NAME );
assertSameProject( expected, project );
}
+ private void addTarget( final DefaultProject project, final String name )
+ {
+ final ModelElement model = new ModelElement( "target", "" );
+ model.setAttribute( "name", name );
+ project.addTarget( new Target( project, model ) );
+ }
+
private String getNameFor( final File projFile )
{
return FileUtil.removeExtension( projFile.getName() );
@@ -155,13 +165,14 @@
final Project project = m_builder.build( projFile.getAbsolutePath() );
// Compare against expected project
- DefaultProject expected =
+ final DefaultProject expected =
new DefaultProject( "some-project",
getURIFor( projFile ),
getTestDirectory(),
"main",
- Collections.EMPTY_MAP,
- Collections.EMPTY_MAP);
+ null );
+ addTarget( expected, "main" );
+ addTarget( expected, Project.IMPLICIT_TARGET_NAME );
assertSameProject( expected, project );
}
@@ -176,13 +187,14 @@
// Compare against expected project
final File baseDir = getTestDirectory( "other-base-dir" );
- DefaultProject expected =
+ final DefaultProject expected =
new DefaultProject( getNameFor( projFile ),
getURIFor( projFile ),
baseDir,
"main",
- Collections.EMPTY_MAP,
- Collections.EMPTY_MAP );
+ null );
+ addTarget( expected, "main" );
+ addTarget( expected, Project.IMPLICIT_TARGET_NAME );
assertSameProject( expected, project );
}
@@ -201,8 +213,9 @@
getURIFor( projFile ),
getTestDirectory(),
"some-target",
- Collections.EMPTY_MAP,
- Collections.EMPTY_MAP );
+ null );
+ addTarget( expected, "some-target" );
+ addTarget( expected, Project.IMPLICIT_TARGET_NAME );
assertSameProject( expected, project );
}
@@ -268,18 +281,25 @@
*/
protected void assertSameProject( final Project expected,
final Project project )
+ throws Exception
{
- assertEquals( expected.getName(), project.getName() );
+ assertSameMetaData( expected.getMetaData(), project.getMetaData() );
assertEquals( expected.getBaseDirectory(), project.getBaseDirectory() );
- assertEquals( expected.getDefaultTargetName(), project.getDefaultTargetName() );
-
- // TODO - make sure each of the projects are the same
- //assertTrue( Arrays.equals( expected.getProjectNames(), project.getProjectNames() ) );
-
- // TODO - make sure the implicit targets are the same
+ assertSameMetaData( expected.getDefaultTarget(), project.getDefaultTarget() );
+ }
- // TODO - make sure each of the targets are the same
- //assertTrue( Arrays.equals( expected.getTargetNames(), project.getTargetNames() ) );
+ private void assertSameMetaData( final TargetMetaData expected,
+ final TargetMetaData actual )
+ {
+ assertEquals( expected.getName(), actual.getName() );
+ assertEquals( expected.getDescription(), actual.getDescription() );
+ final TargetMetaData[] expectedChildren = expected.getTargets();
+ final TargetMetaData[] actualChildren = actual.getTargets();
+ assertEquals( expectedChildren.length, actualChildren.length );
+ for( int i = 0; i < actualChildren.length; i++ )
+ {
+ assertSameMetaData( expectedChildren[ i ], actualChildren[ i ] );
+ }
}
/**
1.2 +1 -0 jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/defaults.ant
Index: defaults.ant
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/defaults.ant,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- defaults.ant 17 Mar 2002 08:07:07 -0000 1.1
+++ defaults.ant 2 Jun 2002 14:08:06 -0000 1.2
@@ -1,3 +1,4 @@
<!-- Use all the defaults -->
<project version="2.0">
+ <target name="main"/>
</project>
1.2 +1 -0 jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/set-base-dir.ant
Index: set-base-dir.ant
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/set-base-dir.ant,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- set-base-dir.ant 17 Mar 2002 08:07:07 -0000 1.1
+++ set-base-dir.ant 2 Jun 2002 14:08:06 -0000 1.2
@@ -1,3 +1,4 @@
<!-- Project with a non-default base directory -->
<project version="2.0" basedir="other-base-dir">
+ <target name="main"/>
</project>
1.2 +1 -0 jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/set-project-name.ant
Index: set-project-name.ant
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/set-project-name.ant,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- set-project-name.ant 17 Mar 2002 08:07:07 -0000 1.1
+++ set-project-name.ant 2 Jun 2002 14:08:06 -0000 1.2
@@ -1,3 +1,4 @@
<!-- Project with non-default name -->
<project name="some-project" version="2.0">
+ <target name="main"/>
</project >
1.19 +9 -8 jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java
Index: DefaultEmbeddorTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- DefaultEmbeddorTest.java 29 May 2002 13:17:19 -0000 1.18
+++ DefaultEmbeddorTest.java 2 Jun 2002 14:08:06 -0000 1.19
@@ -26,7 +26,7 @@
* Test cases for the default embeddor.
*
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
- * @version $Revision: 1.18 $ $Date: 2002/05/29 13:17:19 $
+ * @version $Revision: 1.19 $ $Date: 2002/06/02 14:08:06 $
*/
public class DefaultEmbeddorTest
extends AbstractContainerTestCase
@@ -85,13 +85,13 @@
final Project project = getEmbeddor().createProject( projectFile.getAbsolutePath(), null, null );
// Verify the project.
- assertEquals( "test-project", project.getName() );
- assertEquals( "main-target", project.getDefaultTargetName() );
+ assertEquals( "test-project", project.getMetaData().getName() );
+ assertEquals( project.getTarget( "main-target" ), project.getDefaultTarget() );
assertEquals( projectFile.getParentFile(), project.getBaseDirectory() );
//assertEquals( 0, project.getProjectNames().length );
//assertEquals( 1, project.getTargetNames().length );
- final Target implicitTarget = project.getImplicitTarget();
+ final Target implicitTarget = project.getTarget( Project.IMPLICIT_TARGET_NAME );
final ModelElement model = implicitTarget.getModel();
assertEquals( 1, model.getChildCount() );
@@ -114,6 +114,8 @@
/**
* Tests that a workspace can execute a project file.
+ *
+ * @todo - move this somewhere else
*/
public void testWorkspaceCreate() throws Exception
{
@@ -123,8 +125,8 @@
final Project project = embeddor.createProject( projectFile.getAbsolutePath(), null, null );
// Build the workspace
- final Workspace workspace = embeddor.createWorkspace();
final ExecutionFrame frame = embeddor.createExecutionFrame( new HashMap() );
+ final Workspace workspace = project.createWorkspace( frame );
// Install a listener
final LogMessageTracker listener = new LogMessageTracker();
@@ -133,9 +135,8 @@
listener.addExpectedMessage( "main-target", "A log message" );
// Execute the default target
- final String target = project.getDefaultTargetName();
- workspace.setFrame( frame );
- workspace.executeProject( project, target );
+ final Target target = project.getDefaultTarget();
+ workspace.executeTarget( target );
// Cleanup
listener.assertComplete();
1.8 +15 -9 jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/ExecuteTarget.java
Index: ExecuteTarget.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/ExecuteTarget.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ExecuteTarget.java 28 May 2002 03:52:21 -0000 1.7
+++ ExecuteTarget.java 2 Jun 2002 14:08:07 -0000 1.8
@@ -14,6 +14,7 @@
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.interfaces.embeddor.Embeddor;
import org.apache.myrmidon.interfaces.oldmodel.Project;
+import org.apache.myrmidon.interfaces.oldmodel.Target;
import org.apache.myrmidon.interfaces.workspace.Workspace;
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
import org.apache.avalon.excalibur.i18n.ResourceManager;
@@ -25,7 +26,7 @@
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
- * @version $Revision: 1.7 $ $Date: 2002/05/28 03:52:21 $
+ * @version $Revision: 1.8 $ $Date: 2002/06/02 14:08:07 $
*/
public class ExecuteTarget
{
@@ -96,25 +97,30 @@
final Project project = buildProject( embeddor );
final Map properties = buildParameters( context );
- String target = m_target;
- if( null == target )
+ final Target target;
+ if( null == m_target )
{
- target = project.getDefaultTargetName();
+ target = project.getDefaultTarget();
+ }
+ else
+ {
+ target = project.getTarget( m_target );
}
try
{
// TODO - need to be able to inherit services (TypeManager specifically)
- final Workspace workspace = embeddor.createWorkspace();
final ExecutionFrame frame =
embeddor.createExecutionFrame( properties );
-
- workspace.setFrame( frame );
- workspace.executeProject( project, target );
+ final Workspace workspace = project.createWorkspace( frame );
+ workspace.executeTarget( target );
}
catch( final Exception e )
{
- final String message = REZ.getString( "execute-target.execute.error", project.getName(), target );
+ final String message =
+ REZ.getString( "execute-target.execute.error",
+ project.getMetaData().getName(),
+ target.getName() );
throw new TaskException( message, e );
}
}
1.3 +1 -3 jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/AbstractProjectListener.java
Index: AbstractProjectListener.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/AbstractProjectListener.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractProjectListener.java 29 May 2002 13:03:33 -0000 1.2
+++ AbstractProjectListener.java 2 Jun 2002 14:08:07 -0000 1.3
@@ -7,15 +7,13 @@
*/
package org.apache.myrmidon.framework.listener;
-
-
/**
* Abstract listener from which to extend. This implementation provedes
* empty implementions of each of the event methods.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
- * @version $Revision: 1.2 $ $Date: 2002/05/29 13:03:33 $
+ * @version $Revision: 1.3 $ $Date: 2002/06/02 14:08:07 $
*/
public abstract class AbstractProjectListener
implements ProjectListener
1.4 +2 -2 jakarta-ant-myrmidon/framework/src/todo/org/apache/tools/todo/taskdefs/text/FixCRLF.java
Index: FixCRLF.java
===================================================================
RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/todo/org/apache/tools/todo/taskdefs/text/FixCRLF.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FixCRLF.java 23 May 2002 01:50:28 -0000 1.3
+++ FixCRLF.java 2 Jun 2002 14:08:07 -0000 1.4
@@ -70,7 +70,7 @@
*
* @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>
* @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
- * @version $Revision: 1.3 $ $Name: $
+ * @version $Revision: 1.4 $ $Name: $
*/
public class FixCRLF
extends MatchingTask
@@ -95,7 +95,7 @@
private static final int INBUFLEN = 8192;
private static final int LINEBUFLEN = 200;
- private static final char CTRLZ = '\u001A';
+ private static final char CTRLZ = (char)0x1A;
private int tablength = 8;
private String spaces = " ";
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>