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/container/src/java/org/apache/myrmidon/interfaces EmbeddedAnt.java
Date Thu, 13 Jun 2002 04:24:40 GMT
donaldp     2002/06/12 21:24:40

  Modified:    framework/src/test/org/apache/myrmidon/framework
                        AbstractTaskTestCase.java
               container/src/java/org/apache/myrmidon/frontends
                        CLIMain.java
               container/src/java/org/apache/myrmidon/interfaces
                        EmbeddedAnt.java
  Log:
  Simplify EmbeddedAnt so that it takes a ProjectDescriptor
  
  Revision  Changes    Path
  1.2       +6 -3      jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/AbstractTaskTestCase.java
  
  Index: AbstractTaskTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/AbstractTaskTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractTaskTestCase.java	5 Jun 2002 07:58:22 -0000	1.1
  +++ AbstractTaskTestCase.java	13 Jun 2002 04:24:40 -0000	1.2
  @@ -14,6 +14,7 @@
   import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.components.AbstractComponentTest;
   import org.apache.myrmidon.interfaces.EmbeddedAnt;
  +import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   import org.apache.myrmidon.TrackingTaskListener;
   
   /**
  @@ -171,8 +172,10 @@
               embeddor.enableLogging( getLogger() );
               embeddor.setSharedClassLoader( getClass().getClassLoader() );
               embeddor.setContainerClassLoader( getClass().getClassLoader() );
  -            embeddor.setProjectFile( projectFile.getAbsolutePath() );
  -            embeddor.setProjectType( getProjectType() );
  +
  +            final String uri =
  +                projectFile.getAbsoluteFile().toURL().toExternalForm();
  +            embeddor.setProjectDescriptor( new ProjectDescriptor( uri, getProjectType()
) );
               if( props != null )
               {
                   for( Iterator iterator = props.entrySet().iterator(); iterator.hasNext();
)
  
  
  
  1.50      +30 -3     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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- CLIMain.java	13 Jun 2002 02:42:43 -0000	1.49
  +++ CLIMain.java	13 Jun 2002 04:24:40 -0000	1.50
  @@ -10,6 +10,7 @@
   import java.io.BufferedReader;
   import java.io.File;
   import java.io.InputStreamReader;
  +import java.net.MalformedURLException;
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -30,6 +31,7 @@
   import org.apache.myrmidon.interfaces.BasicLogger;
   import org.apache.myrmidon.interfaces.EmbeddedAnt;
   import org.apache.myrmidon.interfaces.executor.Executor;
  +import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   
   /**
    * The class to kick the tires and light the fires.
  @@ -281,6 +283,9 @@
               throw new Exception( message );
           }
   
  +        String projectFile = null;
  +        String projectType = null;
  +
           final EmbeddedAnt embeddedAnt = m_embedded;
   
           final List clOptions = parser.getArguments();
  @@ -322,7 +327,7 @@
                       break;
   
                   case FILE_OPT:
  -                    embeddedAnt.setProjectFile( option.getArgument() );
  +                    projectFile = option.getArgument();
                       break;
   
                   case LISTENER_OPT:
  @@ -354,7 +359,7 @@
                       break;
   
                   case TYPE_OPT:
  -                    embeddedAnt.setProjectType( option.getArgument( 0 ) );
  +                    projectType = option.getArgument( 0 );
                       break;
   
                   case 0:
  @@ -363,7 +368,29 @@
               }
           }
   
  +        setupBuildFile( embeddedAnt, projectFile, projectType );
  +
           return true;
  +    }
  +
  +    private void setupBuildFile( final EmbeddedAnt embeddedAnt,
  +                                 final String projectFile,
  +                                 final String projectType )
  +    {
  +        if( null != projectFile )
  +        {
  +            final File file = new File( projectFile ).getAbsoluteFile();
  +            String uri = file.toString();
  +            try
  +            {
  +                uri = file.toURL().toExternalForm();
  +            }
  +            catch( final MalformedURLException mue )
  +            {
  +            }
  +
  +            embeddedAnt.setProjectDescriptor( new ProjectDescriptor( uri, projectType )
);
  +        }
       }
   
       protected void execute( final Map properties, final String[] args )
  
  
  
  1.27      +9 -37     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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- EmbeddedAnt.java	13 Jun 2002 03:52:32 -0000	1.26
  +++ EmbeddedAnt.java	13 Jun 2002 04:24:40 -0000	1.27
  @@ -24,7 +24,6 @@
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
  -import org.apache.myrmidon.interfaces.model.Project;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   
   /**
  @@ -54,11 +53,10 @@
       private final Map m_workspaceProperties = new HashMap();
   
       private String m_projectFile = "build.ant";
  -    private Project m_project;
  +    private ProjectDescriptor m_project;
       private ClassLoader m_sharedClassLoader;
       private Embeddor m_embeddor;
       private File m_homeDir;
  -    private String m_projectType;
       private ClassLoader m_containerClassLoader;
   
       /**
  @@ -73,32 +71,8 @@
           m_homeDir = homeDir.getAbsoluteFile();
       }
   
  -    /**
  -     * Sets the project file to execute.  Default is 'build.ant'.
  -     */
  -    public void setProjectFile( final String projectFile )
  -    {
  -        m_projectFile = projectFile;
  -        m_project = null;
  -    }
  -
  -    /**
  -     * Sets the project file type.  Ignored if {@link #setProject} is used.
  -     * Set to null to use the default project type.
  -     */
  -    public void setProjectType( final String projectType )
  -    {
  -        m_projectType = projectType;
  -    }
  -
  -    /**
  -     * Sets the project to execute.  This method can be used instead of
  -     * {@link #setProjectFile}, for projects models that are built
  -     * programmatically.
  -     */
  -    public void setProject( final Project project )
  +    public void setProjectDescriptor( final ProjectDescriptor project )
       {
  -        m_projectFile = null;
           m_project = project;
       }
   
  @@ -175,7 +149,7 @@
   
           // Prepare the embeddor, and project model
           final Embeddor embeddor = prepareEmbeddor( embeddorParameters );
  -        final Project project = prepareProjectModel( embeddor );
  +        final ProjectDescriptor project = prepareProjectDescriptor();
   
           final ExecutionFrame frame =
               embeddor.createExecutionFrame( m_workspaceProperties );
  @@ -209,7 +183,7 @@
        * Actually do the build.
        */
       private void executeTargets( final ExecutionFrame frame,
  -                                 final Project project,
  +                                 final ProjectDescriptor project,
                                    final String[] targets )
           throws TaskException
       {
  @@ -218,13 +192,13 @@
           {
               //final String targetName = project.getDefaultTargetName();
               //Next line an utter hack - need to rejif it completely
  -            m_embeddor.execute( frame, project.getProjectDescriptor(), null );
  +            m_embeddor.execute( frame, project, null );
           }
           else
           {
               for( int i = 0; i < targets.length; i++ )
               {
  -                m_embeddor.execute( frame, project.getProjectDescriptor(), targets[ i ]
);
  +                m_embeddor.execute( frame, project, targets[ i ] );
               }
           }
       }
  @@ -324,17 +298,15 @@
       /**
        * Prepares and returns the project model.
        */
  -    private Project prepareProjectModel( final Embeddor embeddor )
  +    private ProjectDescriptor prepareProjectDescriptor()
           throws Exception
       {
           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( descriptor );
  +                new ProjectDescriptor( uri );
           }
           return m_project;
       }
  
  
  

--
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