Browse Source

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


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269251 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
1c204914d0
4 changed files with 104 additions and 3 deletions
  1. +11
    -1
      proposal/myrmidon/build.xml
  2. +84
    -1
      proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java
  3. +7
    -0
      proposal/myrmidon/src/make/primitive-tests.ant
  4. +2
    -1
      proposal/myrmidon/src/make/sample.ant

+ 11
- 1
proposal/myrmidon/build.xml View File

@@ -57,6 +57,7 @@ Legal:
<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 @@ Legal:

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


+ 84
- 1
proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java View File

@@ -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.DefaultExecutionFrame;
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 @@ public class DefaultProjectManager
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 @@ public class DefaultProjectManager

//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()


+ 7
- 0
proposal/myrmidon/src/make/primitive-tests.ant View File

@@ -16,10 +16,17 @@ Legal:

<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"/>
</target>


+ 2
- 1
proposal/myrmidon/src/make/sample.ant View File

@@ -17,12 +17,13 @@ Legal:
<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" />

<!--


Loading…
Cancel
Save