donaldp 2002/06/08 16:56:05
Modified: antlib/src/java/org/apache/antlib/project
AbstractWorkspaceTask.java
container/src/java/org/apache/myrmidon/components/builder
ConvertingProjectBuilder.java DefaultProject.java
DefaultProjectBuilder.java Resources.properties
container/src/java/org/apache/myrmidon/components/embeddor
DefaultEmbeddor.java
container/src/java/org/apache/myrmidon/components/event
DefaultTaskEventManager.java
container/src/java/org/apache/myrmidon/components/workspace
DefaultWorkspace.java
container/src/java/org/apache/myrmidon/frontends
CLIMain.java
container/src/java/org/apache/myrmidon/interfaces
EmbeddedAnt.java
container/src/java/org/apache/myrmidon/interfaces/builder
ProjectBuilder.java
container/src/java/org/apache/myrmidon/interfaces/embeddor
Embeddor.java
container/src/java/org/apache/myrmidon/interfaces/oldmodel
Project.java
container/src/java/org/apache/myrmidon/interfaces/workspace
ProjectDescriptor.java Workspace.java
container/src/test/org/apache/myrmidon/components/builder/test
DefaultProjectBuilderTestCase.java
container/src/test/org/apache/myrmidon/components/embeddor/test
DefaultEmbeddorTest.java
framework/src/java/org/apache/myrmidon/framework
ExecuteTarget.java
Removed: container/src/java/org/apache/myrmidon/interfaces/oldmodel
ProjectRef.java
Log:
Allow projects to be represented by a ProjectDescriptor rather than just a
URI. The Descriptor contains the URI and type of the project.
The ProjectDescriptor is now used in places where project URI was previously
used (Workspace/ProjectBuilder) and it is also exposed via Project interface.
In process removed extinct notion of Builder properties as they were never
used anymore.
This gets the unit tests passing again.
Revision Changes Path
1.6 +5 -4
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractWorkspaceTask.java 7 Jun 2002 06:06:05 -0000 1.5
+++ AbstractWorkspaceTask.java 8 Jun 2002 23:56:04 -0000 1.6
@@ -13,12 +13,13 @@
import org.apache.myrmidon.framework.AbstractContainerTask;
import org.apache.myrmidon.interfaces.oldmodel.Project;
import org.apache.myrmidon.interfaces.workspace.Workspace;
+import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
/**
* An abstract class used to execute Ant files within same workspace.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.5 $ $Date: 2002/06/07 06:06:05 $
+ * @version $Revision: 1.6 $ $Date: 2002/06/08 23:56:04 $
*/
abstract class AbstractWorkspaceTask
extends AbstractContainerTask
@@ -44,7 +45,7 @@
final Project project = getProject( dependency );
final String targetName = dependency.getTargetName();
- executeTarget( project.getURI(), targetName );
+ executeTarget( project.getProjectDescriptor(), targetName );
}
/**
@@ -54,13 +55,13 @@
* @param target the name of target to execute
* @throws TaskException if error occurs executing target
*/
- protected final void executeTarget( final String projectURI,
+ protected final void executeTarget( final ProjectDescriptor descriptor,
final String target )
throws TaskException
{
final Workspace workspace =
(Workspace)getContext().getService( Workspace.class );
- workspace.execute( projectURI, target );
+ workspace.execute( descriptor, target );
}
/**
1.12 +1 -3
jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/ConvertingProjectBuilder.java
Index: ConvertingProjectBuilder.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/ConvertingProjectBuilder.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ConvertingProjectBuilder.java 29 May 2002 06:20:23 -0000 1.11
+++ ConvertingProjectBuilder.java 8 Jun 2002 23:56:04 -0000 1.12
@@ -8,15 +8,13 @@
package org.apache.myrmidon.components.builder;
import org.apache.myrmidon.api.metadata.ModelElement;
-import java.util.List;
-import java.util.ArrayList;
/**
* A simple ProjectBuilder, which programmatically converts an Ant1 Project
* configuration into a Myrmidon one.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Darrell DeBoer</a>
- * @version $Revision: 1.11 $ $Date: 2002/05/29 06:20:23 $
+ * @version $Revision: 1.12 $ $Date: 2002/06/08 23:56:04 $
*
* @ant.type type="project-builder" name="xml"
* @ant.type type="project-builder" name="ant"
1.23 +16 -15
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.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- DefaultProject.java 7 Jun 2002 07:07:52 -0000 1.22
+++ DefaultProject.java 8 Jun 2002 23:56:04 -0000 1.23
@@ -21,14 +21,15 @@
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.ProjectRef;
+import org.apache.myrmidon.interfaces.workspace.ProjectRef;
import org.apache.myrmidon.interfaces.workspace.Workspace;
+import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
/**
* Default project implementation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.22 $ $Date: 2002/06/07 07:07:52 $
+ * @version $Revision: 1.23 $ $Date: 2002/06/08 23:56:04 $
*/
public class DefaultProject
extends AbstractLogEnabled
@@ -43,11 +44,6 @@
private final String m_name;
/**
- * The URI of this project file.
- */
- private final String m_uri;
-
- /**
* The name of the default target
*/
private final String m_defaultTarget;
@@ -72,16 +68,19 @@
*/
private final Map m_targets = new HashMap();
+ private final ProjectDescriptor m_descriptor;
+
private Embeddor m_embeddor;
+
public DefaultProject( final String name,
- final String uri,
+ final ProjectDescriptor descriptor,
final File baseDirectory,
final String defaultTarget,
final Embeddor embeddor )
{
m_name = name;
- m_uri = uri;
+ m_descriptor = descriptor;
m_baseDirectory = baseDirectory;
m_defaultTarget = defaultTarget;
m_embeddor = embeddor;
@@ -103,9 +102,9 @@
m_targets.put( target.getName(), target );
}
- public String getURI()
+ public ProjectDescriptor getProjectDescriptor()
{
- return m_uri;
+ return m_descriptor;
}
/**
@@ -141,15 +140,17 @@
throw new TaskException( message );
}
- final String uri = ref.getUri();
+ final ProjectDescriptor project = ref.getProject();
try
{
- return m_embeddor.createProject( uri, null, null );
+ return m_embeddor.createProject( project, null );
}
catch( final Exception e )
{
final String message =
- REZ.getString( "project.nobuild-project.error", uri );
+ REZ.getString( "project.nobuild-project.error",
+ project.getUri(),
+ project.getType() );
throw new TaskException( message, e );
}
}
@@ -262,7 +263,7 @@
throws TaskException
{
final Workspace workspace = createWorkspace( frame );
- workspace.execute( getURI(), target.getName() );
+ workspace.execute( getProjectDescriptor(), target.getName() );
}
/**
1.68 +11 -42
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.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- DefaultProjectBuilder.java 7 Jun 2002 07:07:52 -0000 1.67
+++ DefaultProjectBuilder.java 8 Jun 2002 23:56:04 -0000 1.68
@@ -24,16 +24,17 @@
import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
import org.apache.myrmidon.interfaces.builder.ProjectException;
import org.apache.myrmidon.interfaces.oldmodel.Project;
-import org.apache.myrmidon.interfaces.oldmodel.ProjectRef;
+import org.apache.myrmidon.interfaces.workspace.ProjectRef;
import org.apache.myrmidon.interfaces.property.NameValidator;
import org.apache.myrmidon.interfaces.property.NameValidatorManager;
import org.apache.myrmidon.interfaces.embeddor.Embeddor;
+import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
/**
* Default implementation to construct project from a build file.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.67 $ $Date: 2002/06/07 07:07:52 $
+ * @version $Revision: 1.68 $ $Date: 2002/06/08 23:56:04 $
*
* @ant.type type="project-builder" name="ant2"
*/
@@ -74,20 +75,6 @@
}
/**
- * build a project from file.
- *
- * @param source the source
- * @return the constructed Project
- * @throws ProjectException if an error occurs
- */
- public Project build( final String source )
- throws ProjectException
- {
- final File file = toFile( source );
- return build( file );
- }
-
- /**
* Convert the specified source into a file object.
*
* @param source the source to transform
@@ -118,13 +105,14 @@
/**
* build project from file.
*
- * @param file the file
+ * @param descriptor the project descriptor
* @return the create Project object
* @throws ProjectException if error building project
*/
- private Project build( final File file )
+ public Project build( final ProjectDescriptor descriptor )
throws ProjectException
{
+ final File file = toFile( descriptor.getUri() );
try
{
// Check for cached project
@@ -142,13 +130,12 @@
final File baseDirectory = calcBaseDir( file,
model.getAttribute( "basedir" ) );
final String defaultTarget = model.getAttribute( "default",
"main" );
final Version version = getVersion( model );
- final String uri = getURI( file );
verifyVersion( version );
DefaultProject project =
new DefaultProject( projectName,
- uri,
+ descriptor,
baseDirectory,
defaultTarget,
m_embeddor );
@@ -255,26 +242,6 @@
}
/**
- * Get the URI for specified file.
- *
- * @param file the file
- * @return the URI for file
- * @throws ProjectException on error
- */
- private String getURI( final File file )
- throws ProjectException
- {
- try
- {
- return file.getCanonicalFile().toURL().toExternalForm();
- }
- catch( final IOException ioe )
- {
- throw new ProjectException( ioe.getMessage(), ioe );
- }
- }
-
- /**
* Get the project name from the model, or create a default name if none
* was supplied.
*/
@@ -414,6 +381,7 @@
{
final String name = element.getAttribute( "name" );
final String location = element.getAttribute( "location" );
+ final String type = element.getAttribute( "type" );
if( null == name )
{
@@ -445,11 +413,12 @@
// Build the URL of the referenced projects
final File file = FileUtil.resolveFile( baseDirectory, location );
-
try
{
final String uri = file.getCanonicalFile().toString();
- return new ProjectRef( name, uri );
+ final ProjectDescriptor project =
+ new ProjectDescriptor( uri, type );
+ return new ProjectRef( name, project );
}
catch( final IOException ioe )
{
1.13 +1 -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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Resources.properties 2 Jun 2002 14:08:05 -0000 1.12
+++ Resources.properties 8 Jun 2002 23:56:04 -0000 1.13
@@ -32,5 +32,5 @@
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.nobuild-project.error=Could not load referenced project "{0}" with
type "{1}".
project.unknown-target.error=Unknown target "{0}".
1.82 +11 -13
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.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- DefaultEmbeddor.java 7 Jun 2002 05:48:20 -0000 1.81
+++ DefaultEmbeddor.java 8 Jun 2002 23:56:04 -0000 1.82
@@ -16,7 +16,6 @@
import org.apache.aut.converter.Converter;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.framework.CascadingException;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
@@ -59,13 +58,14 @@
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.ProjectDescriptor;
/**
* Default implementation of Embeddor.
* Instantiate this to embed inside other applications.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.81 $ $Date: 2002/06/07 05:48:20 $
+ * @version $Revision: 1.82 $ $Date: 2002/06/08 23:56:04 $
*/
public class DefaultEmbeddor
extends AbstractLogEnabled
@@ -105,26 +105,24 @@
/**
* Builds a project.
*/
- public Project createProject( final String location,
- final String type,
+ public Project createProject( final ProjectDescriptor project,
final Parameters parameters )
throws Exception
{
try
{
- String projectType = type;
- if( null == projectType )
- {
- projectType = FileUtil.getExtension( location );
- }
-
// TODO - reuse the project builders, or dispose them
- final ProjectBuilder builder = getProjectBuilder( projectType,
parameters );
- return builder.build( location );
+ final ProjectBuilder builder = getProjectBuilder(
project.getType(), parameters );
+ System.out.println( "DefaultEmbeddor.createProject" );
+ System.out.println( "type = " + project.getType() );
+ System.out.println( "builder = " + builder );
+ return builder.build( project );
}
catch( final Exception e )
{
- final String message = REZ.getString( "create-project.error",
location );
+ final String message =
+ REZ.getString( "create-project.error",
+ project.getUri() );
throw new CascadingException( message, e );
}
}
1.4 +1 -12
jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/event/DefaultTaskEventManager.java
Index: DefaultTaskEventManager.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/event/DefaultTaskEventManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultTaskEventManager.java 5 Jun 2002 07:40:40 -0000 1.3
+++ DefaultTaskEventManager.java 8 Jun 2002 23:56:04 -0000 1.4
@@ -17,7 +17,7 @@
* Support for the task listener event dispatching.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.3 $ $Date: 2002/06/05 07:40:40 $
+ * @version $Revision: 1.4 $ $Date: 2002/06/08 23:56:04 $
*/
public class DefaultTaskEventManager
implements TaskEventManager
@@ -80,16 +80,5 @@
{
m_listeners[ i ].taskMessage( event );
}
- }
-
- /**
- * Retrieve current processID.
- *
- * @return the current processID.
- * @todo Actually implement
- */
- private int getCurrentProcessID()
- {
- return 0;
}
}
1.76 +19 -11
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.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- DefaultWorkspace.java 7 Jun 2002 07:07:52 -0000 1.75
+++ DefaultWorkspace.java 8 Jun 2002 23:56:04 -0000 1.76
@@ -31,12 +31,13 @@
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.workspace.ProjectDescriptor;
/**
* This is the default implementation of Workspace.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.75 $ $Date: 2002/06/07 07:07:52 $
+ * @version $Revision: 1.76 $ $Date: 2002/06/08 23:56:04 $
* @todo Merge m_entries and m_projects
*/
public class DefaultWorkspace
@@ -63,10 +64,17 @@
}
public void execute( final String projectURI,
+ final String target )
+ throws TaskException
+ {
+ execute( new ProjectDescriptor( projectURI, null ), target );
+ }
+
+ public void execute( final ProjectDescriptor descriptor,
final String targetName )
throws TaskException
{
- final ProjectEntry entry = getProjectEntry( projectURI );
+ final ProjectEntry entry = getProjectEntry( descriptor );
final Project project = entry.getProject();
TargetMetaData target = project.getTarget( targetName );
if( null == target )
@@ -109,7 +117,7 @@
serviceManager.put( Workspace.ROLE, this );
serviceManager.put( Project.ROLE, project );
- return frame.createChildFrame( project.getMetaData().getName(),
+ return frame.createChildFrame( project.getProjectName(),
project.getBaseDirectory(),
serviceManager,
true );
@@ -173,34 +181,34 @@
serviceManager.put( role, childService );
}
- private ProjectEntry getProjectEntry( final String projectURI )
+ private ProjectEntry getProjectEntry( final ProjectDescriptor descriptor
)
throws TaskException
{
- ProjectEntry entry = (ProjectEntry)m_entries.get( projectURI );
-
+ ProjectEntry entry = (ProjectEntry)m_entries.get( descriptor );
if( null == entry )
{
- final Project project = createProject( projectURI );
+ final Project project = createProject( descriptor );
entry = createProjectEntry( project, m_frame );
- m_entries.put( project.getURI(), entry );
+ m_entries.put( descriptor, entry );
}
return entry;
}
- private Project createProject( final String projectURI )
+ private Project createProject( final ProjectDescriptor project)
throws TaskException
{
try
{
final ServiceManager serviceManager =
m_frame.getServiceManager();
final Embeddor embeddor = (Embeddor)serviceManager.lookup(
Embeddor.ROLE );
- return embeddor.createProject( projectURI, null, null );
+ return embeddor.createProject( project, null );
}
catch( final Exception e )
{
final String message =
- REZ.getString( "nobuild-project.error", projectURI );
+ REZ.getString( "nobuild-project.error",
+ project.getUri() );
throw new TaskException( message, e );
}
}
1.48 +2 -11
jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/frontends/CLIMain.java
Index: CLIMain.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/frontends/CLIMain.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- CLIMain.java 2 Jun 2002 05:03:46 -0000 1.47
+++ CLIMain.java 8 Jun 2002 23:56:04 -0000 1.48
@@ -37,7 +37,7 @@
* to run project.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.47 $ $Date: 2002/06/02 05:03:46 $
+ * @version $Revision: 1.48 $ $Date: 2002/06/08 23:56:04 $
*/
public class CLIMain
{
@@ -54,7 +54,6 @@
private static final int FILE_OPT = 'f';
private static final int LOG_LEVEL_OPT = 'l';
private static final int DEFINE_OPT = 'D';
- private static final int BUILDER_PARAM_OPT = 'B';
private static final int LISTENER_PARAM_OPT = 'L';
private static final int NO_PREFIX_OPT = 'p';
private static final int GUI_OPT = 'g';
@@ -73,7 +72,7 @@
private static final int[] INFO_OPT_INCOMPAT = new int[]
{
HELP_OPT, QUIET_OPT, VERBOSE_OPT, FILE_OPT,
- LOG_LEVEL_OPT, BUILDER_PARAM_OPT, LISTENER_PARAM_OPT,
+ LOG_LEVEL_OPT, LISTENER_PARAM_OPT,
NO_PREFIX_OPT, VERSION_OPT, LISTENER_OPT, LISTENER_CONFIG_OPT,
EXTLIB_DIR_OPT, INCREMENTAL_OPT, HOME_DIR_OPT, DRY_RUN_OPT,
TYPE_OPT, BANNER_OPT
@@ -201,10 +200,6 @@
CLOptionDescriptor.ARGUMENT_REQUIRED,
TYPE_OPT,
REZ.getString( "type.opt" ) ),
- new CLOptionDescriptor( "builderparam",
- CLOptionDescriptor.ARGUMENTS_REQUIRED_2
| CLOptionDescriptor.DUPLICATES_ALLOWED,
- BUILDER_PARAM_OPT,
- REZ.getString( "build.opt" ) ),
new CLOptionDescriptor( "loglevel",
CLOptionDescriptor.ARGUMENT_REQUIRED,
LOG_LEVEL_OPT,
@@ -348,10 +343,6 @@
case DEFINE_OPT:
embeddedAnt.setWorkspaceProperty( option.getArgument( 0
), option.getArgument( 1 ) );
- break;
-
- case BUILDER_PARAM_OPT:
- embeddedAnt.setBuilderProperty( option.getArgument( 0 ),
option.getArgument( 1 ) );
break;
case GUI_OPT:
1.17 +6 -16
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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- EmbeddedAnt.java 7 Jun 2002 02:46:31 -0000 1.16
+++ EmbeddedAnt.java 8 Jun 2002 23:56:04 -0000 1.17
@@ -18,7 +18,6 @@
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.parameters.Parameters;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.metadata.ModelElement;
import org.apache.myrmidon.api.event.TaskListener;
@@ -27,6 +26,7 @@
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.workspace.ProjectDescriptor;
/**
* A utility class, that takes care of launching Myrmidon, and building and
@@ -39,7 +39,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.16 $ $Date: 2002/06/07 02:46:31 $
+ * @version $Revision: 1.17 $ $Date: 2002/06/08 23:56:04 $
*/
public class EmbeddedAnt
extends AbstractLogEnabled
@@ -51,7 +51,6 @@
"org.apache.myrmidon.components.embeddor.DefaultEmbeddor";
private final ArrayList m_listeners = new ArrayList();
- private final Parameters m_builderProps = new Parameters();
private final Map m_embeddorParameters = new HashMap();
private final Map m_workspaceProperties = new HashMap();
@@ -136,16 +135,6 @@
}
/**
- * Sets a project builder property. These are used by the project
builder
- * when it is parsing the project file.
- */
- public void setBuilderProperty( final String name, final Object value )
- {
- // TODO - Make properties Objects, not Strings
- m_builderProps.setParameter( name, value.toString() );
- }
-
- /**
* Sets a task engine property. These are used to configure the task
engine.
*/
public void setEmbeddorProperty( final String name, final Object value )
@@ -341,10 +330,11 @@
if( m_project == null )
{
final File buildFile = getProjectFile();
+ final String uri = buildFile.toURL().toExternalForm();
+ final ProjectDescriptor descriptor =
+ new ProjectDescriptor( uri, m_projectType );
m_project =
- embeddor.createProject( buildFile.toString(),
- m_projectType,
- m_builderProps );
+ embeddor.createProject( descriptor, null );
}
return m_project;
}
1.15 +4 -3
jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/builder/ProjectBuilder.java
Index: ProjectBuilder.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/builder/ProjectBuilder.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ProjectBuilder.java 23 May 2002 01:50:26 -0000 1.14
+++ ProjectBuilder.java 8 Jun 2002 23:56:04 -0000 1.15
@@ -8,12 +8,13 @@
package org.apache.myrmidon.interfaces.builder;
import org.apache.myrmidon.interfaces.oldmodel.Project;
+import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
/**
* Interface implemented by components that build projects from sources.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.14 $ $Date: 2002/05/23 01:50:26 $
+ * @version $Revision: 1.15 $ $Date: 2002/06/08 23:56:04 $
* @ant.role name="project-builder"
*/
public interface ProjectBuilder
@@ -24,10 +25,10 @@
/**
* build a project from source.
*
- * @param source the project file path.
+ * @param project the project descriptor.
* @return the constructed Project
* @throws ProjectException if an error occurs
*/
- Project build( String source )
+ Project build( ProjectDescriptor project )
throws ProjectException;
}
1.20 +4 -5
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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Embeddor.java 2 Jun 2002 14:08:06 -0000 1.19
+++ Embeddor.java 8 Jun 2002 23:56:04 -0000 1.20
@@ -13,12 +13,13 @@
import org.apache.myrmidon.api.metadata.ModelElement;
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
import org.apache.myrmidon.interfaces.oldmodel.Project;
+import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
/**
* Interface through which you embed Myrmidon into applications.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.19 $ $Date: 2002/06/02 14:08:06 $
+ * @version $Revision: 1.20 $ $Date: 2002/06/08 23:56:04 $
*/
public interface Embeddor
{
@@ -28,9 +29,7 @@
/**
* Creates a project from a project file.
*
- * @param location The path to the project file.
- * @param type The project file type. If null the type is inferred from
the
- * project file name.
+ * @param project The descriptor describing location and type of project
* @param parameters The project builder parameters.
* @return the created Project
* @throws Exception If an error occurs creating the Project.
@@ -39,7 +38,7 @@
* unless there is a protocol section like ftp:, file: etc
* @todo parameters needs more thought put into it.
*/
- Project createProject( String location, String type, Parameters
parameters )
+ Project createProject( ProjectDescriptor project, Parameters parameters )
throws Exception;
/**
1.16 +6 -3
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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Project.java 7 Jun 2002 07:07:52 -0000 1.15
+++ Project.java 8 Jun 2002 23:56:05 -0000 1.16
@@ -10,6 +10,7 @@
import java.io.File;
import org.apache.myrmidon.interfaces.model.Module;
import org.apache.myrmidon.interfaces.model.TargetMetaData;
+import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.metadata.ModelElement;
@@ -18,7 +19,7 @@
* Implementations may choose to structure it anyway they choose.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.15 $ $Date: 2002/06/07 07:07:52 $
+ * @version $Revision: 1.16 $ $Date: 2002/06/08 23:56:05 $
*/
public interface Project
extends Module
@@ -37,9 +38,11 @@
String getProjectName();
/**
- * Returns the URI of this project.
+ * Returns the descriptor for this project.
+ *
+ * @return the descriptor for this project.
*/
- String getURI();
+ ProjectDescriptor getProjectDescriptor();
/**
* Returns a referenced project.
1.2 +92 -2
jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/ProjectDescriptor.java
Index: ProjectDescriptor.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/ProjectDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProjectDescriptor.java 8 Jun 2002 07:32:03 -0000 1.1
+++ ProjectDescriptor.java 8 Jun 2002 23:56:05 -0000 1.2
@@ -12,7 +12,7 @@
* (ie it contains all information required to build project).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.1 $ $Date: 2002/06/08 07:32:03 $
+ * @version $Revision: 1.2 $ $Date: 2002/06/08 23:56:05 $
*/
public class ProjectDescriptor
{
@@ -28,8 +28,52 @@
public ProjectDescriptor( final String uri,
final String type )
{
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+
+ if( null == type )
+ {
+ m_type = guessType( uri );
+ }
+ else
+ {
+ m_type = type;
+ }
+
m_uri = uri;
- m_type = type;
+ }
+
+ /**
+ * Create a ProjectDescriptor for URI and guess type.
+ *
+ * @param uri the URI of project file.
+ */
+ public ProjectDescriptor( final String uri )
+ {
+ this( uri, null );
+ }
+
+ /**
+ * Guess the type of Project that is represented by URI.
+ * The type is guessed by taking extension of file
+ * as the type.
+ *
+ * @param uri the URI of project
+ * @return a guess for the type of project
+ */
+ public final static String guessType( final String uri )
+ {
+ final int index = uri.lastIndexOf( '.' );
+ if( -1 == index )
+ {
+ return "";
+ }
+ else
+ {
+ return uri.substring( index + 1 );
+ }
}
/**
@@ -73,5 +117,51 @@
sb.append( m_uri );
return sb.toString();
+ }
+
+ public boolean equals( final Object object )
+ {
+ if( this == object )
+ {
+ return true;
+ }
+ else if( !( object instanceof ProjectDescriptor ) )
+ {
+ return false;
+ }
+ else
+ {
+ final ProjectDescriptor other = (ProjectDescriptor)object;
+ final String type = other.getType();
+
+ if( !other.getUri().equals( m_uri ) )
+ {
+ return false;
+ }
+ else if( null == m_type && null == type )
+ {
+ return true;
+ }
+ else if( null == m_type || null == type )
+ {
+ return false;
+ }
+ else
+ {
+ return m_type.equals( type );
+ }
+ }
+ }
+
+ public int hashCode()
+ {
+ if( null == m_type )
+ {
+ return m_uri.hashCode();
+ }
+ else
+ {
+ return m_uri.hashCode() + m_type.hashCode();
+ }
}
}
1.17 +4 -4
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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Workspace.java 7 Jun 2002 05:48:20 -0000 1.16
+++ Workspace.java 8 Jun 2002 23:56:05 -0000 1.17
@@ -13,7 +13,7 @@
* This is the abstraction through which Modules are executed.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.16 $ $Date: 2002/06/07 05:48:20 $
+ * @version $Revision: 1.17 $ $Date: 2002/06/08 23:56:05 $
*/
public interface Workspace
{
@@ -21,13 +21,13 @@
String ROLE = Workspace.class.getName();
/**
- * Execute target in Project file specified by URI.
+ * Execute target in Project specified via descriptor.
* If target is null then execute the default target.
*
- * @param projectURI the URI of Project file
+ * @param project the project descriptor that indicates project to
execute
* @param target the target to execute, can be null
* @throws TaskException if error occurs executing target.
*/
- void execute( String projectURI, String target )
+ void execute( ProjectDescriptor project, String target )
throws TaskException;
}
1.14 +36 -16
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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DefaultProjectBuilderTestCase.java 7 Jun 2002 07:07:52 -0000
1.13
+++ DefaultProjectBuilderTestCase.java 8 Jun 2002 23:56:05 -0000
1.14
@@ -9,6 +9,7 @@
import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.framework.container.ContainerUtil;
@@ -22,13 +23,14 @@
import org.apache.myrmidon.interfaces.oldmodel.Project;
import org.apache.myrmidon.components.builder.Target;
import org.apache.myrmidon.interfaces.embeddor.Embeddor;
+import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
import org.apache.myrmidon.api.metadata.ModelElement;
/**
* Test cases for [EMAIL PROTECTED] DefaultProjectBuilder}.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Darrell DeBoer</a>
- * @version $Revision: 1.13 $ $Date: 2002/06/07 07:07:52 $
+ * @version $Revision: 1.14 $ $Date: 2002/06/08 23:56:05 $
*/
public class DefaultProjectBuilderTestCase
extends AbstractComponentTest
@@ -67,7 +69,7 @@
try
{
- m_builder.build( projFile.getAbsolutePath() );
+ build( projFile );
fail();
}
catch( ProjectException e )
@@ -85,7 +87,7 @@
try
{
- m_builder.build( projFile.getAbsolutePath() );
+ build( projFile );
fail();
}
catch( ProjectException e )
@@ -107,7 +109,7 @@
final File projFile = getTestResource( "bad-xml.ant" );
try
{
- m_builder.build( projFile.getAbsolutePath() );
+ build( projFile );
fail();
}
catch( ProjectException e )
@@ -129,12 +131,13 @@
{
// Build project
final File projFile = getTestResource( "defaults.ant" );
- final Project project = m_builder.build( projFile.getAbsolutePath()
);
+ Project project = build( projFile );
// Compare against expected project
+ final String uri = getURIFor( projFile );
final DefaultProject expected =
new DefaultProject( getNameFor( projFile ),
- getURIFor( projFile ),
+ new ProjectDescriptor( uri ),
getTestDirectory(),
"main",
null );
@@ -143,6 +146,20 @@
assertSameProject( expected, project );
}
+ private Project build( final File projFile ) throws ProjectException
+ {
+ try
+ {
+ final String uri = projFile.toURL().toExternalForm();
+ final ProjectDescriptor descriptor = new ProjectDescriptor( uri
);
+ return m_builder.build( descriptor );
+ }
+ catch( final MalformedURLException mue )
+ {
+ throw new ProjectException( mue.getMessage(), mue );
+ }
+ }
+
private void addTarget( final DefaultProject project,
final String name )
{
@@ -163,12 +180,13 @@
{
// Build project
final File projFile = getTestResource( "set-project-name.ant" );
- final Project project = m_builder.build( projFile.getAbsolutePath()
);
+ final Project project = build( projFile );
// Compare against expected project
+ final String uri = getURIFor( projFile );
final DefaultProject expected =
new DefaultProject( "some-project",
- getURIFor( projFile ),
+ new ProjectDescriptor( uri ),
getTestDirectory(),
"main",
null );
@@ -184,13 +202,14 @@
{
// Build project
final File projFile = getTestResource( "set-base-dir.ant" );
- final Project project = m_builder.build( projFile.getAbsolutePath()
);
+ final Project project = build( projFile );
// Compare against expected project
final File baseDir = getTestDirectory( "other-base-dir" );
+ final String uri = getURIFor( projFile );
final DefaultProject expected =
new DefaultProject( getNameFor( projFile ),
- getURIFor( projFile ),
+ new ProjectDescriptor( uri ),
baseDir,
"main",
null );
@@ -206,12 +225,13 @@
{
// Build project
final File projFile = getTestResource( "set-default-target.ant" );
- final Project project = m_builder.build( projFile.getAbsolutePath()
);
+ final Project project = build( projFile );
// Compare against expected project
+ final String uri = getURIFor( projFile );
DefaultProject expected =
new DefaultProject( getNameFor( projFile ),
- getURIFor( projFile ),
+ new ProjectDescriptor( uri ),
getTestDirectory(),
"some-target",
null );
@@ -229,7 +249,7 @@
File projFile = getTestResource( "no-version.ant" );
try
{
- m_builder.build( projFile.getAbsolutePath() );
+ build( projFile );
fail();
}
catch( ProjectException e )
@@ -246,7 +266,7 @@
projFile = getTestResource( "bad-version.ant" );
try
{
- m_builder.build( projFile.getAbsolutePath() );
+ build( projFile );
fail();
}
catch( ProjectException e )
@@ -263,7 +283,7 @@
projFile = getTestResource( "mismatched-version.ant" );
try
{
- m_builder.build( projFile.getAbsolutePath() );
+ build( projFile );
fail();
}
catch( ProjectException e )
@@ -312,7 +332,7 @@
final File badProjectFile = getTestResource( "bad-project-name.ant"
);
try
{
- m_builder.build( badProjectFile.getAbsolutePath() );
+ build( badProjectFile );
fail();
}
catch( Exception e )
1.23 +9 -3
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.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- DefaultEmbeddorTest.java 7 Jun 2002 07:07:52 -0000 1.22
+++ DefaultEmbeddorTest.java 8 Jun 2002 23:56:05 -0000 1.23
@@ -20,12 +20,13 @@
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.workspace.ProjectDescriptor;
/**
* Test cases for the default embeddor.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
- * @version $Revision: 1.22 $ $Date: 2002/06/07 07:07:52 $
+ * @version $Revision: 1.23 $ $Date: 2002/06/08 23:56:05 $
*/
public class DefaultEmbeddorTest
extends AbstractContainerTestCase
@@ -81,7 +82,9 @@
{
// Build the project
final File projectFile = getTestResource( "project-builder.ant" );
- final Project project = getEmbeddor().createProject(
projectFile.getAbsolutePath(), null, null );
+ final String uri = projectFile.toURL().toExternalForm();
+ final ProjectDescriptor descriptor = new ProjectDescriptor( uri );
+ final Project project = getEmbeddor().createProject( descriptor,
null );
// Verify the project.
assertEquals( "test-project", project.getMetaData().getName() );
@@ -119,7 +122,10 @@
// Build the project
final File projectFile = getTestResource( "project-builder.ant" );
final Embeddor embeddor = getEmbeddor();
- final Project project = embeddor.createProject(
projectFile.getAbsolutePath(), null, null );
+
+ final String uri = projectFile.toURL().toExternalForm();
+ final ProjectDescriptor descriptor = new ProjectDescriptor( uri );
+ final Project project = embeddor.createProject( descriptor, null );
// Build the workspace
final ExecutionFrame frame = embeddor.createExecutionFrame( new
HashMap() );
1.11 +7 -2
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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ExecuteTarget.java 7 Jun 2002 06:06:05 -0000 1.10
+++ ExecuteTarget.java 8 Jun 2002 23:56:05 -0000 1.11
@@ -18,6 +18,7 @@
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
import org.apache.myrmidon.interfaces.oldmodel.Project;
import org.apache.myrmidon.interfaces.model.TargetMetaData;
+import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
/**
* A utility class that simplifies executing a target in a project.
@@ -25,7 +26,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Darrell DeBoer</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
- * @version $Revision: 1.10 $ $Date: 2002/06/07 06:06:05 $
+ * @version $Revision: 1.11 $ $Date: 2002/06/08 23:56:05 $
*/
public class ExecuteTarget
{
@@ -146,7 +147,11 @@
{
return m_project;
}
- return embeddor.createProject( m_projectFile.getAbsolutePath(),
m_projectType, null );
+
+ final String uri = m_projectFile.toURL().toExternalForm();
+ final ProjectDescriptor descriptor =
+ new ProjectDescriptor( uri, m_projectType );
+ return embeddor.createProject( descriptor, null );
}
catch( final Exception e )
{
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>