From 64d951bcfa8ee32137eaa6ee2d5f2fce98e6b64d Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Wed, 6 Mar 2002 10:37:41 +0000 Subject: [PATCH] Convert Javac to using TaskContext to log git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271769 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/compilers/CompilerAdapter.java | 2 ++ .../compilers/CompilerAdapterFactory.java | 16 +++++++++++----- .../compilers/DefaultCompilerAdapter.java | 3 --- .../tools/ant/taskdefs/compilers/Javac.java | 11 ++++------- .../ant/taskdefs/compilers/CompilerAdapter.java | 2 ++ .../compilers/CompilerAdapterFactory.java | 16 +++++++++++----- .../compilers/DefaultCompilerAdapter.java | 3 --- .../tools/ant/taskdefs/compilers/Javac.java | 11 ++++------- 8 files changed, 34 insertions(+), 30 deletions(-) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java index aa1a6b1a8..6ad4e8f55 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java @@ -8,6 +8,7 @@ package org.apache.tools.ant.taskdefs.compilers; import org.apache.myrmidon.api.TaskException; +import org.apache.myrmidon.api.TaskContext; /** * The interface that all compiler adapters must adher to.

@@ -24,6 +25,7 @@ import org.apache.myrmidon.api.TaskException; public interface CompilerAdapter { + void setTaskContext( TaskContext context ); /** * Sets the compiler attributes, which are stored in the Javac task. diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java index c17ca22a3..792ad498e 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java @@ -7,7 +7,7 @@ */ package org.apache.tools.ant.taskdefs.compilers; -import org.apache.avalon.framework.logger.Logger; +import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.api.TaskException; /** @@ -45,13 +45,20 @@ public class CompilerAdapterFactory * * @param compilerType either the name of the desired compiler, or the full * classname of the compiler's adapter. - * @param task a task to log through. * @return The Compiler value * @throws TaskException if the compiler type could not be resolved into a * compiler adapter. */ - public static CompilerAdapter getCompiler( String compilerType, Logger logger ) + public static CompilerAdapter getCompiler( String compilerType, + TaskContext context ) throws TaskException + { + final CompilerAdapter adaptor = createAdaptor( compilerType, context ); + adaptor.setTaskContext( context ); + return adaptor; + } + + private static CompilerAdapter createAdaptor( String compilerType, TaskContext context ) throws TaskException { /* * If I've done things right, this should be the extent of the @@ -84,7 +91,7 @@ public class CompilerAdapterFactory { final String message = "Modern compiler is not available - using " + "classic compiler"; - logger.warn( message ); + context.warn( message ); return new Javac12(); } return new Javac13(); @@ -144,5 +151,4 @@ public class CompilerAdapterFactory + "exception.", t ); } } - } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index b6e858f9a..3f19cc5c6 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -14,8 +14,6 @@ import java.io.PrintWriter; import org.apache.aut.nativelib.ExecManager; import org.apache.avalon.excalibur.io.IOUtil; import org.apache.avalon.excalibur.util.StringUtil; -import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.avalon.framework.logger.Logger; import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.framework.Execute; @@ -35,7 +33,6 @@ import org.apache.tools.ant.util.FileUtils; * @author J D Glanville */ public abstract class DefaultCompilerAdapter -// extends AbstractLogEnabled implements CompilerAdapter { protected boolean m_debug; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac.java index 9a6b2eba5..ba63a5d86 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac.java @@ -575,13 +575,10 @@ public class Javac /** * Adds an implementation specific command line argument. - * - * @return Description of the Returned Value */ - public org.apache.tools.ant.taskdefs.compilers.ImplementationSpecificArgument createCompilerArg() + public ImplementationSpecificArgument createCompilerArg() { - org.apache.tools.ant.taskdefs.compilers.ImplementationSpecificArgument arg = - new org.apache.tools.ant.taskdefs.compilers.ImplementationSpecificArgument( this ); + final ImplementationSpecificArgument arg = new ImplementationSpecificArgument( this ); m_implementationSpecificArgs.add( arg ); return arg; } @@ -637,8 +634,8 @@ public class Javac if( m_compileList.length > 0 ) { - CompilerAdapter adapter = CompilerAdapterFactory.getCompiler( - compiler, getLogger() ); + CompilerAdapter adapter = + CompilerAdapterFactory.getCompiler( compiler, getContext() ); final String message = "Compiling " + m_compileList.length + " source file" + ( m_compileList.length == 1 ? "" : "s" ) + ( m_destDir != null ? " to " + m_destDir : "" ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java index aa1a6b1a8..6ad4e8f55 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java @@ -8,6 +8,7 @@ package org.apache.tools.ant.taskdefs.compilers; import org.apache.myrmidon.api.TaskException; +import org.apache.myrmidon.api.TaskContext; /** * The interface that all compiler adapters must adher to.

@@ -24,6 +25,7 @@ import org.apache.myrmidon.api.TaskException; public interface CompilerAdapter { + void setTaskContext( TaskContext context ); /** * Sets the compiler attributes, which are stored in the Javac task. diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java index c17ca22a3..792ad498e 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java @@ -7,7 +7,7 @@ */ package org.apache.tools.ant.taskdefs.compilers; -import org.apache.avalon.framework.logger.Logger; +import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.api.TaskException; /** @@ -45,13 +45,20 @@ public class CompilerAdapterFactory * * @param compilerType either the name of the desired compiler, or the full * classname of the compiler's adapter. - * @param task a task to log through. * @return The Compiler value * @throws TaskException if the compiler type could not be resolved into a * compiler adapter. */ - public static CompilerAdapter getCompiler( String compilerType, Logger logger ) + public static CompilerAdapter getCompiler( String compilerType, + TaskContext context ) throws TaskException + { + final CompilerAdapter adaptor = createAdaptor( compilerType, context ); + adaptor.setTaskContext( context ); + return adaptor; + } + + private static CompilerAdapter createAdaptor( String compilerType, TaskContext context ) throws TaskException { /* * If I've done things right, this should be the extent of the @@ -84,7 +91,7 @@ public class CompilerAdapterFactory { final String message = "Modern compiler is not available - using " + "classic compiler"; - logger.warn( message ); + context.warn( message ); return new Javac12(); } return new Javac13(); @@ -144,5 +151,4 @@ public class CompilerAdapterFactory + "exception.", t ); } } - } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index b6e858f9a..3f19cc5c6 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -14,8 +14,6 @@ import java.io.PrintWriter; import org.apache.aut.nativelib.ExecManager; import org.apache.avalon.excalibur.io.IOUtil; import org.apache.avalon.excalibur.util.StringUtil; -import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.avalon.framework.logger.Logger; import org.apache.myrmidon.api.TaskContext; import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.framework.Execute; @@ -35,7 +33,6 @@ import org.apache.tools.ant.util.FileUtils; * @author J D Glanville */ public abstract class DefaultCompilerAdapter -// extends AbstractLogEnabled implements CompilerAdapter { protected boolean m_debug; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac.java index 9a6b2eba5..ba63a5d86 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac.java @@ -575,13 +575,10 @@ public class Javac /** * Adds an implementation specific command line argument. - * - * @return Description of the Returned Value */ - public org.apache.tools.ant.taskdefs.compilers.ImplementationSpecificArgument createCompilerArg() + public ImplementationSpecificArgument createCompilerArg() { - org.apache.tools.ant.taskdefs.compilers.ImplementationSpecificArgument arg = - new org.apache.tools.ant.taskdefs.compilers.ImplementationSpecificArgument( this ); + final ImplementationSpecificArgument arg = new ImplementationSpecificArgument( this ); m_implementationSpecificArgs.add( arg ); return arg; } @@ -637,8 +634,8 @@ public class Javac if( m_compileList.length > 0 ) { - CompilerAdapter adapter = CompilerAdapterFactory.getCompiler( - compiler, getLogger() ); + CompilerAdapter adapter = + CompilerAdapterFactory.getCompiler( compiler, getContext() ); final String message = "Compiling " + m_compileList.length + " source file" + ( m_compileList.length == 1 ? "" : "s" ) + ( m_destDir != null ? " to " + m_destDir : "" );