You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/06/29 09:45:26 UTC

cvs commit: jakarta-ant/proposal/myrmidon/src/make primitive-tests.ant sample.ant

donaldp     01/06/29 00:45:26

  Modified:    proposal/myrmidon build.xml
               proposal/myrmidon/src/java/org/apache/myrmidon/components/manager
                        DefaultProjectManager.java
               proposal/myrmidon/src/make primitive-tests.ant sample.ant
  Log:
  Updated so that each project has a separate Deployer (that writes to separate TypeManager).
  
  Updated so that TypeLib (ie import of type libs in build file) will actually be obeyed and import types in as appropriate. Currently type libs are only loaded from <base-dir>/ext/*.atl however this will be exapnded in the future.
  
  Updated examples to reflect the new working TypeLib system and so as cross-project deployer can be verified.
  
  Updated build process so that the self testing code is placed in dist/ext and thus has to be explicitly loaded via an import
  
  Revision  Changes    Path
  1.18      +11 -1     jakarta-ant/proposal/myrmidon/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/build.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- build.xml	2001/06/17 00:35:15	1.17
  +++ build.xml	2001/06/29 07:45:20	1.18
  @@ -57,6 +57,7 @@
     <property name="dist.dir" value="dist"/>
     <property name="dist.bin" value="${dist.dir}/bin"/>
     <property name="dist.lib" value="${dist.dir}/lib"/>
  +  <property name="dist.ext" value="${dist.dir}/ext"/>
   
     <property name="constants.file" value="org/apache/myrmidon/Constants.java"/>
   
  @@ -159,11 +160,20 @@
   
       <mkdir dir="${dist.bin}"/>
       <mkdir dir="${dist.lib}"/>
  +    <mkdir dir="${dist.ext}"/>
   
       <copy file="tools/lib/ant.jar" tofile="${dist.lib}/ant1-compat.jar" />
   
       <copy todir="${dist.lib}">
  -      <fileset dir="${build.lib}"/>
  +      <fileset dir="${build.lib}">
  +        <exclude name="selftest.atl"/>
  +      </fileset>
  +    </copy>
  +
  +    <copy todir="${dist.ext}">
  +      <fileset dir="${build.lib}">
  +        <include name="selftest.atl"/>
  +      </fileset>
       </copy>
   
       <copy todir="${dist.lib}">
  
  
  
  1.11      +84 -1     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java
  
  Index: DefaultProjectManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultProjectManager.java	2001/06/27 00:50:06	1.10
  +++ DefaultProjectManager.java	2001/06/29 07:45:22	1.11
  @@ -7,6 +7,7 @@
    */
   package org.apache.myrmidon.components.manager;
   
  +import java.io.File;
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.Map;
  @@ -30,7 +31,11 @@
   import org.apache.myrmidon.components.executor.ExecutionFrame;
   import org.apache.myrmidon.components.executor.Executor;
   import org.apache.myrmidon.framework.Condition;
  +import org.apache.myrmidon.components.deployer.DefaultDeployer;
  +import org.apache.myrmidon.components.deployer.Deployer;
  +import org.apache.myrmidon.components.deployer.DeploymentException;
   import org.apache.myrmidon.components.model.Project;
  +import org.apache.myrmidon.components.model.TypeLib;
   import org.apache.myrmidon.components.model.Target;
   import org.apache.myrmidon.components.type.TypeManager;
   import org.apache.myrmidon.listeners.ProjectListener;
  @@ -142,6 +147,64 @@
           return context;
       }
   
  +    private File findTypeLib( final String libraryName )
  +        throws TaskException
  +    {
  +        //TODO: In future this will be expanded to allow
  +        //users to specify search path or automagically 
  +        //add entries to lib path (like user specific or 
  +        //workspace specific)
  +        final String name = libraryName.replace( '/', File.separatorChar ) + ".atl";
  +
  +        final String home = System.getProperty( "myrmidon.home" );
  +        final File homeDir = new File( home + File.separatorChar + "ext" );
  +        
  +        final File library = new File( homeDir, name );
  +
  +        if( library.exists() )
  +        {
  +            if( !library.canRead() )
  +            {
  +                throw new TaskException( "Unable to read library at " + library );
  +            }
  +            else
  +            {
  +                return library;
  +            }
  +        }
  +
  +        throw new TaskException( "Unable to locate Type Library " + libraryName );
  +    }
  +
  +    private void deployTypeLib( final Deployer deployer, final Project project )
  +        throws TaskException
  +    {
  +        final TypeLib[] typeLibs = project.getTypeLibs();
  +
  +        for( int i = 0; i < typeLibs.length; i++ )
  +        {
  +            final TypeLib typeLib = typeLibs[ i ];
  +            final File file = findTypeLib( typeLib.getLibrary() );
  +
  +            try
  +            {
  +                if( null == typeLib.getRole() )
  +                {
  +                    deployer.deploy( file );
  +                }
  +                else
  +                {
  +                    deployer.deployType( typeLib.getRole(), typeLib.getName(), file );
  +                }
  +            }
  +            catch( final DeploymentException de )
  +            {
  +                throw new TaskException( "Error deploying type library " + 
  +                                         typeLib + " at " + file, de );
  +            }
  +        }
  +    }
  +
       private ExecutionFrame createExecutionFrame( final Project project )
           throws TaskException
       {
  @@ -154,7 +217,27 @@
   
           //Add in child type manager so each frame can register different 
           //sets of tasks etc
  -        componentManager.put( TypeManager.ROLE, m_typeManager.createChildTypeManager() );
  +        final TypeManager typeManager = m_typeManager.createChildTypeManager();
  +        componentManager.put( TypeManager.ROLE, typeManager );
  +
  +        //We need to create a new deployer so that it deploys
  +        //to project specific TypeManager
  +        final DefaultDeployer deployer = new DefaultDeployer();
  +        deployer.setLogger( getLogger() );
  +
  +        try { deployer.compose( componentManager ); }
  +        catch( final ComponentException ce )
  +        {
  +            throw new TaskException( "Error configuring deployer", ce );
  +        }
  +
  +        //HACK: Didn't call initialize because Deployer contained in Embeddor
  +        // Already initialized and this would be reduendent
  +        //deployer.initialize();
  +
  +        componentManager.put( Deployer.ROLE, deployer );
  +
  +        deployTypeLib( deployer, project );
   
           //We need to place projects and ProjectManager
           //in ComponentManager so as to support project-local call()
  
  
  
  1.2       +7 -0      jakarta-ant/proposal/myrmidon/src/make/primitive-tests.ant
  
  Index: primitive-tests.ant
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/make/primitive-tests.ant,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- primitive-tests.ant	2001/06/10 12:56:59	1.1
  +++ primitive-tests.ant	2001/06/29 07:45:24	1.2
  @@ -16,9 +16,16 @@
   
   <project name="MySample" default="main" basedir=".">
   
  +  <import library="selftest" />
  +
     <property name="year" value="2000"/>
   
     <target name="main" depends="test-target" />
  +
  +  <target name="undefined-task">
  +    <echo message="About to execute task that hasn't been defined"/>
  +    <echo2 message="This should have failed"/>
  +  </target>
   
     <target name="no-test-target" if="no-do-tests">
       <echo message="No tests done here"/>
  
  
  
  1.12      +2 -1      jakarta-ant/proposal/myrmidon/src/make/sample.ant
  
  Index: sample.ant
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/make/sample.ant,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- sample.ant	2001/06/29 02:40:07	1.11
  +++ sample.ant	2001/06/29 07:45:24	1.12
  @@ -17,11 +17,12 @@
   <project name="MySample" default="main" basedir=".">
   
     <projectref name="prim" location="primitive-tests.ant" />
  -  <import library="core.atl" />
   
     <property name="year" value="2000"/>
   
     <target name="main" depends="typedef-test, converterdef-test, datatype-test, namespace-test, ant1-tasklib-test" />
  +
  +  <target name="xp-deployer-test" depends="typedef-test, prim->undefined-task" />
   
     <target name="all" depends="property-test, typedef-test, converterdef-test, ant-call-test, datatype-test, namespace-test, ant1-tasklib-test, prim->main" />