Browse Source

Modify ProjectBuilder interface to accept Parameters. This allows arbitrary builders to be added in the future (such as for templating etc).

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269171 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
4a677e7d65
3 changed files with 28 additions and 7 deletions
  1. +5
    -4
      proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  2. +2
    -1
      proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ProjectBuilder.java
  3. +21
    -2
      proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java

+ 5
- 4
proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java View File

@@ -18,6 +18,7 @@ import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.SAXConfigurationHandler; import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
import org.apache.avalon.framework.logger.AbstractLoggable; import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.log.Logger; import org.apache.log.Logger;
import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.components.model.Condition; import org.apache.myrmidon.components.model.Condition;
@@ -50,7 +51,7 @@ public class DefaultProjectBuilder
* @exception IOException if an error occurs * @exception IOException if an error occurs
* @exception Exception if an error occurs * @exception Exception if an error occurs
*/ */
public Project build( final String source )
public Project build( final String source, final Parameters parameters )
throws Exception throws Exception
{ {
final File file = new File( source ); final File file = new File( source );
@@ -102,7 +103,7 @@ public class DefaultProjectBuilder
* @exception Exception if an error occurs * @exception Exception if an error occurs
* @exception ConfigurationException if an error occurs * @exception ConfigurationException if an error occurs
*/ */
private DefaultProject buildProject( final File file,
private DefaultProject buildProject( final File file,
final Configuration configuration ) final Configuration configuration )
throws Exception throws Exception
{ {
@@ -226,7 +227,7 @@ public class DefaultProjectBuilder
if( !validName( name ) ) if( !validName( name ) )
{ {
throw new Exception( "Projectref with an invalid name attribute at " + throw new Exception( "Projectref with an invalid name attribute at " +
element.getLocation() );
element.getLocation() );
} }


if( null == location ) if( null == location )
@@ -301,7 +302,7 @@ public class DefaultProjectBuilder
if( !validName( name ) ) if( !validName( name ) )
{ {
throw new Exception( "Target with an invalid name at " + throw new Exception( "Target with an invalid name at " +
target.getLocation() );
target.getLocation() );
} }


getLogger().debug( "Parsing target: " + name ); getLogger().debug( "Parsing target: " + name );


+ 2
- 1
proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/ProjectBuilder.java View File

@@ -10,6 +10,7 @@ package org.apache.myrmidon.components.builder;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.myrmidon.components.model.Project; import org.apache.myrmidon.components.model.Project;


/** /**
@@ -30,6 +31,6 @@ public interface ProjectBuilder
* @exception IOException if an error occurs * @exception IOException if an error occurs
* @exception AntException if an error occurs * @exception AntException if an error occurs
*/ */
Project build( String source )
Project build( String source, Parameters parameters )
throws Exception; throws Exception;
} }

+ 21
- 2
proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java View File

@@ -76,11 +76,30 @@ public class DefaultEmbeddor
} }


public Project createProject( final String location, public Project createProject( final String location,
final String type,
String type,
final Parameters parameters ) final Parameters parameters )
throws Exception throws Exception
{ {
return m_builder.build( location );
if( null == type )
{
type = guessTypeFor( location );
}

final ProjectBuilder builder = getProjectBuilder( type );
return builder.build( location, parameters );
}

private String guessTypeFor( final String location )
{
//TODO: use hueristics to map filename extention to type
return "ant";
}

private ProjectBuilder getProjectBuilder( final String type )
throws Exception
{
//FIXME: Should not be ignoring type
return m_builder;
} }


public ProjectManager createProjectManager( final Project project, public ProjectManager createProjectManager( final Project project,


Loading…
Cancel
Save