Browse Source

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
master
Peter Donald 23 years ago
parent
commit
64d951bcfa
8 changed files with 34 additions and 30 deletions
  1. +2
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java
  2. +11
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
  3. +0
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  4. +4
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac.java
  5. +2
    -0
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java
  6. +11
    -5
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
  7. +0
    -3
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  8. +4
    -7
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac.java

+ 2
- 0
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java View File

@@ -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. <p>
@@ -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.


+ 11
- 5
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java View File

@@ -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 );
}
}

}

+ 0
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -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 <a href="mailto:jayglanville@home.com">J D Glanville</a>
*/
public abstract class DefaultCompilerAdapter
// extends AbstractLogEnabled
implements CompilerAdapter
{
protected boolean m_debug;


+ 4
- 7
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac.java View File

@@ -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 : "" );


+ 2
- 0
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java View File

@@ -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. <p>
@@ -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.


+ 11
- 5
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java View File

@@ -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 );
}
}

}

+ 0
- 3
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -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 <a href="mailto:jayglanville@home.com">J D Glanville</a>
*/
public abstract class DefaultCompilerAdapter
// extends AbstractLogEnabled
implements CompilerAdapter
{
protected boolean m_debug;


+ 4
- 7
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac.java View File

@@ -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 : "" );


Loading…
Cancel
Save