From dd0a617ea06a9b95681812b868d536c01a3b5c86 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sat, 16 Jun 2001 03:21:03 +0000 Subject: [PATCH] Remove old ant1 compatibility layer in preparation to move it. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269177 13f79535-47bb-0310-9956-ffa450edef68 --- .../myrmidon/framework/ant1/Ant1Project.java | 153 ------------------ .../framework/ant1/Ant1TypeFactory.java | 57 ------- .../myrmidon/framework/ant1/TaskAdapter.java | 76 --------- 3 files changed, 286 deletions(-) delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/Ant1Project.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/Ant1TypeFactory.java delete mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/TaskAdapter.java diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/Ant1Project.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/Ant1Project.java deleted file mode 100644 index 5d14460de..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/Ant1Project.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.myrmidon.framework.ant1; - -import java.io.File; -import org.apache.avalon.framework.context.Context; -import org.apache.avalon.framework.context.Contextualizable; -import org.apache.avalon.framework.logger.Loggable; -import org.apache.log.Logger; -import org.apache.myrmidon.api.TaskContext; -import org.apache.tools.ant.*; -import org.apache.tools.ant.Project; - -public class Ant1Project - extends Project - implements Loggable, Contextualizable -{ - private Logger m_logger; - - ///Variable to hold context for use by sub-classes - private TaskContext m_context; - - public void setLogger( final Logger logger ) - { - m_logger = logger; - } - - protected final Logger getLogger() - { - return m_logger; - } - - /** - * Retrieve context from container. - * - * @param context the context - */ - public void contextualize( final Context context ) - { - m_context = (TaskContext)context; - } - - protected final TaskContext getContext() - { - return m_context; - } - - /** - * Initialise the project. - */ - public void init() - throws BuildException - { - setJavaVersionProperty(); - } - - public void setProperty( final String name, final String value ) - { - try { getContext().setProperty( name, value ); } - catch( final Exception e ) - { - getLogger().warn( "Failed to set property " + name + " to " + value, e ); - } - } - - public void setUserProperty( final String name, final String value ) - { - setProperty( name, value ); - } - - public String getProperty( final String name ) - { - return "" + getContext().getProperty( name ); - } - - public String getUserProperty( final String name ) - { - return getProperty( name ); - } - - public String getName() - { - return "Ant1 Project"; - } - - public Task createTask( final String taskType ) - throws BuildException - { - throw new UnsupportedOperationException(); - } - - public Object createDataType( final String typeName ) - throws BuildException - { - throw new UnsupportedOperationException(); - } - - public File resolveFile( final String fileName ) - { - try { return getContext().resolveFile( fileName ); } - catch( final Exception e ) - { - return null; - } - } - - protected void fireBuildStarted() {} - protected void fireBuildFinished(Throwable exception) {} - protected void fireTargetStarted(Target target) {} - protected void fireTargetFinished(Target target, Throwable exception) {} - protected void fireTaskStarted(Task task) {} - protected void fireTaskFinished(Task task, Throwable exception) {} - - private void fireMessageLoggedEvent(BuildEvent event, String message, int priority) - { - messageLogged( message, priority ); - } - - protected void fireMessageLogged(Project project, String message, int priority) - { - messageLogged( message, priority ); - } - - protected void fireMessageLogged(Target target, String message, int priority) - { - messageLogged( message, priority ); - } - - protected void fireMessageLogged(Task task, String message, int priority) - { - messageLogged( message, priority ); - } - - private void messageLogged( String message, int priority ) - { - switch( priority ) - { - case MSG_ERR: getLogger().error( message ); break; - case MSG_WARN: getLogger().warn( message ); break; - case MSG_INFO: getLogger().info( message ); break; - case MSG_VERBOSE: getLogger().debug( message ); break; - case MSG_DEBUG: getLogger().debug( message ); break; - - default: - getLogger().debug( message ); - } - } -} diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/Ant1TypeFactory.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/Ant1TypeFactory.java deleted file mode 100644 index 56ea15a93..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/Ant1TypeFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.myrmidon.framework.ant1; - -import java.net.URL; -import org.apache.myrmidon.components.type.DefaultTypeFactory; -import org.apache.myrmidon.components.type.TypeException; -import org.apache.tools.ant.Task; - -/** - * Factory used to create adaptors for Ant1 tasks. - * - * @author Peter Donald - */ -public class Ant1TypeFactory - extends DefaultTypeFactory -{ - public Ant1TypeFactory( final URL url ) - { - super( url ); - } - - public Ant1TypeFactory( final URL[] urls ) - { - super( urls ); - } - - public Ant1TypeFactory( final URL[] urls, final ClassLoader parent ) - { - super( urls, parent ); - } - - public Ant1TypeFactory( final ClassLoader classLoader ) - { - super( classLoader ); - } - - public Object create( final String name ) - throws TypeException - { - final Object object = super.create( name ); - - if( !(object instanceof Task) ) - { - throw new TypeException( "Expected an Ant1 task but received an " + - "object of type : " + object.getClass().getName() ); - } - - return new TaskAdapter( (Task)object ); - } -} - diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/TaskAdapter.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/TaskAdapter.java deleted file mode 100644 index 09d06354c..000000000 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/ant1/TaskAdapter.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.myrmidon.framework.ant1; - -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.myrmidon.api.DataType; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.components.type.TypeException; -import org.apache.myrmidon.components.type.TypeFactory; -import org.apache.myrmidon.components.type.TypeManager; -import org.apache.myrmidon.framework.AbstractContainerTask; -import org.apache.tools.ant.Task; - -/** - * Adapter of Ant1 tasks to ant2. - * - * @author Peter Donald - */ -public class TaskAdapter - extends AbstractContainerTask - implements Configurable -{ - private Task m_ant1Task; - private Ant1Project m_project = new Ant1Project(); - - public TaskAdapter( final Task ant1Task ) - { - m_ant1Task = ant1Task; - } - - protected final Task getTask() - { - return m_ant1Task; - } - - protected final Ant1Project getProject() - { - return m_project; - } - - public void configure( final Configuration configuration ) - throws ConfigurationException - { - getTask().setTaskName( configuration.getName() ); - - //do configuration - configure( getTask(), configuration ); - } - - public void execute() - throws TaskException - { - try - { - getProject().setLogger( getLogger() ); - getProject().contextualize( getContext() ); - getProject().init(); - - getTask().setProject( getProject() ); - getTask().init(); - getTask().execute(); - } - catch( final Exception e ) - { - throw new TaskException( e.getMessage(), e ); - } - } -}