ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework ExecuteTarget.java
Date Sun, 09 Jun 2002 04:53:35 GMT
donaldp     2002/06/08 21:53:35

  Modified:    ant1compat/src/java/org/apache/tools/ant/taskdefs
                        CallTarget.java
               antlib/src/java/org/apache/antlib/project
                        AbstractWorkspaceTask.java AntCallTask.java
                        Resources.properties
               container/src/java/org/apache/myrmidon/components/builder
                        DefaultProject.java DefaultProjectBuilder.java
                        Resources.properties
               container/src/java/org/apache/myrmidon/interfaces/oldmodel
                        Project.java
               container/src/test/org/apache/myrmidon/components/builder/test
                        DefaultProjectBuilderTestCase.java
               framework/src/java/org/apache/myrmidon/framework
                        ExecuteTarget.java
  Log:
  Remove Project.getProject and replace with Project.getProjectRef
  
  Revision  Changes    Path
  1.5       +3 -2      jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/CallTarget.java
  
  Index: CallTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/CallTarget.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CallTarget.java	28 Apr 2002 05:04:48 -0000	1.4
  +++ CallTarget.java	9 Jun 2002 04:53:34 -0000	1.5
  @@ -16,7 +16,7 @@
    * Myrmidon version.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.4 $ $Date: 2002/04/28 05:04:48 $
  + * @version $Revision: 1.5 $ $Date: 2002/06/09 04:53:34 $
    */
   public class CallTarget
       extends AbstractAnt1AntTask
  @@ -35,6 +35,7 @@
        */
       protected void prepare( final ExecuteTarget exe ) throws TaskException
       {
  -        exe.setProject( (Project)m_context.getService( Project.class ) );
  +        final Project project = (Project)m_context.getService( Project.class );
  +        exe.setProject( project.getProjectDescriptor() );
       }
   }
  
  
  
  1.7       +20 -7     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractWorkspaceTask.java	8 Jun 2002 23:56:04 -0000	1.6
  +++ AbstractWorkspaceTask.java	9 Jun 2002 04:53:34 -0000	1.7
  @@ -12,14 +12,15 @@
   import org.apache.myrmidon.api.TaskException;
   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;
  +import org.apache.myrmidon.interfaces.workspace.ProjectRef;
  +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.6 $ $Date: 2002/06/08 23:56:04 $
  + * @version $Revision: 1.7 $ $Date: 2002/06/09 04:53:34 $
    */
   abstract class AbstractWorkspaceTask
       extends AbstractContainerTask
  @@ -42,10 +43,10 @@
           getContext().debug( message );
   
           // Locate the referenced target
  -        final Project project = getProject( dependency );
  +        final ProjectDescriptor project = getProject( dependency );
           final String targetName = dependency.getTargetName();
   
  -        executeTarget( project.getProjectDescriptor(), targetName );
  +        executeTarget( project, targetName );
       }
   
       /**
  @@ -71,18 +72,30 @@
        * @return
        * @throws TaskException
        */
  -    protected final Project getProject( final Dependency dependency )
  +    protected final ProjectDescriptor getProject( final Dependency dependency )
           throws TaskException
       {
           final Project project = (Project)getContext().getService( Project.class );
           final String projectName = dependency.getProjectName();
           if( null == projectName )
           {
  -            return project;
  +            return project.getProjectDescriptor();
           }
           else
           {
  -            return project.getProject( projectName );
  +            final ProjectRef projectRef = project.getProjectRef( projectName );
  +            if( null == projectRef )
  +            {
  +                final String message =
  +                    REZ.getString( "workspace.missing-ref.error",
  +                                   projectName,
  +                                   dependency );
  +                throw new TaskException( message );
  +            }
  +            else
  +            {
  +                return projectRef.getProject();
  +            }
           }
       }
   }
  
  
  
  1.5       +14 -10    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AntCallTask.java	4 Jun 2002 12:33:03 -0000	1.4
  +++ AntCallTask.java	9 Jun 2002 04:53:34 -0000	1.5
  @@ -10,28 +10,31 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.ExecuteTarget;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  +import org.apache.myrmidon.interfaces.workspace.ProjectRef;
  +import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   
   /**
    * A task which executes a target in the current project,
    * or a referenced project.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.4 $ $Date: 2002/06/04 12:33:03 $
  + * @version $Revision: 1.5 $ $Date: 2002/06/09 04:53:34 $
    * @ant.task name="ant-call"
    */
   public class AntCallTask
       extends AbstractAntTask
   {
  -    private String m_project;
  +    private String m_projectName;
   
       /**
        * Specifies the project to execute. If not specified, the current
        * project is used.
  +     *
        * @param project the name of the Project to execute.
        */
       public void setProject( String project )
       {
  -        m_project = project;
  +        m_projectName = project;
       }
   
       /**
  @@ -43,14 +46,15 @@
               (Project)getContext().getService( Project.class );
   
           // By default, use the current project.
  -        if( null == m_project )
  -        {
  -            exe.setProject( currentProject );
  -        }
  -        else
  +        ProjectDescriptor project = currentProject.getProjectDescriptor();
  +
  +        if( null != m_projectName )
           {
  -            final Project refProject = currentProject.getProject( m_project );
  -            exe.setProject( refProject );
  +            final ProjectRef projectRef =
  +                currentProject.getProjectRef( m_projectName );
  +            project = projectRef.getProject();
           }
  +
  +        exe.setProject( project );
       }
   }
  
  
  
  1.11      +1 -0      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Resources.properties	2 Jun 2002 14:08:05 -0000	1.10
  +++ Resources.properties	9 Jun 2002 04:53:34 -0000	1.11
  @@ -6,6 +6,7 @@
   target.bad-dependency.error=Discovered empty dependency in target "{0}" at {1}.
   
   workspace.exec-depends.notice=Executing dependency: {0}
  +workspace.missing-ref.error=Unable to locate Project Reference "{0}" for dependency "{1}".
   
   depends.no-target.error=No target specified in <depends/> task.
   
  
  
  
  1.25      +11 -54    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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- DefaultProject.java	9 Jun 2002 03:58:34 -0000	1.24
  +++ DefaultProject.java	9 Jun 2002 04:53:34 -0000	1.25
  @@ -17,19 +17,18 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.metadata.ModelElement;
   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.workspace.ProjectDescriptor;
   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:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.24 $ $Date: 2002/06/09 03:58:34 $
  + * @version $Revision: 1.25 $ $Date: 2002/06/09 04:53:34 $
    */
   public class DefaultProject
       extends AbstractLogEnabled
  @@ -59,31 +58,21 @@
       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 Map m_targets = new HashMap();
   
       private final ProjectDescriptor m_descriptor;
   
  -    private Embeddor m_embeddor;
  -
  -
       public DefaultProject( final String name,
                              final ProjectDescriptor descriptor,
                              final File baseDirectory,
  -                           final String defaultTarget,
  -                           final Embeddor embeddor )
  +                           final String defaultTarget )
       {
           m_name = name;
           m_descriptor = descriptor;
           m_baseDirectory = baseDirectory;
           m_defaultTarget = defaultTarget;
  -        m_embeddor = embeddor;
       }
   
       /**
  @@ -107,52 +96,20 @@
           return m_descriptor;
       }
   
  -    /**
  -     * Returns a referenced project.
  -     *
  -     * @param name the project name
  -     * @return the project.
  -     * @throws TaskException if the request project is unknown.
  -     */
  -    public Project getProject( final String name ) throws TaskException
  -    {
  -        // 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 )
  +    public ProjectRef getProjectRef( String name )
           throws TaskException
       {
  -        final ProjectRef ref = (ProjectRef)m_references.get( name );
  -        if( ref == null )
  +        // TODO - this does not handle dependency cycles between projects
  +        final ProjectRef project = (ProjectRef)m_references.get( name );
  +        if( null == project )
           {
  -            final String message = REZ.getString( "project.unknown-ref.error", name );
  +            final String message =
  +                REZ.getString( "project.missing-ref.error",
  +                               name );
               throw new TaskException( message );
           }
   
  -        final ProjectDescriptor project = ref.getProject();
  -        try
  -        {
  -            return m_embeddor.createProject( project );
  -        }
  -        catch( final Exception e )
  -        {
  -            final String message =
  -                REZ.getString( "project.nobuild-project.error",
  -                               project.getUri(),
  -                               project.getType() );
  -            throw new TaskException( message, e );
  -        }
  +        return project;
       }
   
       /**
  
  
  
  1.71      +2 -3      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.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- DefaultProjectBuilder.java	9 Jun 2002 03:55:48 -0000	1.70
  +++ DefaultProjectBuilder.java	9 Jun 2002 04:53:34 -0000	1.71
  @@ -34,7 +34,7 @@
    * Default implementation to construct project from a build file.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.70 $ $Date: 2002/06/09 03:55:48 $
  + * @version $Revision: 1.71 $ $Date: 2002/06/09 04:53:34 $
    *
    * @ant.type type="project-builder" name="ant2"
    */
  @@ -138,8 +138,7 @@
                   new DefaultProject( projectName,
                                       descriptor,
                                       baseDirectory,
  -                                    defaultTarget,
  -                                    m_embeddor );
  +                                    defaultTarget );
               setupLogger( project );
               buildTopLevelProject( baseDirectory, model, project );
   
  
  
  
  1.15      +1 -0      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Resources.properties	9 Jun 2002 03:34:46 -0000	1.14
  +++ Resources.properties	9 Jun 2002 04:53:34 -0000	1.15
  @@ -34,6 +34,7 @@
   project.unknown-ref.error=Unknown project reference "{0}".
   project.nobuild-project.error=Could not load referenced project "{0}" with type "{1}".
   project.unknown-target.error=Unknown target "{0}".
  +project.missing-ref.error=Unable to locate project reference "{0}".
   
   builder.create.error=Error creating Project of type "{0}" at "{1}". (Reason: {2})
   builder.destroy.error=Error destroying builder of type "{0}". (Reason: {1})
  
  
  
  1.17      +5 -4      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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Project.java	8 Jun 2002 23:56:05 -0000	1.16
  +++ Project.java	9 Jun 2002 04:53:34 -0000	1.17
  @@ -11,6 +11,7 @@
   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.interfaces.workspace.ProjectRef;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.metadata.ModelElement;
   
  @@ -19,7 +20,7 @@
    * Implementations may choose to structure it anyway they choose.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.16 $ $Date: 2002/06/08 23:56:05 $
  + * @version $Revision: 1.17 $ $Date: 2002/06/09 04:53:34 $
    */
   public interface Project
       extends Module
  @@ -45,13 +46,13 @@
       ProjectDescriptor getProjectDescriptor();
   
       /**
  -     * Returns a referenced project.
  +     * Returns the project reference for specified name.
        *
        * @param name the project name
  -     * @return the project.
  +     * @return the project reference for specified name.
        * @throws TaskException if the request project is unknown.
        */
  -    Project getProject( String name ) throws TaskException;
  +    ProjectRef getProjectRef( String name ) throws TaskException;
   
       /**
        * Return the default target for this project.
  
  
  
  1.15      +5 -9      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DefaultProjectBuilderTestCase.java	8 Jun 2002 23:56:05 -0000	1.14
  +++ DefaultProjectBuilderTestCase.java	9 Jun 2002 04:53:35 -0000	1.15
  @@ -30,7 +30,7 @@
    * Test cases for {@link DefaultProjectBuilder}.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.14 $ $Date: 2002/06/08 23:56:05 $
  + * @version $Revision: 1.15 $ $Date: 2002/06/09 04:53:35 $
    */
   public class DefaultProjectBuilderTestCase
       extends AbstractComponentTest
  @@ -139,8 +139,7 @@
               new DefaultProject( getNameFor( projFile ),
                                   new ProjectDescriptor( uri ),
                                   getTestDirectory(),
  -                                "main",
  -                                null );
  +                                "main" );
           addTarget( expected, "main" );
           addTarget( expected, Project.IMPLICIT_TARGET_NAME );
           assertSameProject( expected, project );
  @@ -188,8 +187,7 @@
               new DefaultProject( "some-project",
                                   new ProjectDescriptor( uri ),
                                   getTestDirectory(),
  -                                "main",
  -                                null );
  +                                "main" );
           addTarget( expected, "main" );
           addTarget( expected, Project.IMPLICIT_TARGET_NAME );
           assertSameProject( expected, project );
  @@ -211,8 +209,7 @@
               new DefaultProject( getNameFor( projFile ),
                                   new ProjectDescriptor( uri ),
                                   baseDir,
  -                                "main",
  -                                null );
  +                                "main" );
           addTarget( expected, "main" );
           addTarget( expected, Project.IMPLICIT_TARGET_NAME );
           assertSameProject( expected, project );
  @@ -233,8 +230,7 @@
               new DefaultProject( getNameFor( projFile ),
                                   new ProjectDescriptor( uri ),
                                   getTestDirectory(),
  -                                "some-target",
  -                                null );
  +                                "some-target" );
           addTarget( expected, "some-target" );
           addTarget( expected, Project.IMPLICIT_TARGET_NAME );
           assertSameProject( expected, project );
  
  
  
  1.13      +19 -21    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ExecuteTarget.java	9 Jun 2002 03:58:35 -0000	1.12
  +++ ExecuteTarget.java	9 Jun 2002 04:53:35 -0000	1.13
  @@ -8,6 +8,7 @@
   package org.apache.myrmidon.framework;
   
   import java.io.File;
  +import java.net.MalformedURLException;
   import java.util.HashMap;
   import java.util.Map;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
  @@ -16,8 +17,8 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   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.oldmodel.Project;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   
   /**
  @@ -26,7 +27,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.12 $ $Date: 2002/06/09 03:58:35 $
  + * @version $Revision: 1.13 $ $Date: 2002/06/09 04:53:35 $
    */
   public class ExecuteTarget
   {
  @@ -35,10 +36,8 @@
   
       private boolean m_inheritAll;
       private String m_target;
  -    private Project m_project;
  +    private ProjectDescriptor m_project;
       private final Map m_parameters = new HashMap();
  -    private File m_projectFile;
  -    private String m_projectType;
   
       /**
        * Enables the inheritance of properties from the calling task.  Default
  @@ -61,21 +60,28 @@
       /**
        * Sets the project to execute.
        */
  -    public void setProject( final Project project )
  +    public void setProject( final ProjectDescriptor project )
       {
           m_project = project;
  -        m_projectFile = null;
  -        m_projectType = null;
       }
   
       /**
        * Sets the project file to execute.
        */
  -    public void setProjectFile( final File projectFile, final String projectType )
  +    public void setProjectFile( final File projectFile,
  +                                final String projectType )
  +        throws TaskException
       {
  -        m_projectFile = projectFile;
  -        m_projectType = projectType;
  -        m_project = null;
  +        try
  +        {
  +            final String uri = projectFile.toURL().toExternalForm();
  +            m_project =
  +                new ProjectDescriptor( uri, projectType );
  +        }
  +        catch( final MalformedURLException mue )
  +        {
  +            throw new TaskException( mue.getMessage(), mue );
  +        }
       }
   
       /**
  @@ -143,15 +149,7 @@
       {
           try
           {
  -            if( m_project != null )
  -            {
  -                return m_project;
  -            }
  -
  -            final String uri = m_projectFile.toURL().toExternalForm();
  -            final ProjectDescriptor descriptor =
  -                new ProjectDescriptor( uri, m_projectType );
  -            return embeddor.createProject( descriptor );
  +            return embeddor.createProject( m_project );
           }
           catch( final Exception e )
           {
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message