git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271767 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -15,6 +15,8 @@ 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; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| @@ -33,7 +35,7 @@ import org.apache.tools.ant.util.FileUtils; | |||
| * @author <a href="mailto:jayglanville@home.com">J D Glanville</a> | |||
| */ | |||
| public abstract class DefaultCompilerAdapter | |||
| extends AbstractLogEnabled | |||
| // extends AbstractLogEnabled | |||
| implements CompilerAdapter | |||
| { | |||
| protected boolean m_debug; | |||
| @@ -63,6 +65,18 @@ public abstract class DefaultCompilerAdapter | |||
| protected Path src; | |||
| protected String target; | |||
| private TaskContext m_taskContext; | |||
| public void setTaskContext( final TaskContext context ) | |||
| { | |||
| m_taskContext = context; | |||
| } | |||
| protected final TaskContext getTaskContext() | |||
| { | |||
| return m_taskContext; | |||
| } | |||
| public void setJavac( Javac attributes ) | |||
| { | |||
| m_attributes = attributes; | |||
| @@ -130,7 +144,7 @@ public abstract class DefaultCompilerAdapter | |||
| if( !m_attributes.isForkedJavac() ) | |||
| { | |||
| final String message = "Since fork is false, ignoring memoryInitialSize setting."; | |||
| getLogger().warn( message ); | |||
| getTaskContext().warn( message ); | |||
| } | |||
| else | |||
| { | |||
| @@ -143,7 +157,7 @@ public abstract class DefaultCompilerAdapter | |||
| if( !m_attributes.isForkedJavac() ) | |||
| { | |||
| final String message = "Since fork is false, ignoring memoryMaximumSize setting."; | |||
| getLogger().warn( message ); | |||
| getTaskContext().warn( message ); | |||
| } | |||
| else | |||
| { | |||
| @@ -358,12 +372,12 @@ public abstract class DefaultCompilerAdapter | |||
| commandArray = args; | |||
| } | |||
| final ExecManager execManager = (ExecManager)m_attributes.getService( ExecManager.class ); | |||
| final Execute exe = new Execute( execManager ); | |||
| exe.setWorkingDirectory( m_baseDir ); | |||
| final String[] commandline = commandArray; | |||
| exe.setCommandline( new Commandline( commandline ) ); | |||
| return exe.execute(); | |||
| final ExecManager execManager = (ExecManager)m_attributes.getService( ExecManager.class ); | |||
| final Execute exe = new Execute( execManager ); | |||
| exe.setWorkingDirectory( m_baseDir ); | |||
| final String[] commandline = commandArray; | |||
| exe.setCommandline( new Commandline( commandline ) ); | |||
| return exe.execute(); | |||
| } | |||
| finally | |||
| { | |||
| @@ -382,7 +396,7 @@ public abstract class DefaultCompilerAdapter | |||
| */ | |||
| protected void logAndAddFilesToCompile( Commandline cmd ) | |||
| { | |||
| getLogger().debug( "Compilation args: " + cmd.toString() ); | |||
| getTaskContext().debug( "Compilation args: " + cmd.toString() ); | |||
| StringBuffer niceSourceList = new StringBuffer( "File" ); | |||
| if( m_compileList.length != 1 ) | |||
| @@ -400,7 +414,7 @@ public abstract class DefaultCompilerAdapter | |||
| niceSourceList.append( " " + arg + StringUtil.LINE_SEPARATOR ); | |||
| } | |||
| getLogger().debug( niceSourceList.toString() ); | |||
| getTaskContext().debug( niceSourceList.toString() ); | |||
| } | |||
| /** | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -32,7 +33,7 @@ public class Gcj extends DefaultCompilerAdapter | |||
| throws TaskException | |||
| { | |||
| Commandline cmd; | |||
| getLogger().debug( "Using gcj compiler" ); | |||
| getTaskContext().debug( "Using gcj compiler" ); | |||
| cmd = setupGCJCommand(); | |||
| int firstFileName = cmd.size(); | |||
| @@ -11,6 +11,7 @@ import java.io.OutputStream; | |||
| import java.lang.reflect.Constructor; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| /** | |||
| @@ -29,7 +30,7 @@ public class Javac12 extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using classic compiler" ); | |||
| getTaskContext().debug( "Using classic compiler" ); | |||
| Commandline cmd = setupJavacCommand( true ); | |||
| try | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs.compilers; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| /** | |||
| @@ -32,7 +33,7 @@ public class Javac13 extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using modern compiler" ); | |||
| getTaskContext().debug( "Using modern compiler" ); | |||
| Commandline cmd = setupModernJavacCommand(); | |||
| // Use reflection to be able to build on all JDKs >= 1.1: | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| /** | |||
| @@ -27,7 +28,7 @@ public class JavacExternal extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using external javac compiler" ); | |||
| getTaskContext().debug( "Using external javac compiler" ); | |||
| Commandline cmd = new Commandline(); | |||
| cmd.setExecutable( getJavac().getJavacExecutable() ); | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -40,7 +41,7 @@ public class Jikes | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using jikes compiler" ); | |||
| getTaskContext().debug( "Using jikes compiler" ); | |||
| Path classpath = new Path(); | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -28,7 +29,7 @@ public class Jvc extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using jvc compiler" ); | |||
| getTaskContext().debug( "Using jvc compiler" ); | |||
| Path classpath = new Path(); | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs.compilers; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -25,7 +26,7 @@ public class Kjc extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using kjc compiler" ); | |||
| getTaskContext().debug( "Using kjc compiler" ); | |||
| Commandline cmd = setupKjcCommand(); | |||
| try | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| /** | |||
| @@ -29,7 +30,7 @@ public class Sj extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using symantec java compiler" ); | |||
| getTaskContext().debug( "Using symantec java compiler" ); | |||
| Commandline cmd = setupJavacCommand(); | |||
| cmd.setExecutable( "sj" ); | |||
| @@ -15,6 +15,8 @@ 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; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| @@ -33,7 +35,7 @@ import org.apache.tools.ant.util.FileUtils; | |||
| * @author <a href="mailto:jayglanville@home.com">J D Glanville</a> | |||
| */ | |||
| public abstract class DefaultCompilerAdapter | |||
| extends AbstractLogEnabled | |||
| // extends AbstractLogEnabled | |||
| implements CompilerAdapter | |||
| { | |||
| protected boolean m_debug; | |||
| @@ -63,6 +65,18 @@ public abstract class DefaultCompilerAdapter | |||
| protected Path src; | |||
| protected String target; | |||
| private TaskContext m_taskContext; | |||
| public void setTaskContext( final TaskContext context ) | |||
| { | |||
| m_taskContext = context; | |||
| } | |||
| protected final TaskContext getTaskContext() | |||
| { | |||
| return m_taskContext; | |||
| } | |||
| public void setJavac( Javac attributes ) | |||
| { | |||
| m_attributes = attributes; | |||
| @@ -130,7 +144,7 @@ public abstract class DefaultCompilerAdapter | |||
| if( !m_attributes.isForkedJavac() ) | |||
| { | |||
| final String message = "Since fork is false, ignoring memoryInitialSize setting."; | |||
| getLogger().warn( message ); | |||
| getTaskContext().warn( message ); | |||
| } | |||
| else | |||
| { | |||
| @@ -143,7 +157,7 @@ public abstract class DefaultCompilerAdapter | |||
| if( !m_attributes.isForkedJavac() ) | |||
| { | |||
| final String message = "Since fork is false, ignoring memoryMaximumSize setting."; | |||
| getLogger().warn( message ); | |||
| getTaskContext().warn( message ); | |||
| } | |||
| else | |||
| { | |||
| @@ -358,12 +372,12 @@ public abstract class DefaultCompilerAdapter | |||
| commandArray = args; | |||
| } | |||
| final ExecManager execManager = (ExecManager)m_attributes.getService( ExecManager.class ); | |||
| final Execute exe = new Execute( execManager ); | |||
| exe.setWorkingDirectory( m_baseDir ); | |||
| final String[] commandline = commandArray; | |||
| exe.setCommandline( new Commandline( commandline ) ); | |||
| return exe.execute(); | |||
| final ExecManager execManager = (ExecManager)m_attributes.getService( ExecManager.class ); | |||
| final Execute exe = new Execute( execManager ); | |||
| exe.setWorkingDirectory( m_baseDir ); | |||
| final String[] commandline = commandArray; | |||
| exe.setCommandline( new Commandline( commandline ) ); | |||
| return exe.execute(); | |||
| } | |||
| finally | |||
| { | |||
| @@ -382,7 +396,7 @@ public abstract class DefaultCompilerAdapter | |||
| */ | |||
| protected void logAndAddFilesToCompile( Commandline cmd ) | |||
| { | |||
| getLogger().debug( "Compilation args: " + cmd.toString() ); | |||
| getTaskContext().debug( "Compilation args: " + cmd.toString() ); | |||
| StringBuffer niceSourceList = new StringBuffer( "File" ); | |||
| if( m_compileList.length != 1 ) | |||
| @@ -400,7 +414,7 @@ public abstract class DefaultCompilerAdapter | |||
| niceSourceList.append( " " + arg + StringUtil.LINE_SEPARATOR ); | |||
| } | |||
| getLogger().debug( niceSourceList.toString() ); | |||
| getTaskContext().debug( niceSourceList.toString() ); | |||
| } | |||
| /** | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -32,7 +33,7 @@ public class Gcj extends DefaultCompilerAdapter | |||
| throws TaskException | |||
| { | |||
| Commandline cmd; | |||
| getLogger().debug( "Using gcj compiler" ); | |||
| getTaskContext().debug( "Using gcj compiler" ); | |||
| cmd = setupGCJCommand(); | |||
| int firstFileName = cmd.size(); | |||
| @@ -11,6 +11,7 @@ import java.io.OutputStream; | |||
| import java.lang.reflect.Constructor; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| /** | |||
| @@ -29,7 +30,7 @@ public class Javac12 extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using classic compiler" ); | |||
| getTaskContext().debug( "Using classic compiler" ); | |||
| Commandline cmd = setupJavacCommand( true ); | |||
| try | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs.compilers; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| /** | |||
| @@ -32,7 +33,7 @@ public class Javac13 extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using modern compiler" ); | |||
| getTaskContext().debug( "Using modern compiler" ); | |||
| Commandline cmd = setupModernJavacCommand(); | |||
| // Use reflection to be able to build on all JDKs >= 1.1: | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| /** | |||
| @@ -27,7 +28,7 @@ public class JavacExternal extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using external javac compiler" ); | |||
| getTaskContext().debug( "Using external javac compiler" ); | |||
| Commandline cmd = new Commandline(); | |||
| cmd.setExecutable( getJavac().getJavacExecutable() ); | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -40,7 +41,7 @@ public class Jikes | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using jikes compiler" ); | |||
| getTaskContext().debug( "Using jikes compiler" ); | |||
| Path classpath = new Path(); | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -28,7 +29,7 @@ public class Jvc extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using jvc compiler" ); | |||
| getTaskContext().debug( "Using jvc compiler" ); | |||
| Path classpath = new Path(); | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs.compilers; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -25,7 +26,7 @@ public class Kjc extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using kjc compiler" ); | |||
| getTaskContext().debug( "Using kjc compiler" ); | |||
| Commandline cmd = setupKjcCommand(); | |||
| try | |||
| @@ -8,6 +8,7 @@ | |||
| package org.apache.tools.ant.taskdefs.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| /** | |||
| @@ -29,7 +30,7 @@ public class Sj extends DefaultCompilerAdapter | |||
| public boolean execute() | |||
| throws TaskException | |||
| { | |||
| getLogger().debug( "Using symantec java compiler" ); | |||
| getTaskContext().debug( "Using symantec java compiler" ); | |||
| Commandline cmd = setupJavacCommand(); | |||
| cmd.setExecutable( "sj" ); | |||