git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271770 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -383,7 +383,7 @@ public class JspC extends MatchingTask | |||||
| if( compileList.size() > 0 ) | if( compileList.size() > 0 ) | ||||
| { | { | ||||
| CompilerAdapter adapter = | CompilerAdapter adapter = | ||||
| CompilerAdapterFactory.getCompiler( compiler.toString(), this ); | |||||
| CompilerAdapterFactory.getCompiler( compiler.toString(), getContext() ); | |||||
| getLogger().info( "Compiling " + compileList.size() + | getLogger().info( "Compiling " + compileList.size() + | ||||
| " source file" | " source file" | ||||
| + ( compileList.size() == 1 ? "" : "s" ) | + ( compileList.size() == 1 ? "" : "s" ) | ||||
| @@ -8,6 +8,7 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | ||||
| /** | /** | ||||
| @@ -23,9 +24,9 @@ import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | |||||
| * jayglanville@home.com</a> | * jayglanville@home.com</a> | ||||
| * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a> | * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a> | ||||
| */ | */ | ||||
| public interface CompilerAdapter | public interface CompilerAdapter | ||||
| { | { | ||||
| void setTaskContext( TaskContext context ); | |||||
| /** | /** | ||||
| * Sets the compiler attributes, which are stored in the Jspc task. | * Sets the compiler attributes, which are stored in the Jspc task. | ||||
| @@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | |||||
| import org.apache.myrmidon.api.AbstractTask; | import org.apache.myrmidon.api.AbstractTask; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| /** | /** | ||||
| * Creates the necessary compiler adapter, given basic criteria. | * Creates the necessary compiler adapter, given basic criteria. | ||||
| @@ -18,7 +19,6 @@ import org.apache.myrmidon.api.TaskException; | |||||
| */ | */ | ||||
| public class CompilerAdapterFactory | public class CompilerAdapterFactory | ||||
| { | { | ||||
| /** | /** | ||||
| * This is a singlton -- can't create instances!! | * This is a singlton -- can't create instances!! | ||||
| */ | */ | ||||
| @@ -39,12 +39,19 @@ 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, AbstractTask task ) | |||||
| public static CompilerAdapter getCompiler( String compilerType, TaskContext context ) | |||||
| throws TaskException | |||||
| { | |||||
| final CompilerAdapter adapter = createAdapter( compilerType ); | |||||
| adapter.setTaskContext( context ); | |||||
| return adapter; | |||||
| } | |||||
| private static CompilerAdapter createAdapter( String compilerType ) | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| /* | /* | ||||
| @@ -10,7 +10,7 @@ package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import org.apache.avalon.excalibur.util.StringUtil; | import org.apache.avalon.excalibur.util.StringUtil; | ||||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -21,10 +21,20 @@ import org.apache.tools.ant.types.Commandline; | |||||
| * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a> | * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a> | ||||
| */ | */ | ||||
| public abstract class DefaultCompilerAdapter | public abstract class DefaultCompilerAdapter | ||||
| extends AbstractLogEnabled | |||||
| implements CompilerAdapter | implements CompilerAdapter | ||||
| { | { | ||||
| private JspC m_attributes; | private JspC m_attributes; | ||||
| private TaskContext m_taskContext; | |||||
| public void setTaskContext( final TaskContext context ) | |||||
| { | |||||
| m_taskContext = context; | |||||
| } | |||||
| protected final TaskContext getTaskContext() | |||||
| { | |||||
| return m_taskContext; | |||||
| } | |||||
| public void setJspc( final JspC attributes ) | public void setJspc( final JspC attributes ) | ||||
| { | { | ||||
| @@ -51,7 +61,7 @@ public abstract class DefaultCompilerAdapter | |||||
| ArrayList compileList, | ArrayList compileList, | ||||
| Commandline cmd ) | Commandline cmd ) | ||||
| { | { | ||||
| getLogger().debug( "Compilation args: " + cmd.toString() ); | |||||
| getTaskContext().debug( "Compilation args: " + cmd.toString() ); | |||||
| StringBuffer niceSourceList = new StringBuffer( "File" ); | StringBuffer niceSourceList = new StringBuffer( "File" ); | ||||
| if( compileList.size() != 1 ) | if( compileList.size() != 1 ) | ||||
| @@ -70,7 +80,7 @@ public abstract class DefaultCompilerAdapter | |||||
| niceSourceList.append( " " + arg + StringUtil.LINE_SEPARATOR ); | niceSourceList.append( " " + arg + StringUtil.LINE_SEPARATOR ); | ||||
| } | } | ||||
| getLogger().debug( niceSourceList.toString() ); | |||||
| getTaskContext().debug( niceSourceList.toString() ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -8,6 +8,7 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.ant.taskdefs.Java; | import org.apache.tools.ant.taskdefs.Java; | ||||
| import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | ||||
| import org.apache.tools.ant.types.Argument; | import org.apache.tools.ant.types.Argument; | ||||
| @@ -28,7 +29,7 @@ public class JasperC | |||||
| public boolean execute() | public boolean execute() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| getLogger().debug( "Using jasper compiler" ); | |||||
| getTaskContext().debug( "Using jasper compiler" ); | |||||
| Commandline cmd = setupJasperCommand(); | Commandline cmd = setupJasperCommand(); | ||||
| try | try | ||||
| @@ -383,7 +383,7 @@ public class JspC extends MatchingTask | |||||
| if( compileList.size() > 0 ) | if( compileList.size() > 0 ) | ||||
| { | { | ||||
| CompilerAdapter adapter = | CompilerAdapter adapter = | ||||
| CompilerAdapterFactory.getCompiler( compiler.toString(), this ); | |||||
| CompilerAdapterFactory.getCompiler( compiler.toString(), getContext() ); | |||||
| getLogger().info( "Compiling " + compileList.size() + | getLogger().info( "Compiling " + compileList.size() + | ||||
| " source file" | " source file" | ||||
| + ( compileList.size() == 1 ? "" : "s" ) | + ( compileList.size() == 1 ? "" : "s" ) | ||||
| @@ -8,6 +8,7 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | ||||
| /** | /** | ||||
| @@ -23,9 +24,9 @@ import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | |||||
| * jayglanville@home.com</a> | * jayglanville@home.com</a> | ||||
| * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a> | * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a> | ||||
| */ | */ | ||||
| public interface CompilerAdapter | public interface CompilerAdapter | ||||
| { | { | ||||
| void setTaskContext( TaskContext context ); | |||||
| /** | /** | ||||
| * Sets the compiler attributes, which are stored in the Jspc task. | * Sets the compiler attributes, which are stored in the Jspc task. | ||||
| @@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | |||||
| import org.apache.myrmidon.api.AbstractTask; | import org.apache.myrmidon.api.AbstractTask; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| /** | /** | ||||
| * Creates the necessary compiler adapter, given basic criteria. | * Creates the necessary compiler adapter, given basic criteria. | ||||
| @@ -18,7 +19,6 @@ import org.apache.myrmidon.api.TaskException; | |||||
| */ | */ | ||||
| public class CompilerAdapterFactory | public class CompilerAdapterFactory | ||||
| { | { | ||||
| /** | /** | ||||
| * This is a singlton -- can't create instances!! | * This is a singlton -- can't create instances!! | ||||
| */ | */ | ||||
| @@ -39,12 +39,19 @@ 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, AbstractTask task ) | |||||
| public static CompilerAdapter getCompiler( String compilerType, TaskContext context ) | |||||
| throws TaskException | |||||
| { | |||||
| final CompilerAdapter adapter = createAdapter( compilerType ); | |||||
| adapter.setTaskContext( context ); | |||||
| return adapter; | |||||
| } | |||||
| private static CompilerAdapter createAdapter( String compilerType ) | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| /* | /* | ||||
| @@ -10,7 +10,7 @@ package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import org.apache.avalon.excalibur.util.StringUtil; | import org.apache.avalon.excalibur.util.StringUtil; | ||||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -21,10 +21,20 @@ import org.apache.tools.ant.types.Commandline; | |||||
| * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a> | * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a> | ||||
| */ | */ | ||||
| public abstract class DefaultCompilerAdapter | public abstract class DefaultCompilerAdapter | ||||
| extends AbstractLogEnabled | |||||
| implements CompilerAdapter | implements CompilerAdapter | ||||
| { | { | ||||
| private JspC m_attributes; | private JspC m_attributes; | ||||
| private TaskContext m_taskContext; | |||||
| public void setTaskContext( final TaskContext context ) | |||||
| { | |||||
| m_taskContext = context; | |||||
| } | |||||
| protected final TaskContext getTaskContext() | |||||
| { | |||||
| return m_taskContext; | |||||
| } | |||||
| public void setJspc( final JspC attributes ) | public void setJspc( final JspC attributes ) | ||||
| { | { | ||||
| @@ -51,7 +61,7 @@ public abstract class DefaultCompilerAdapter | |||||
| ArrayList compileList, | ArrayList compileList, | ||||
| Commandline cmd ) | Commandline cmd ) | ||||
| { | { | ||||
| getLogger().debug( "Compilation args: " + cmd.toString() ); | |||||
| getTaskContext().debug( "Compilation args: " + cmd.toString() ); | |||||
| StringBuffer niceSourceList = new StringBuffer( "File" ); | StringBuffer niceSourceList = new StringBuffer( "File" ); | ||||
| if( compileList.size() != 1 ) | if( compileList.size() != 1 ) | ||||
| @@ -70,7 +80,7 @@ public abstract class DefaultCompilerAdapter | |||||
| niceSourceList.append( " " + arg + StringUtil.LINE_SEPARATOR ); | niceSourceList.append( " " + arg + StringUtil.LINE_SEPARATOR ); | ||||
| } | } | ||||
| getLogger().debug( niceSourceList.toString() ); | |||||
| getTaskContext().debug( niceSourceList.toString() ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -8,6 +8,7 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | package org.apache.tools.ant.taskdefs.optional.jsp.compilers; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.ant.taskdefs.Java; | import org.apache.tools.ant.taskdefs.Java; | ||||
| import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | ||||
| import org.apache.tools.ant.types.Argument; | import org.apache.tools.ant.types.Argument; | ||||
| @@ -28,7 +29,7 @@ public class JasperC | |||||
| public boolean execute() | public boolean execute() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| getLogger().debug( "Using jasper compiler" ); | |||||
| getTaskContext().debug( "Using jasper compiler" ); | |||||
| Commandline cmd = setupJasperCommand(); | Commandline cmd = setupJasperCommand(); | ||||
| try | try | ||||