- Moved generic formatting to aut.nativelib.PathUtil. - Moved FileList util methods to framework.file.FileListUtil. - Moved addExtDirs() to DefaultCompilerAdaptor. - myrmidon.components.* no longer depend on todo.* * Removed all usages of Commandline.toString(), size() and getCommandline(), excluding Execute. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272268 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -11,7 +11,7 @@ import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.conditions.Condition; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * An abstract condition which checks for the availability of a particular | |||
| @@ -46,6 +46,6 @@ public abstract class AbstractAvailableCondition | |||
| */ | |||
| protected ClassLoader buildClassLoader( final TaskContext context ) throws TaskException | |||
| { | |||
| return PathUtil.createClassLoader( m_classpath, context ); | |||
| return FileListUtil.createClassLoader( m_classpath, context ); | |||
| } | |||
| } | |||
| @@ -9,8 +9,8 @@ package org.apache.antlib.java; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import java.io.File; | |||
| import java.lang.reflect.Method; | |||
| @@ -84,7 +84,7 @@ public class JavacAdaptor | |||
| classpath.add( getClassPath() ); | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( classpath, getContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getContext() ) ); | |||
| if( isDeprecation() ) | |||
| { | |||
| @@ -12,8 +12,8 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.myrmidon.framework.java.JavaRuntimeClassPath; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| /** | |||
| * An adaptor for the jikes compiler. | |||
| @@ -74,7 +74,7 @@ public class JikesAdaptor | |||
| cmd.addArgument( getDestDir() ); | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( classpath, getContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getContext() ) ); | |||
| // TODO - make this configurable | |||
| cmd.addArgument( "+E" ); | |||
| @@ -16,9 +16,9 @@ import java.util.Hashtable; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.tools.todo.types.FileSet; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.tools.todo.types.ScannerUtil; | |||
| import org.xml.sax.EntityResolver; | |||
| import org.xml.sax.InputSource; | |||
| @@ -311,7 +311,7 @@ public class XMLValidateTask | |||
| { | |||
| // load the parser class | |||
| // with JAXP, we would use a SAXParser factory | |||
| final ClassLoader classLoader = PathUtil.createClassLoader( m_classpath, getContext() ); | |||
| final ClassLoader classLoader = FileListUtil.createClassLoader( m_classpath, getContext() ); | |||
| final Class readerClass = classLoader.loadClass( m_readerClassName ); | |||
| // then check it implements XMLReader | |||
| @@ -0,0 +1,64 @@ | |||
| /* | |||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||
| * | |||
| * This software is published under the terms of the Apache Software License | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE.txt file. | |||
| */ | |||
| package org.apache.aut.nativelib; | |||
| import java.io.File; | |||
| /** | |||
| * Utility methods for dealing with native paths. | |||
| * | |||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||
| * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
| * @version $Revision$ $Date$ | |||
| */ | |||
| public class PathUtil | |||
| { | |||
| /** | |||
| * Formats a path into its native representation. | |||
| */ | |||
| public static String formatPath( final String[] path ) | |||
| { | |||
| // empty path return empty string | |||
| if( path == null || path.length == 0 ) | |||
| { | |||
| return ""; | |||
| } | |||
| // path containing one or more elements | |||
| final StringBuffer result = new StringBuffer( path[ 0 ].toString() ); | |||
| for( int i = 1; i < path.length; i++ ) | |||
| { | |||
| result.append( File.pathSeparatorChar ); | |||
| result.append( path[ i ] ); | |||
| } | |||
| return result.toString(); | |||
| } | |||
| /** | |||
| * Formats a path into its native representation. | |||
| */ | |||
| public static String formatPath( final File[] path ) | |||
| { | |||
| // empty path return empty string | |||
| if( path == null || path.length == 0 ) | |||
| { | |||
| return ""; | |||
| } | |||
| // path containing one or more elements | |||
| final StringBuffer result = new StringBuffer( path[ 0 ].toString() ); | |||
| for( int i = 1; i < path.length; i++ ) | |||
| { | |||
| result.append( File.pathSeparatorChar ); | |||
| result.append( path[ i ].getAbsolutePath() ); | |||
| } | |||
| return result.toString(); | |||
| } | |||
| } | |||
| @@ -30,7 +30,7 @@ import org.apache.myrmidon.interfaces.classloader.ClassLoaderException; | |||
| import org.apache.myrmidon.interfaces.classloader.ClassLoaderManager; | |||
| import org.apache.myrmidon.interfaces.deployer.DeploymentException; | |||
| import org.apache.myrmidon.interfaces.extensions.ExtensionManager; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.aut.nativelib.PathUtil; | |||
| /** | |||
| * A default implementation of a ClassLoader manager. | |||
| @@ -9,10 +9,10 @@ package org.apache.myrmidon.framework.file; | |||
| import org.apache.aut.converter.AbstractConverter; | |||
| import org.apache.aut.converter.ConverterException; | |||
| import org.apache.aut.nativelib.PathUtil; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.FileList; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| /** | |||
| * Converters from FileList to String. | |||
| @@ -5,70 +5,28 @@ | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE.txt file. | |||
| */ | |||
| package org.apache.tools.todo.types; | |||
| package org.apache.myrmidon.framework.file; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.net.URL; | |||
| import java.util.Locale; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileList; | |||
| import org.apache.myrmidon.interfaces.classloader.ClassLoaderManager; | |||
| import org.apache.myrmidon.interfaces.classloader.ClassLoaderException; | |||
| import org.apache.aut.nativelib.Os; | |||
| import org.apache.aut.nativelib.PathUtil; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.net.URL; | |||
| /** | |||
| * Utilities for operating on Path objects. | |||
| * Utility methods for dealing with {@link FileList} objects. | |||
| * | |||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||
| * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
| * @version $Revision$ $Date$ | |||
| */ | |||
| public class PathUtil | |||
| public final class FileListUtil | |||
| { | |||
| /** | |||
| * Formats a path into its native representation. | |||
| */ | |||
| public static String formatPath( final String[] path ) | |||
| { | |||
| // empty path return empty string | |||
| if( path.length == 0 ) | |||
| { | |||
| return ""; | |||
| } | |||
| // path containing one or more elements | |||
| final StringBuffer result = new StringBuffer( path[ 0 ].toString() ); | |||
| for( int i = 1; i < path.length; i++ ) | |||
| { | |||
| result.append( File.pathSeparatorChar ); | |||
| result.append( path[ i ] ); | |||
| } | |||
| return result.toString(); | |||
| } | |||
| /** | |||
| * Formats a path into its native representation. | |||
| */ | |||
| public static String formatPath( final File[] path ) | |||
| private FileListUtil() | |||
| { | |||
| // empty path return empty string | |||
| if( path.length == 0 ) | |||
| { | |||
| return ""; | |||
| } | |||
| // path containing one or more elements | |||
| final StringBuffer result = new StringBuffer( path[ 0 ].toString() ); | |||
| for( int i = 1; i < path.length; i++ ) | |||
| { | |||
| result.append( File.pathSeparatorChar ); | |||
| result.append( path[ i ].getAbsolutePath() ); | |||
| } | |||
| return result.toString(); | |||
| } | |||
| /** | |||
| @@ -78,7 +36,7 @@ public class PathUtil | |||
| throws TaskException | |||
| { | |||
| final String[] list = path.listFiles( context ); | |||
| return formatPath( list ); | |||
| return PathUtil.formatPath( list ); | |||
| } | |||
| /** | |||
| @@ -141,25 +99,4 @@ public class PathUtil | |||
| } | |||
| } | |||
| /** | |||
| * Adds the contents of a set of directories to a path. | |||
| */ | |||
| public static void addExtdirs( final Path toPath, | |||
| final Path extDirs, | |||
| final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| final String[] dirs = extDirs.listFiles( context ); | |||
| for( int i = 0; i < dirs.length; i++ ) | |||
| { | |||
| final File dir = new File( dirs[ i ] ); | |||
| if( dir.exists() && dir.isDirectory() ) | |||
| { | |||
| final FileSet fileSet = new FileSet(); | |||
| fileSet.setDir( dir ); | |||
| fileSet.setIncludes( "*" ); | |||
| toPath.addFileset( fileSet ); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -11,15 +11,16 @@ import java.io.File; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.aut.nativelib.Os; | |||
| import org.apache.aut.nativelib.PathUtil; | |||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||
| import org.apache.avalon.excalibur.i18n.Resources; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.EnvironmentData; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.tools.todo.types.SysProperties; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| @@ -197,7 +198,7 @@ public class ExecuteJava | |||
| final String message = REZ.getString( "executejava.jar-no-fork.error" ); | |||
| throw new TaskException( message ); | |||
| } | |||
| if( m_vmArgs.size() > 0 ) | |||
| if( m_vmArgs.getArguments().length > 0 ) | |||
| { | |||
| final String message = REZ.getString( "executejava.ignore-jvm-args.notice" ); | |||
| context.warn( message ); | |||
| @@ -234,7 +235,7 @@ public class ExecuteJava | |||
| Class target; | |||
| try | |||
| { | |||
| final ClassLoader classLoader = PathUtil.createClassLoader( m_classPath, context ); | |||
| final ClassLoader classLoader = FileListUtil.createClassLoader( m_classPath, context ); | |||
| target = classLoader.loadClass( m_className ); | |||
| } | |||
| catch( final Exception e ) | |||
| @@ -21,7 +21,7 @@ import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter; | |||
| import org.apache.tools.todo.taskdefs.javac.Javac; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.antlib.java.JavaTask; | |||
| /** | |||
| @@ -774,7 +774,7 @@ public class IContract extends MatchingTask | |||
| } | |||
| iControlProps.setProperty( "sourceRoot", srcDir.getAbsolutePath() ); | |||
| iControlProps.setProperty( "classRoot", classDir.getAbsolutePath() ); | |||
| final String classpath = PathUtil.formatPath( afterInstrumentationClasspath, getContext() ); | |||
| final String classpath = FileListUtil.formatPath( afterInstrumentationClasspath, getContext() ); | |||
| iControlProps.setProperty( "classpath", classpath ); | |||
| iControlProps.setProperty( "controlFile", controlFile.getAbsolutePath() ); | |||
| iControlProps.setProperty( "targetsFile", targets.getAbsolutePath() ); | |||
| @@ -15,8 +15,9 @@ import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * Task to generate JNI header files using javah. This task can take the | |||
| @@ -207,10 +208,12 @@ public class Javah | |||
| * &qout;niceSourceList" | |||
| */ | |||
| private void logAndAddFilesToCompile( final Commandline cmd ) | |||
| throws TaskException | |||
| { | |||
| int n = 0; | |||
| getContext().debug( "Compilation args: " + cmd.toString() ); | |||
| final String[] args = cmd.getArguments(); | |||
| getContext().debug( "Compilation args: " + FileUtils.formatCommandLine( args ) ); | |||
| int n = 0; | |||
| StringBuffer niceClassList = new StringBuffer(); | |||
| if( m_cls != null ) | |||
| { | |||
| @@ -268,7 +271,7 @@ public class Javah | |||
| if( m_classpath != null ) | |||
| { | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( m_classpath, getContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( m_classpath, getContext() ) ); | |||
| } | |||
| if( m_verbose ) | |||
| @@ -296,7 +299,7 @@ public class Javah | |||
| if( m_bootclasspath != null ) | |||
| { | |||
| cmd.addArgument( "-bootclasspath" ); | |||
| cmd.addArgument( PathUtil.formatPath( m_bootclasspath, getContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( m_bootclasspath, getContext() ) ); | |||
| } | |||
| logAndAddFilesToCompile( cmd ); | |||
| @@ -15,7 +15,7 @@ import java.util.Properties; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * Will set a Project property. Used to be a hack in ProjectHelper Will not | |||
| @@ -120,7 +120,7 @@ public class Property | |||
| getContext().debug( "Resource Loading " + name ); | |||
| try | |||
| { | |||
| final ClassLoader classLoader = PathUtil.createClassLoader( m_classpath, getContext() ); | |||
| final ClassLoader classLoader = FileListUtil.createClassLoader( m_classpath, getContext() ); | |||
| final InputStream is = classLoader.getResourceAsStream( name ); | |||
| if( is != null ) | |||
| @@ -33,10 +33,10 @@ import java.util.StringTokenizer; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.tools.todo.types.EnumeratedAttribute; | |||
| import org.apache.tools.todo.types.FileSet; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.tools.todo.types.ScannerUtil; | |||
| /** | |||
| @@ -417,7 +417,7 @@ public class SQLExec | |||
| // Load the driver using the | |||
| try | |||
| { | |||
| final ClassLoader classLoader = PathUtil.createClassLoader( classpath, getContext() ); | |||
| final ClassLoader classLoader = FileListUtil.createClassLoader( classpath, getContext() ); | |||
| final Class dc = classLoader.loadClass( driver ); | |||
| driverInstance = (Driver)dc.newInstance(); | |||
| } | |||
| @@ -18,7 +18,10 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.FileSet; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| import org.apache.aut.nativelib.PathUtil; | |||
| /** | |||
| * This is the default implementation for the CompilerAdapter interface. | |||
| @@ -114,7 +117,8 @@ public abstract class DefaultCompilerAdapter | |||
| { | |||
| Commandline cmd = new Commandline(); | |||
| setupJavacCommandlineSwitches( cmd, debugLevelCheck ); | |||
| logAndAddFilesToCompile( cmd ); | |||
| logFilesToCompile( cmd ); | |||
| addFilesToCompile( cmd ); | |||
| return cmd; | |||
| } | |||
| @@ -176,10 +180,10 @@ public abstract class DefaultCompilerAdapter | |||
| } | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( classpath, getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getTaskContext() ) ); | |||
| cmd.addArgument( "-sourcepath" ); | |||
| cmd.addArgument( PathUtil.formatPath( src, getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( src, getTaskContext() ) ); | |||
| if( target != null ) | |||
| { | |||
| @@ -197,7 +201,7 @@ public abstract class DefaultCompilerAdapter | |||
| if( m_extdirs != null ) | |||
| { | |||
| cmd.addArgument( "-extdirs" ); | |||
| cmd.addArgument( PathUtil.formatPath( m_extdirs, getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( m_extdirs, getTaskContext() ) ); | |||
| } | |||
| if( m_encoding != null ) | |||
| @@ -255,7 +259,8 @@ public abstract class DefaultCompilerAdapter | |||
| Commandline cmd = new Commandline(); | |||
| setupModernJavacCommandlineSwitches( cmd ); | |||
| logAndAddFilesToCompile( cmd ); | |||
| logFilesToCompile( cmd ); | |||
| addFilesToCompile( cmd ); | |||
| return cmd; | |||
| } | |||
| @@ -312,14 +317,14 @@ public abstract class DefaultCompilerAdapter | |||
| /** | |||
| * Do the compile with the specified arguments. | |||
| * | |||
| * @param args - arguments to pass to process on command line | |||
| * @param firstFileName - index of the first source file in args | |||
| * @return Description of the Returned Value | |||
| * @param cmd - the command line, to which the names of the files to | |||
| * compile are added. | |||
| */ | |||
| protected int executeExternalCompile( String[] args, int firstFileName ) | |||
| protected boolean executeExternalCompile( final Commandline cmd ) | |||
| throws TaskException | |||
| { | |||
| String[] commandArray = null; | |||
| logFilesToCompile( cmd ); | |||
| File tmpFile = null; | |||
| try | |||
| @@ -329,43 +334,38 @@ public abstract class DefaultCompilerAdapter | |||
| * long command lines - no, not only Windows ;-). | |||
| * | |||
| * POSIX seems to define a lower limit of 4k, so use a temporary | |||
| * file if the total length of the command line exceeds this limit. | |||
| * file. | |||
| */ | |||
| if( StringUtil.join( args, " " ).length() > 4096 ) | |||
| try | |||
| { | |||
| PrintWriter out = null; | |||
| tmpFile = File.createTempFile( "javac", "", new File( "." ) ); | |||
| final FileWriter fout = new FileWriter( tmpFile ); | |||
| try | |||
| { | |||
| tmpFile = File.createTempFile( "jikes", "", new File( "." ) ); | |||
| out = new PrintWriter( new FileWriter( tmpFile ) ); | |||
| for( int i = firstFileName; i < args.length; i++ ) | |||
| final PrintWriter out = new PrintWriter( fout ); | |||
| for( int i = 0; i < m_compileList.length; i++ ) | |||
| { | |||
| out.println( args[ i ] ); | |||
| File file = m_compileList[i ]; | |||
| out.println( file.getAbsolutePath() ); | |||
| } | |||
| out.flush(); | |||
| commandArray = new String[ firstFileName + 1 ]; | |||
| System.arraycopy( args, 0, commandArray, 0, firstFileName ); | |||
| commandArray[ firstFileName ] = "@" + tmpFile.getAbsolutePath(); | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| throw new TaskException( "Error creating temporary file", ioe ); | |||
| out.close(); | |||
| } | |||
| finally | |||
| { | |||
| IOUtil.shutdownWriter( out ); | |||
| IOUtil.shutdownWriter( fout ); | |||
| } | |||
| } | |||
| else | |||
| catch( final IOException ioe ) | |||
| { | |||
| commandArray = args; | |||
| throw new TaskException( "Error creating temporary file", ioe ); | |||
| } | |||
| cmd.addArgument( "@" + tmpFile.getAbsolutePath() ); | |||
| final Execute exe = new Execute(); | |||
| exe.setIgnoreReturnCode( true ); | |||
| final String[] commandline = commandArray; | |||
| exe.setCommandline( new Commandline( commandline ) ); | |||
| return exe.execute( getTaskContext() ); | |||
| exe.setCommandline( cmd ); | |||
| return exe.execute( getTaskContext() ) == 0; | |||
| } | |||
| finally | |||
| { | |||
| @@ -382,9 +382,11 @@ public abstract class DefaultCompilerAdapter | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| protected void logAndAddFilesToCompile( Commandline cmd ) | |||
| protected void logFilesToCompile( final Commandline cmd ) | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Compilation args: " + cmd.toString() ); | |||
| final String[] cmdline = cmd.getArguments(); | |||
| getTaskContext().debug( "Compilation args: " + FileUtils.formatCommandLine( cmdline ) ); | |||
| StringBuffer niceSourceList = new StringBuffer( "File" ); | |||
| if( m_compileList.length != 1 ) | |||
| @@ -398,13 +400,24 @@ public abstract class DefaultCompilerAdapter | |||
| for( int i = 0; i < m_compileList.length; i++ ) | |||
| { | |||
| String arg = m_compileList[ i ].getAbsolutePath(); | |||
| cmd.addArgument( arg ); | |||
| niceSourceList.append( " " + arg + StringUtil.LINE_SEPARATOR ); | |||
| } | |||
| getTaskContext().debug( niceSourceList.toString() ); | |||
| } | |||
| /** | |||
| * Adds the files to compile to a command-line | |||
| */ | |||
| protected void addFilesToCompile( final Commandline cmd ) | |||
| { | |||
| for( int i = 0; i < m_compileList.length; i++ ) | |||
| { | |||
| File file = m_compileList[i ]; | |||
| cmd.addArgument( file ); | |||
| } | |||
| } | |||
| /** | |||
| * Emulation of extdirs feature in java >= 1.2. This method adds all files | |||
| * in the given directories (but not in sub-directories!) to the classpath, | |||
| @@ -426,7 +439,29 @@ public abstract class DefaultCompilerAdapter | |||
| } | |||
| } | |||
| PathUtil.addExtdirs( path, m_extdirs, getTaskContext() ); | |||
| addExtdirs( path, m_extdirs, getTaskContext() ); | |||
| } | |||
| /** | |||
| * Adds the contents of a set of directories to a path. | |||
| */ | |||
| public static void addExtdirs( final Path toPath, | |||
| final Path extDirs, | |||
| final TaskContext context ) | |||
| throws TaskException | |||
| { | |||
| final String[] dirs = extDirs.listFiles( context ); | |||
| for( int i = 0; i < dirs.length; i++ ) | |||
| { | |||
| final File dir = new File( dirs[ i ] ); | |||
| if( dir.exists() && dir.isDirectory() ) | |||
| { | |||
| final FileSet fileSet = new FileSet(); | |||
| fileSet.setDir( dir ); | |||
| fileSet.setIncludes( "*" ); | |||
| toPath.addFileset( fileSet ); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -10,7 +10,7 @@ package org.apache.tools.todo.taskdefs.javac; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * The implementation of the gcj compiler. This is primarily a cut-and-paste | |||
| @@ -35,10 +35,7 @@ public class Gcj extends DefaultCompilerAdapter | |||
| getTaskContext().debug( "Using gcj compiler" ); | |||
| cmd = setupGCJCommand(); | |||
| int firstFileName = cmd.size(); | |||
| logAndAddFilesToCompile( cmd ); | |||
| return executeExternalCompile( cmd.getCommandline(), firstFileName ) == 0; | |||
| return executeExternalCompile( cmd ); | |||
| } | |||
| protected Commandline setupGCJCommand() | |||
| @@ -83,7 +80,7 @@ public class Gcj extends DefaultCompilerAdapter | |||
| } | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( classpath, getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getTaskContext() ) ); | |||
| if( m_encoding != null ) | |||
| { | |||
| @@ -34,10 +34,8 @@ public class JavacExternal extends DefaultCompilerAdapter | |||
| Commandline cmd = new Commandline(); | |||
| cmd.setExecutable( getJavac().getJavacExecutable() ); | |||
| setupModernJavacCommandlineSwitches( cmd ); | |||
| int firstFileName = cmd.size(); | |||
| logAndAddFilesToCompile( cmd ); | |||
| return executeExternalCompile( cmd.getCommandline(), firstFileName ) == 0; | |||
| return executeExternalCompile( cmd ); | |||
| } | |||
| } | |||
| @@ -10,7 +10,7 @@ package org.apache.tools.todo.taskdefs.javac; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * The implementation of the jikes compiler. This is primarily a cut-and-paste | |||
| @@ -91,7 +91,7 @@ public class Jikes | |||
| } | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( classpath, getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getTaskContext() ) ); | |||
| if( m_encoding != null ) | |||
| { | |||
| @@ -128,10 +128,7 @@ public class Jikes | |||
| addCurrentCompilerArgs( cmd ); | |||
| int firstFileName = cmd.size(); | |||
| logAndAddFilesToCompile( cmd ); | |||
| return executeExternalCompile( cmd.getCommandline(), firstFileName ) == 0; | |||
| return executeExternalCompile( cmd ); | |||
| } | |||
| } | |||
| @@ -10,7 +10,7 @@ package org.apache.tools.todo.taskdefs.javac; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * The implementation of the jvc compiler from microsoft. This is primarily a | |||
| @@ -68,7 +68,7 @@ public class Jvc extends DefaultCompilerAdapter | |||
| // Add the Classpath before the "internal" one. | |||
| cmd.addArgument( "/cp:p" ); | |||
| cmd.addArgument( PathUtil.formatPath( classpath, getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getTaskContext() ) ); | |||
| // Enable MS-Extensions and ... | |||
| cmd.addArgument( "/x-" ); | |||
| @@ -92,9 +92,6 @@ public class Jvc extends DefaultCompilerAdapter | |||
| addCurrentCompilerArgs( cmd ); | |||
| int firstFileName = cmd.size(); | |||
| logAndAddFilesToCompile( cmd ); | |||
| return executeExternalCompile( cmd.getCommandline(), firstFileName ) == 0; | |||
| return executeExternalCompile( cmd ); | |||
| } | |||
| } | |||
| @@ -11,7 +11,7 @@ import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * The implementation of the Java compiler for KJC. This is primarily a | |||
| @@ -99,7 +99,7 @@ public class Kjc extends DefaultCompilerAdapter | |||
| cp.add( classpath ); | |||
| cp.add( src ); | |||
| cmd.addArgument( PathUtil.formatPath( cp, getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( cp, getTaskContext() ) ); | |||
| // kjc-1.5A doesn't support -encoding option now. | |||
| // but it will be supported near the feature. | |||
| @@ -126,7 +126,8 @@ public class Kjc extends DefaultCompilerAdapter | |||
| addCurrentCompilerArgs( cmd ); | |||
| logAndAddFilesToCompile( cmd ); | |||
| logFilesToCompile( cmd ); | |||
| addFilesToCompile( cmd ); | |||
| return cmd; | |||
| } | |||
| } | |||
| @@ -33,12 +33,11 @@ public class Sj extends DefaultCompilerAdapter | |||
| { | |||
| getTaskContext().debug( "Using symantec java compiler" ); | |||
| Commandline cmd = setupJavacCommand(); | |||
| Commandline cmd = new Commandline(); | |||
| setupJavacCommandlineSwitches( cmd, false ); | |||
| cmd.setExecutable( "sj" ); | |||
| int firstFileName = cmd.size() - m_compileList.length; | |||
| return executeExternalCompile( cmd.getCommandline(), firstFileName ) == 0; | |||
| return executeExternalCompile( cmd ); | |||
| } | |||
| } | |||
| @@ -14,7 +14,6 @@ import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| /** | |||
| * Taskdef for the JJTree compiler compiler. | |||
| @@ -14,7 +14,6 @@ import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| /** | |||
| * Taskdef for the JavaCC compiler compiler. | |||
| @@ -25,7 +25,7 @@ import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.tools.todo.types.FileSet; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.ScannerUtil; | |||
| /** | |||
| @@ -570,7 +570,7 @@ public class Javadoc | |||
| classpath.add( m_classpath ); | |||
| } | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( classpath, getContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getContext() ) ); | |||
| if( m_version && m_doclet == null ) | |||
| { | |||
| @@ -607,7 +607,7 @@ public class Javadoc | |||
| if( m_doclet.getPath() != null ) | |||
| { | |||
| cmd.addArgument( "-docletpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( m_doclet.getPath(), getContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( m_doclet.getPath(), getContext() ) ); | |||
| } | |||
| for( Iterator e = m_doclet.getParams(); e.hasNext(); ) | |||
| { | |||
| @@ -628,7 +628,7 @@ public class Javadoc | |||
| if( m_bootclasspath != null ) | |||
| { | |||
| cmd.addArgument( "-bootclasspath" ); | |||
| cmd.addArgument( PathUtil.formatPath( m_bootclasspath, getContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( m_bootclasspath, getContext() ) ); | |||
| } | |||
| // add the links arguments | |||
| @@ -886,7 +886,7 @@ public class Javadoc | |||
| ArrayList packages, ArrayList excludePackages ) | |||
| throws TaskException | |||
| { | |||
| getContext().debug( "Source path = " + PathUtil.formatPath( sourcePath, getContext() ) ); | |||
| getContext().debug( "Source path = " + FileListUtil.formatPath( sourcePath, getContext() ) ); | |||
| StringBuffer msg = new StringBuffer( "Packages = " ); | |||
| for( int i = 0; i < packages.size(); i++ ) | |||
| { | |||
| @@ -16,7 +16,7 @@ import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.tools.todo.taskdefs.MatchingTask; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * Class to precompile JSP's using weblogic's jsp compiler (weblogic.jspc) | |||
| @@ -190,7 +190,7 @@ public class WLJspc extends MatchingTask | |||
| // Does not take the classpath from the env.... | |||
| // Am i missing something about the Java task?? | |||
| args[ j++ ] = "-classpath"; | |||
| args[ j++ ] = PathUtil.formatPath( compileClasspath, getContext() ); | |||
| args[ j++ ] = FileListUtil.formatPath( compileClasspath, getContext() ); | |||
| this.scanDir( files ); | |||
| getContext().info( "Compiling " + filesToDo.size() + " JSP files" ); | |||
| @@ -11,8 +11,10 @@ import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.taskdefs.jsp.JspC; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| /** | |||
| * This is the default implementation for the CompilerAdapter interface. This is | |||
| @@ -60,8 +62,10 @@ public abstract class DefaultCompilerAdapter | |||
| protected void logAndAddFilesToCompile( JspC jspc, | |||
| ArrayList compileList, | |||
| Commandline cmd ) | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Compilation args: " + cmd.toString() ); | |||
| final String[] args = cmd.getArguments(); | |||
| getTaskContext().debug( "Compilation args: " + FileUtils.formatCommandLine( args ) ); | |||
| StringBuffer niceSourceList = new StringBuffer( "File" ); | |||
| if( compileList.size() != 1 ) | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.todo.taskdefs.jsp.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.antlib.java.JavaTask; | |||
| import org.apache.tools.todo.taskdefs.jsp.JspC; | |||
| import org.apache.tools.todo.types.Argument; | |||
| @@ -30,47 +31,28 @@ public class JasperC | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Using jasper compiler" ); | |||
| Commandline cmd = setupJasperCommand(); | |||
| try | |||
| final ExecuteJava exe = new ExecuteJava(); | |||
| exe.setClassName( "org.apache.jasper.JspC" ); | |||
| if( getJspc().getClasspath() != null ) | |||
| { | |||
| // Create an instance of the compiler, redirecting output to | |||
| // the project log | |||
| //FIXME | |||
| JavaTask java = null;//(Java)( getJspc().getProject() ).createTask( "java" ); | |||
| if( getJspc().getClasspath() != null ) | |||
| { | |||
| java.addClasspath( getJspc().getClasspath() ); | |||
| } | |||
| java.setClassname( "org.apache.jasper.JspC" ); | |||
| String args[] = cmd.getArguments(); | |||
| for( int i = 0; i < args.length; i++ ) | |||
| { | |||
| java.addArg( new Argument( args[ i ] ) ); | |||
| } | |||
| java.execute(); | |||
| return true; | |||
| } | |||
| catch( Exception ex ) | |||
| { | |||
| if( ex instanceof TaskException ) | |||
| { | |||
| throw (TaskException)ex; | |||
| } | |||
| else | |||
| { | |||
| throw new TaskException( "Error running jsp compiler: ", | |||
| ex ); | |||
| } | |||
| exe.getClassPath().add( getJspc().getClasspath() ); | |||
| } | |||
| setupJasperCommand( exe.getArguments() ); | |||
| // Create an instance of the compiler, redirecting output to | |||
| // the project log | |||
| exe.execute( getTaskContext() ); | |||
| return true; | |||
| } | |||
| /* | |||
| * ------------------------------------------------------------ | |||
| */ | |||
| private Commandline setupJasperCommand() | |||
| private void setupJasperCommand( final Commandline cmd ) | |||
| throws TaskException | |||
| { | |||
| Commandline cmd = new Commandline(); | |||
| JspC jspc = getJspc(); | |||
| if( jspc.getDestdir() != null ) | |||
| { | |||
| @@ -106,9 +88,5 @@ public class JasperC | |||
| cmd.addArgument( jspc.getUribase().toString() ); | |||
| } | |||
| logAndAddFilesToCompile( getJspc(), getJspc().getCompileList(), cmd ); | |||
| return cmd; | |||
| } | |||
| /* | |||
| * ------------------------------------------------------------ | |||
| */ | |||
| } | |||
| @@ -19,13 +19,13 @@ import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.tools.todo.types.Argument; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.EnumeratedAttribute; | |||
| import org.apache.tools.todo.types.EnvironmentData; | |||
| import org.apache.tools.todo.types.EnvironmentVariable; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.tools.todo.types.SysProperties; | |||
| /** | |||
| @@ -640,7 +640,7 @@ public class JUnitTask extends AbstractTask | |||
| try | |||
| { | |||
| getContext().debug( "Using System properties " + System.getProperties() ); | |||
| final ClassLoader classLoader = PathUtil.createClassLoader( classPath, getContext() ); | |||
| final ClassLoader classLoader = FileListUtil.createClassLoader( classPath, getContext() ); | |||
| runner = new JUnitTestRunner( test, | |||
| test.getHaltonerror(), | |||
| @@ -11,7 +11,7 @@ import java.io.File; | |||
| import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * Metamata Audit evaluates Java code for programming errors, weaknesses, and | |||
| @@ -129,7 +129,7 @@ public class MAudit | |||
| // don't forget to modify the pattern if you change the options reporting | |||
| classpath.add( getClassPath() ); | |||
| final String formattedClasspath = PathUtil.formatPath( classpath, getContext() ); | |||
| final String formattedClasspath = FileListUtil.formatPath( classpath, getContext() ); | |||
| if( formattedClasspath.length() > 0 ) | |||
| { | |||
| options.add( "-classpath" ); | |||
| @@ -162,7 +162,7 @@ public class MAudit | |||
| if( m_unused ) | |||
| { | |||
| options.add( "-unused" ); | |||
| options.add( PathUtil.formatPath( m_searchPath, getContext() ) ); | |||
| options.add( FileListUtil.formatPath( m_searchPath, getContext() ) ); | |||
| } | |||
| addAllArrayList( options, getIncludedFiles().keySet().iterator() ); | |||
| return options; | |||
| @@ -15,7 +15,7 @@ import java.util.ArrayList; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.taskdefs.exec.ExecuteStreamHandler; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * Calculates global complexity and quality metrics on Java source code. You | |||
| @@ -132,7 +132,7 @@ public class MMetrics extends AbstractMetamataTask | |||
| // don't forget to modify the pattern if you change the options reporting | |||
| classpath.add( getClassPath() ); | |||
| final String formattedClasspath = PathUtil.formatPath( classpath, getContext() ); | |||
| final String formattedClasspath = FileListUtil.formatPath( classpath, getContext() ); | |||
| if( formattedClasspath.length() > 0 ) | |||
| { | |||
| options.add( "-classpath" ); | |||
| @@ -19,7 +19,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.tools.todo.types.Argument; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.aut.nativelib.PathUtil; | |||
| /** | |||
| * Simple Metamata MParse task based on the original written by <a | |||
| @@ -152,14 +152,6 @@ public abstract class P4Base | |||
| } | |||
| cmd.addLine( command ); | |||
| String[] cmdline = cmd.getCommandline(); | |||
| String cmdl = ""; | |||
| for( int i = 0; i < cmdline.length; i++ ) | |||
| { | |||
| cmdl += cmdline[ i ] + " "; | |||
| } | |||
| getContext().debug( "Execing " + cmdl ); | |||
| if( handler == null ) | |||
| { | |||
| handler = this; | |||
| @@ -241,7 +241,6 @@ public class Pvcs | |||
| // Capture output | |||
| // build the command line from what we got the format is | |||
| final Commandline cmd = buildPCLICommand(); | |||
| getContext().debug( "Executing " + cmd.toString() ); | |||
| File tmp = null; | |||
| @@ -272,17 +271,9 @@ public class Pvcs | |||
| massagePCLI( tmp, fileList ); | |||
| return fileList; | |||
| } | |||
| catch( final ParseException pe ) | |||
| catch( final Exception e ) | |||
| { | |||
| final String message = "Failed executing: " + | |||
| cmd.toString() + ". Exception: " + pe.getMessage(); | |||
| throw new TaskException( message ); | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| final String message = "Failed executing: " + | |||
| cmd.toString() + ". Exception: " + ioe.getMessage(); | |||
| throw new TaskException( message ); | |||
| throw new TaskException( "Failed execution.", e ); | |||
| } | |||
| finally | |||
| { | |||
| @@ -14,8 +14,9 @@ import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.FileNameMapper; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| /** | |||
| * This is the default implementation for the RmicAdapter interface. Currently, | |||
| @@ -106,10 +107,7 @@ public abstract class DefaultRmicAdapter | |||
| if( options != null ) | |||
| { | |||
| for( int i = 0; i < options.length; i++ ) | |||
| { | |||
| cmd.addArgument( options[ i ] ); | |||
| } | |||
| cmd.addArguments( options ); | |||
| } | |||
| Path classpath = getCompileClasspath(); | |||
| @@ -120,11 +118,11 @@ public abstract class DefaultRmicAdapter | |||
| if( attributes.getExtdirs() != null ) | |||
| { | |||
| cmd.addArgument( "-extdirs" ); | |||
| cmd.addArgument( PathUtil.formatPath( attributes.getExtdirs(), getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( attributes.getExtdirs(), getTaskContext() ) ); | |||
| } | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( PathUtil.formatPath( classpath, getTaskContext() ) ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getTaskContext() ) ); | |||
| String stubVersion = attributes.getStubVersion(); | |||
| if( null != stubVersion ) | |||
| @@ -222,11 +220,13 @@ public abstract class DefaultRmicAdapter | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| protected void logAndAddFilesToCompile( Commandline cmd ) | |||
| protected void logAndAddFilesToCompile( final Commandline cmd ) | |||
| throws TaskException | |||
| { | |||
| ArrayList compileList = attributes.getCompileList(); | |||
| getTaskContext().debug( "Compilation args: " + cmd.toString() ); | |||
| final String[] args = cmd.getArguments(); | |||
| getTaskContext().debug( "Compilation args: " + FileUtils.formatCommandLine( args ) ); | |||
| StringBuffer niceSourceList = new StringBuffer( "File" ); | |||
| if( compileList.size() != 1 ) | |||
| @@ -15,9 +15,9 @@ import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.FileNameMapper; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.taskdefs.MatchingTask; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.tools.todo.types.SourceFileScanner; | |||
| /** | |||
| @@ -483,7 +483,7 @@ public class Rmic extends MatchingTask | |||
| adapter.setRmic( this ); | |||
| Path classpath = adapter.getClasspath(); | |||
| loader = PathUtil.createClassLoader( classpath, getContext() ); | |||
| loader = FileListUtil.createClassLoader( classpath, getContext() ); | |||
| // scan base dirs to build up compile lists only if a | |||
| // specific classname is not given | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.todo.taskdefs.rmic; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.taskdefs.rmic.DefaultRmicAdapter; | |||
| @@ -45,33 +46,13 @@ public class WLRmic extends DefaultRmicAdapter | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Using WebLogic rmic" ); | |||
| Commandline cmd = setupRmicCommand( new String[]{"-noexit"} ); | |||
| try | |||
| { | |||
| // Create an instance of the rmic | |||
| Class c = Class.forName( "weblogic.rmic" ); | |||
| Method doRmic = c.getMethod( "main", | |||
| new Class[]{String[].class} ); | |||
| doRmic.invoke( null, new Object[]{cmd.getArguments()} ); | |||
| return true; | |||
| } | |||
| catch( ClassNotFoundException ex ) | |||
| { | |||
| throw new TaskException( "Cannot use WebLogic rmic, as it is not available" + | |||
| " A common solution is to set the environment variable" + | |||
| " CLASSPATH." ); | |||
| } | |||
| catch( Exception ex ) | |||
| { | |||
| if( ex instanceof TaskException ) | |||
| { | |||
| throw (TaskException)ex; | |||
| } | |||
| else | |||
| { | |||
| throw new TaskException( "Error starting WebLogic rmic: ", ex ); | |||
| } | |||
| } | |||
| final ExecuteJava exe = new ExecuteJava(); | |||
| exe.setClassName( "weblogic.rmic" ); | |||
| final Commandline cmd = setupRmicCommand( new String[]{"-noexit"} ); | |||
| exe.getArguments().addArguments( cmd ); | |||
| exe.execute( getTaskContext() ); | |||
| return true; | |||
| } | |||
| } | |||
| @@ -20,7 +20,7 @@ import org.apache.tools.todo.types.Argument; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.FileSet; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.PathUtil; | |||
| import org.apache.aut.nativelib.PathUtil; | |||
| /** | |||
| * Convenient task to run Sitraka JProbe Coverage from Ant. Options are pretty | |||
| @@ -304,7 +304,7 @@ public class Coverage | |||
| params.addArguments( m_vmArgs ); | |||
| // classpath | |||
| final String[] classpath = m_classpath.listFiles(); | |||
| final String[] classpath = m_classpath.listFiles( getContext() ); | |||
| if( classpath.length > 0 ) | |||
| { | |||
| params.addArgument( "-classpath" ); | |||
| @@ -152,14 +152,4 @@ public class Commandline | |||
| addArgument( parts[ i ] ); | |||
| } | |||
| } | |||
| public int size() | |||
| { | |||
| return getCommandline().length; | |||
| } | |||
| public String toString() | |||
| { | |||
| return StringUtil.join( getCommandline(), " " ); | |||
| } | |||
| } | |||