git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271769 13f79535-47bb-0310-9956-ffa450edef68master
@@ -8,6 +8,7 @@ | |||||
package org.apache.tools.ant.taskdefs.compilers; | package org.apache.tools.ant.taskdefs.compilers; | ||||
import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
import org.apache.myrmidon.api.TaskContext; | |||||
/** | /** | ||||
* The interface that all compiler adapters must adher to. <p> | * The interface that all compiler adapters must adher to. <p> | ||||
@@ -24,6 +25,7 @@ import org.apache.myrmidon.api.TaskException; | |||||
public interface CompilerAdapter | public interface CompilerAdapter | ||||
{ | { | ||||
void setTaskContext( TaskContext context ); | |||||
/** | /** | ||||
* Sets the compiler attributes, which are stored in the Javac task. | * Sets the compiler attributes, which are stored in the Javac task. | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.compilers; | 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; | 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 | * @param compilerType either the name of the desired compiler, or the full | ||||
* classname of the compiler's adapter. | * classname of the compiler's adapter. | ||||
* @param task a task to log through. | |||||
* @return The Compiler value | * @return The Compiler value | ||||
* @throws TaskException if the compiler type could not be resolved into a | * @throws TaskException if the compiler type could not be resolved into a | ||||
* compiler adapter. | * compiler adapter. | ||||
*/ | */ | ||||
public static CompilerAdapter getCompiler( String compilerType, Logger logger ) | |||||
public static CompilerAdapter getCompiler( String compilerType, | |||||
TaskContext context ) | |||||
throws TaskException | 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 | * 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 " | final String message = "Modern compiler is not available - using " | ||||
+ "classic compiler"; | + "classic compiler"; | ||||
logger.warn( message ); | |||||
context.warn( message ); | |||||
return new Javac12(); | return new Javac12(); | ||||
} | } | ||||
return new Javac13(); | return new Javac13(); | ||||
@@ -144,5 +151,4 @@ public class CompilerAdapterFactory | |||||
+ "exception.", t ); | + "exception.", t ); | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -14,8 +14,6 @@ import java.io.PrintWriter; | |||||
import org.apache.aut.nativelib.ExecManager; | import org.apache.aut.nativelib.ExecManager; | ||||
import org.apache.avalon.excalibur.io.IOUtil; | import org.apache.avalon.excalibur.io.IOUtil; | ||||
import org.apache.avalon.excalibur.util.StringUtil; | 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.TaskContext; | ||||
import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
import org.apache.myrmidon.framework.Execute; | import org.apache.myrmidon.framework.Execute; | ||||
@@ -35,7 +33,6 @@ import org.apache.tools.ant.util.FileUtils; | |||||
* @author <a href="mailto:jayglanville@home.com">J D Glanville</a> | * @author <a href="mailto:jayglanville@home.com">J D Glanville</a> | ||||
*/ | */ | ||||
public abstract class DefaultCompilerAdapter | public abstract class DefaultCompilerAdapter | ||||
// extends AbstractLogEnabled | |||||
implements CompilerAdapter | implements CompilerAdapter | ||||
{ | { | ||||
protected boolean m_debug; | protected boolean m_debug; | ||||
@@ -575,13 +575,10 @@ public class Javac | |||||
/** | /** | ||||
* Adds an implementation specific command line argument. | * 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 ); | m_implementationSpecificArgs.add( arg ); | ||||
return arg; | return arg; | ||||
} | } | ||||
@@ -637,8 +634,8 @@ public class Javac | |||||
if( m_compileList.length > 0 ) | 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" + | final String message = "Compiling " + m_compileList.length + " source file" + | ||||
( m_compileList.length == 1 ? "" : "s" ) + | ( m_compileList.length == 1 ? "" : "s" ) + | ||||
( m_destDir != null ? " to " + m_destDir : "" ); | ( m_destDir != null ? " to " + m_destDir : "" ); | ||||
@@ -8,6 +8,7 @@ | |||||
package org.apache.tools.ant.taskdefs.compilers; | package org.apache.tools.ant.taskdefs.compilers; | ||||
import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
import org.apache.myrmidon.api.TaskContext; | |||||
/** | /** | ||||
* The interface that all compiler adapters must adher to. <p> | * The interface that all compiler adapters must adher to. <p> | ||||
@@ -24,6 +25,7 @@ import org.apache.myrmidon.api.TaskException; | |||||
public interface CompilerAdapter | public interface CompilerAdapter | ||||
{ | { | ||||
void setTaskContext( TaskContext context ); | |||||
/** | /** | ||||
* Sets the compiler attributes, which are stored in the Javac task. | * Sets the compiler attributes, which are stored in the Javac task. | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.compilers; | 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; | 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 | * @param compilerType either the name of the desired compiler, or the full | ||||
* classname of the compiler's adapter. | * classname of the compiler's adapter. | ||||
* @param task a task to log through. | |||||
* @return The Compiler value | * @return The Compiler value | ||||
* @throws TaskException if the compiler type could not be resolved into a | * @throws TaskException if the compiler type could not be resolved into a | ||||
* compiler adapter. | * compiler adapter. | ||||
*/ | */ | ||||
public static CompilerAdapter getCompiler( String compilerType, Logger logger ) | |||||
public static CompilerAdapter getCompiler( String compilerType, | |||||
TaskContext context ) | |||||
throws TaskException | 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 | * 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 " | final String message = "Modern compiler is not available - using " | ||||
+ "classic compiler"; | + "classic compiler"; | ||||
logger.warn( message ); | |||||
context.warn( message ); | |||||
return new Javac12(); | return new Javac12(); | ||||
} | } | ||||
return new Javac13(); | return new Javac13(); | ||||
@@ -144,5 +151,4 @@ public class CompilerAdapterFactory | |||||
+ "exception.", t ); | + "exception.", t ); | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -14,8 +14,6 @@ import java.io.PrintWriter; | |||||
import org.apache.aut.nativelib.ExecManager; | import org.apache.aut.nativelib.ExecManager; | ||||
import org.apache.avalon.excalibur.io.IOUtil; | import org.apache.avalon.excalibur.io.IOUtil; | ||||
import org.apache.avalon.excalibur.util.StringUtil; | 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.TaskContext; | ||||
import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
import org.apache.myrmidon.framework.Execute; | import org.apache.myrmidon.framework.Execute; | ||||
@@ -35,7 +33,6 @@ import org.apache.tools.ant.util.FileUtils; | |||||
* @author <a href="mailto:jayglanville@home.com">J D Glanville</a> | * @author <a href="mailto:jayglanville@home.com">J D Glanville</a> | ||||
*/ | */ | ||||
public abstract class DefaultCompilerAdapter | public abstract class DefaultCompilerAdapter | ||||
// extends AbstractLogEnabled | |||||
implements CompilerAdapter | implements CompilerAdapter | ||||
{ | { | ||||
protected boolean m_debug; | protected boolean m_debug; | ||||
@@ -575,13 +575,10 @@ public class Javac | |||||
/** | /** | ||||
* Adds an implementation specific command line argument. | * 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 ); | m_implementationSpecificArgs.add( arg ); | ||||
return arg; | return arg; | ||||
} | } | ||||
@@ -637,8 +634,8 @@ public class Javac | |||||
if( m_compileList.length > 0 ) | 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" + | final String message = "Compiling " + m_compileList.length + " source file" + | ||||
( m_compileList.length == 1 ? "" : "s" ) + | ( m_compileList.length == 1 ? "" : "s" ) + | ||||
( m_destDir != null ? " to " + m_destDir : "" ); | ( m_destDir != null ? " to " + m_destDir : "" ); | ||||