From 1c204914d03e9bc53afb4ebf3c56a0181c10ab51 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Fri, 29 Jun 2001 07:45:24 +0000 Subject: [PATCH] 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 /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 --- proposal/myrmidon/build.xml | 12 ++- .../manager/DefaultProjectManager.java | 85 ++++++++++++++++++- .../myrmidon/src/make/primitive-tests.ant | 7 ++ proposal/myrmidon/src/make/sample.ant | 3 +- 4 files changed, 104 insertions(+), 3 deletions(-) diff --git a/proposal/myrmidon/build.xml b/proposal/myrmidon/build.xml index 6f3c4bf66..22c487e08 100644 --- a/proposal/myrmidon/build.xml +++ b/proposal/myrmidon/build.xml @@ -57,6 +57,7 @@ Legal: + @@ -159,11 +160,20 @@ Legal: + - + + + + + + + + + diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java index 1c00abb38..8512ad177 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java @@ -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() diff --git a/proposal/myrmidon/src/make/primitive-tests.ant b/proposal/myrmidon/src/make/primitive-tests.ant index 8a91307a7..044c097c0 100644 --- a/proposal/myrmidon/src/make/primitive-tests.ant +++ b/proposal/myrmidon/src/make/primitive-tests.ant @@ -16,10 +16,17 @@ Legal: + + + + + + + diff --git a/proposal/myrmidon/src/make/sample.ant b/proposal/myrmidon/src/make/sample.ant index da2c7eaf2..641414483 100644 --- a/proposal/myrmidon/src/make/sample.ant +++ b/proposal/myrmidon/src/make/sample.ant @@ -17,12 +17,13 @@ Legal: - + +