git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270798 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -776,7 +776,8 @@ public class Javac extends MatchingTask | |||
| GlobPatternMapper m = new GlobPatternMapper(); | |||
| m.setFrom( "*.java" ); | |||
| m.setTo( "*.class" ); | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| SourceFileScanner sfs = new SourceFileScanner(); | |||
| setupLogger( sfs ); | |||
| File[] newFiles = sfs.restrictAsFiles( files, srcDir, destDir, m ); | |||
| if( newFiles.length > 0 ) | |||
| @@ -67,7 +67,6 @@ public class Patch | |||
| * @param file The new Patchfile value | |||
| */ | |||
| public void setPatchfile( final File patchFile ) | |||
| throws TaskException | |||
| { | |||
| m_patchFile = patchFile; | |||
| } | |||
| @@ -564,8 +564,9 @@ public class Rmic extends MatchingTask | |||
| } | |||
| else | |||
| { | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| newFiles = sfs.restrict( files, baseDir, baseDir, mapper ); | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| newFiles = scanner.restrict( files, baseDir, baseDir, mapper ); | |||
| } | |||
| for( int i = 0; i < newFiles.length; i++ ) | |||
| @@ -226,7 +226,8 @@ public class Tar | |||
| private boolean archiveIsUpToDate( final String[] files ) | |||
| throws TaskException | |||
| { | |||
| final SourceFileScanner scanner = new SourceFileScanner( this ); | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| final MergingMapper mapper = new MergingMapper(); | |||
| mapper.setTo( tarFile.getAbsolutePath() ); | |||
| return scanner.restrict( files, baseDir, null, mapper ).length == 0; | |||
| @@ -161,7 +161,8 @@ public class UpToDate extends MatchingTask implements Condition | |||
| protected boolean scanDir( File srcDir, String files[] ) | |||
| throws TaskException | |||
| { | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| FileNameMapper mapper = null; | |||
| File dir = srcDir; | |||
| if( mapperElement == null ) | |||
| @@ -175,7 +176,7 @@ public class UpToDate extends MatchingTask implements Condition | |||
| { | |||
| mapper = mapperElement.getImplementation(); | |||
| } | |||
| return sfs.restrict( files, srcDir, dir, mapper ).length == 0; | |||
| return scanner.restrict( files, srcDir, dir, mapper ).length == 0; | |||
| } | |||
| /** | |||
| @@ -458,12 +458,13 @@ public class Zip | |||
| if( !zipFile.exists() ) | |||
| return false; | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| MergingMapper mm = new MergingMapper(); | |||
| mm.setTo( zipFile.getAbsolutePath() ); | |||
| for( int i = 0; i < scanners.length; i++ ) | |||
| { | |||
| if( sfs.restrict( fileNames[ i ], scanners[ i ].getBasedir(), null, | |||
| if( scanner.restrict( fileNames[ i ], scanners[ i ].getBasedir(), null, | |||
| mm ).length > 0 ) | |||
| { | |||
| return false; | |||
| @@ -176,7 +176,7 @@ public class ExecTask | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| checkConfiguration(); | |||
| validate(); | |||
| if( isValidOs() ) | |||
| { | |||
| runExec( prepareExec() ); | |||
| @@ -250,7 +250,7 @@ public class ExecTask | |||
| * | |||
| * @exception TaskException Description of Exception | |||
| */ | |||
| protected void checkConfiguration() | |||
| protected void validate() | |||
| throws TaskException | |||
| { | |||
| if( m_command.getExecutable() == null ) | |||
| @@ -313,8 +313,9 @@ public class ExecuteOn extends ExecTask | |||
| { | |||
| if( mapper != null ) | |||
| { | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| return sfs.restrict( ds.getIncludedDirectories(), baseDir, destDir, | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| return scanner.restrict( ds.getIncludedDirectories(), baseDir, destDir, | |||
| mapper ); | |||
| } | |||
| else | |||
| @@ -336,8 +337,9 @@ public class ExecuteOn extends ExecTask | |||
| { | |||
| if( mapper != null ) | |||
| { | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| return sfs.restrict( ds.getIncludedFiles(), baseDir, destDir, | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| return scanner.restrict( ds.getIncludedFiles(), baseDir, destDir, | |||
| mapper ); | |||
| } | |||
| else | |||
| @@ -346,10 +348,10 @@ public class ExecuteOn extends ExecTask | |||
| } | |||
| } | |||
| protected void checkConfiguration() | |||
| protected void validate() | |||
| throws TaskException | |||
| { | |||
| super.checkConfiguration(); | |||
| super.validate(); | |||
| if( filesets.size() == 0 ) | |||
| { | |||
| throw new TaskException( "no filesets specified" ); | |||
| @@ -305,7 +305,8 @@ public class Copy | |||
| } | |||
| else | |||
| { | |||
| final SourceFileScanner scanner = new SourceFileScanner( this ); | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| return scanner.restrict( names, fromDir, toDir, mapper ); | |||
| } | |||
| } | |||
| @@ -96,7 +96,7 @@ public class Javadoc | |||
| public void setAdditionalparam( String add ) | |||
| throws TaskException | |||
| { | |||
| m_command.createArgument().setLine( add ); | |||
| m_command.addLine( add ); | |||
| } | |||
| public void setAuthor( boolean src ) | |||
| @@ -258,7 +258,7 @@ public class Cab | |||
| if( m_options != null ) | |||
| { | |||
| cmd.createArgument().setLine( m_options ); | |||
| cmd.addLine( m_options ); | |||
| } | |||
| cmd.addArgument( "n" ); | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.ant.taskdefs.optional; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.types.Argument; | |||
| /** | |||
| * Basic task for apache stylebook. | |||
| @@ -57,12 +58,12 @@ public class StyleBook | |||
| { | |||
| validate(); | |||
| createArg().setValue( "targetDirectory=" + m_targetDirectory ); | |||
| createArg().setValue( m_book.toString() ); | |||
| createArg().setValue( m_skinDirectory.toString() ); | |||
| addArg( new Argument( "targetDirectory=" + m_targetDirectory ) ); | |||
| addArg( new Argument( m_book.toString() ) ); | |||
| addArg( new Argument( m_skinDirectory.toString() ) ); | |||
| if( null != m_loaderConfig ) | |||
| { | |||
| createArg().setValue( "loaderConfig=" + m_loaderConfig ); | |||
| addArg( new Argument( "loaderConfig=" + m_loaderConfig ) ); | |||
| } | |||
| super.execute(); | |||
| @@ -13,6 +13,7 @@ import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute2; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Argument; | |||
| /** | |||
| * BorlandGenerateClient is dedicated to the Borland Application Server 4.5 This | |||
| @@ -219,31 +220,32 @@ public class BorlandGenerateClient extends Task | |||
| //execTask.addClasspath( classpath.concatSystemClasspath( "last" ) ); | |||
| execTask.setFork( true ); | |||
| execTask.createArg().setValue( "generateclient" ); | |||
| execTask.addArg( new Argument( "generateclient" ) ); | |||
| if( debug ) | |||
| { | |||
| execTask.createArg().setValue( "-trace" ); | |||
| execTask.addArg( new Argument( "-trace" ) ); | |||
| }// end of if () | |||
| // | |||
| execTask.createArg().setValue( "-short" ); | |||
| execTask.createArg().setValue( "-jarfile" ); | |||
| execTask.addArg( new Argument( "-short" ) ); | |||
| execTask.addArg( new Argument( "-jarfile" ) ); | |||
| // ejb jar file | |||
| execTask.createArg().setValue( ejbjarfile.getAbsolutePath() ); | |||
| execTask.addArg( new Argument( ejbjarfile.getAbsolutePath() ) ); | |||
| //client jar file | |||
| execTask.createArg().setValue( "-single" ); | |||
| execTask.createArg().setValue( "-clientjarfile" ); | |||
| execTask.createArg().setValue( clientjarfile.getAbsolutePath() ); | |||
| execTask.addArg( new Argument( "-single" ) ); | |||
| execTask.addArg( new Argument( "-clientjarfile" ) ); | |||
| execTask.addArg( new Argument( clientjarfile.getAbsolutePath() ) ); | |||
| getLogger().debug( "Calling EJBUtilities" ); | |||
| execTask.execute(); | |||
| } | |||
| catch( Exception e ) | |||
| catch( final Exception e ) | |||
| { | |||
| // Have to catch this because of the semantics of calling main() | |||
| String msg = "Exception while calling generateclient Details: " + e.toString(); | |||
| throw new TaskException( msg, e ); | |||
| final String message = | |||
| "Exception while calling generateclient Details: " + e.toString(); | |||
| throw new TaskException( message, e ); | |||
| } | |||
| } | |||
| } | |||
| @@ -16,6 +16,7 @@ import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Argument; | |||
| /** | |||
| * Class to precompile JSP's using weblogic's jsp compiler (weblogic.jspc) | |||
| @@ -230,7 +231,7 @@ public class WLJspc extends MatchingTask | |||
| System.out.println( "arg = " + arg ); | |||
| //helperTask.clearArgs(); | |||
| helperTask.createArg().setValue( arg ); | |||
| helperTask.addArg( new Argument( arg ) ); | |||
| helperTask.addClasspath( compileClasspath ); | |||
| if( helperTask.executeJava() != 0 ) | |||
| { | |||
| @@ -11,6 +11,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Argument; | |||
| /** | |||
| * The implementation of the jasper compiler. This is a cut-and-paste of the | |||
| @@ -41,7 +42,7 @@ public class JasperC | |||
| java.setClassname( "org.apache.jasper.JspC" ); | |||
| String args[] = cmd.getArguments(); | |||
| for( int i = 0; i < args.length; i++ ) | |||
| java.createArg().setValue( args[ i ] ); | |||
| java.addArg( new Argument( args[ i ] ) ); | |||
| java.execute(); | |||
| return true; | |||
| } | |||
| @@ -210,8 +210,8 @@ public abstract class AbstractMetamataTask | |||
| ArrayList options = getOptions(); | |||
| m_optionsFile = createTmpFile(); | |||
| generateOptionsFile( m_optionsFile, options ); | |||
| Argument args = m_cmdl.createArgument(); | |||
| args.setLine( "-arguments " + m_optionsFile.getAbsolutePath() ); | |||
| m_cmdl.addArgument( "-arguments " ); | |||
| m_cmdl.addArgument( m_optionsFile.getAbsolutePath() ); | |||
| } | |||
| /** | |||
| @@ -211,8 +211,8 @@ public class MParse | |||
| String[] options = getOptions(); | |||
| m_optionsFile = createTmpFile(); | |||
| generateOptionsFile( m_optionsFile, options ); | |||
| Argument args = m_cmdl.createArgument(); | |||
| args.setLine( "-arguments " + m_optionsFile.getAbsolutePath() ); | |||
| m_cmdl.addArgument( "-arguments" ); | |||
| m_cmdl.addArgument( m_optionsFile.getAbsolutePath() ); | |||
| } | |||
| /** | |||
| @@ -150,7 +150,7 @@ public abstract class P4Base | |||
| { | |||
| cmd.addArgument( m_p4Client ); | |||
| } | |||
| cmd.createArgument().setLine( command ); | |||
| cmd.addLine( command ); | |||
| String[] cmdline = cmd.getCommandline(); | |||
| String cmdl = ""; | |||
| @@ -113,7 +113,8 @@ public class Native2Ascii | |||
| final DirectoryScanner scanner = getDirectoryScanner( m_srcDir ); | |||
| String[] files = scanner.getIncludedFiles(); | |||
| final SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| final SourceFileScanner sfs = new SourceFileScanner(); | |||
| setupLogger( sfs ); | |||
| final FileNameMapper mapper = buildMapper(); | |||
| files = sfs.restrict( files, m_srcDir, m_destDir, mapper ); | |||
| int count = files.length; | |||
| @@ -9,13 +9,14 @@ package org.apache.tools.ant.taskdefs.unix; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.aut.nativelib.Os; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecuteOn; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecuteOn; | |||
| import org.apache.tools.ant.types.Argument; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.types.NameEntry; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| /** | |||
| * Chmod equivalent for unix-like environments. | |||
| @@ -26,13 +27,12 @@ import org.apache.tools.ant.types.NameEntry; | |||
| * mnowostawski@infoscience.otago.ac.nz</a> | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| */ | |||
| public class Chmod extends ExecuteOn | |||
| public class Chmod | |||
| extends ExecuteOn | |||
| { | |||
| private FileSet defaultSet = new FileSet(); | |||
| private boolean defaultSetDefined = false; | |||
| private boolean havePerm = false; | |||
| private FileSet m_defaultSet = new FileSet(); | |||
| private boolean m_defaultSetDefined; | |||
| private boolean m_havePerm; | |||
| public Chmod() | |||
| throws TaskException | |||
| @@ -51,14 +51,14 @@ public class Chmod extends ExecuteOn | |||
| public void setDefaultexcludes( boolean useDefaultExcludes ) | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| defaultSet.setDefaultexcludes( useDefaultExcludes ); | |||
| m_defaultSetDefined = true; | |||
| m_defaultSet.setDefaultexcludes( useDefaultExcludes ); | |||
| } | |||
| public void setDir( File src ) | |||
| throws TaskException | |||
| { | |||
| defaultSet.setDir( src ); | |||
| m_defaultSet.setDir( src ); | |||
| } | |||
| /** | |||
| @@ -70,8 +70,8 @@ public class Chmod extends ExecuteOn | |||
| public void setExcludes( String excludes ) | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| defaultSet.setExcludes( excludes ); | |||
| m_defaultSetDefined = true; | |||
| m_defaultSet.setExcludes( excludes ); | |||
| } | |||
| public void setExecutable( String e ) | |||
| @@ -98,14 +98,14 @@ public class Chmod extends ExecuteOn | |||
| public void setIncludes( String includes ) | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| defaultSet.setIncludes( includes ); | |||
| m_defaultSetDefined = true; | |||
| m_defaultSet.setIncludes( includes ); | |||
| } | |||
| public void setPerm( String perm ) | |||
| { | |||
| createArg().setValue( perm ); | |||
| havePerm = true; | |||
| addArg( new Argument( perm ) ); | |||
| m_havePerm = true; | |||
| } | |||
| public void setSkipEmptyFilesets( final boolean skip ) | |||
| @@ -122,8 +122,8 @@ public class Chmod extends ExecuteOn | |||
| public NameEntry createExclude() | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| return defaultSet.createExclude(); | |||
| m_defaultSetDefined = true; | |||
| return m_defaultSet.createExclude(); | |||
| } | |||
| /** | |||
| @@ -134,8 +134,8 @@ public class Chmod extends ExecuteOn | |||
| public NameEntry createInclude() | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| return defaultSet.createInclude(); | |||
| m_defaultSetDefined = true; | |||
| return m_defaultSet.createInclude(); | |||
| } | |||
| /** | |||
| @@ -146,31 +146,31 @@ public class Chmod extends ExecuteOn | |||
| public PatternSet createPatternSet() | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| return defaultSet.createPatternSet(); | |||
| m_defaultSetDefined = true; | |||
| return m_defaultSet.createPatternSet(); | |||
| } | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| if( defaultSetDefined || defaultSet.getDir() == null ) | |||
| if( m_defaultSetDefined || m_defaultSet.getDir() == null ) | |||
| { | |||
| super.execute(); | |||
| } | |||
| else if( isValidOs() ) | |||
| { | |||
| // we are chmodding the given directory | |||
| createArg().setValue( defaultSet.getDir().getPath() ); | |||
| addArg( new Argument( m_defaultSet.getDir().getPath() ) ); | |||
| Execute execute = prepareExec(); | |||
| try | |||
| { | |||
| execute.setCommandline( getCommand().getCommandline() ); | |||
| runExecute( execute ); | |||
| } | |||
| catch( IOException e ) | |||
| catch( final IOException ioe ) | |||
| { | |||
| final String message = "Execute failed: " + e; | |||
| throw new TaskException( message, e ); | |||
| final String message = "Execute failed: " + ioe; | |||
| throw new TaskException( message, ioe ); | |||
| } | |||
| finally | |||
| { | |||
| @@ -185,18 +185,18 @@ public class Chmod extends ExecuteOn | |||
| return Os.isFamily( "unix" ) && super.isValidOs(); | |||
| } | |||
| protected void checkConfiguration() | |||
| protected void validate() | |||
| throws TaskException | |||
| { | |||
| if( !havePerm ) | |||
| if( !m_havePerm ) | |||
| { | |||
| throw new TaskException( "Required attribute perm not set in chmod" ); | |||
| } | |||
| if( defaultSetDefined && defaultSet.getDir() != null ) | |||
| if( m_defaultSetDefined && m_defaultSet.getDir() != null ) | |||
| { | |||
| addFileset( defaultSet ); | |||
| addFileset( m_defaultSet ); | |||
| } | |||
| super.checkConfiguration(); | |||
| super.validate(); | |||
| } | |||
| } | |||
| @@ -124,7 +124,7 @@ public class Rpm | |||
| cmd.addArgument( "_topdir" + m_topDir ); | |||
| } | |||
| cmd.createArgument().setLine( m_command ); | |||
| cmd.addLine( m_command ); | |||
| if( m_cleanBuildDir ) | |||
| { | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| /** | |||
| * Commandline objects help handling command lines specifying processes to | |||
| @@ -132,6 +133,14 @@ public class Commandline | |||
| m_arguments.add( argument ); | |||
| } | |||
| public void addLine( final String line ) | |||
| throws TaskException | |||
| { | |||
| final Argument argument = new Argument(); | |||
| argument.setLine( line ); | |||
| addArgument( argument ); | |||
| } | |||
| /** | |||
| * Return a marker. <p> | |||
| * | |||
| @@ -178,11 +178,6 @@ public class CommandlineJava | |||
| m_sysProperties.addVariable( sysp ); | |||
| } | |||
| public Argument createArgument() | |||
| { | |||
| return m_javaCommand.createArgument(); | |||
| } | |||
| public void addArgument( final String argument ) | |||
| { | |||
| m_javaCommand.addArgument( argument ); | |||
| @@ -13,7 +13,6 @@ import org.apache.aut.nativelib.Os; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.util.mappers.FileNameMapper; | |||
| /** | |||
| @@ -29,16 +28,6 @@ import org.apache.tools.ant.util.mappers.FileNameMapper; | |||
| public class SourceFileScanner | |||
| extends AbstractLogEnabled | |||
| { | |||
| private Task m_task; | |||
| /** | |||
| * @param task The task we should log messages through | |||
| */ | |||
| public SourceFileScanner( Task task ) | |||
| { | |||
| this.m_task = task; | |||
| } | |||
| /** | |||
| * Restrict the given set of files to those that are newer than their | |||
| * corresponding target files. | |||
| @@ -776,7 +776,8 @@ public class Javac extends MatchingTask | |||
| GlobPatternMapper m = new GlobPatternMapper(); | |||
| m.setFrom( "*.java" ); | |||
| m.setTo( "*.class" ); | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| SourceFileScanner sfs = new SourceFileScanner(); | |||
| setupLogger( sfs ); | |||
| File[] newFiles = sfs.restrictAsFiles( files, srcDir, destDir, m ); | |||
| if( newFiles.length > 0 ) | |||
| @@ -67,7 +67,6 @@ public class Patch | |||
| * @param file The new Patchfile value | |||
| */ | |||
| public void setPatchfile( final File patchFile ) | |||
| throws TaskException | |||
| { | |||
| m_patchFile = patchFile; | |||
| } | |||
| @@ -564,8 +564,9 @@ public class Rmic extends MatchingTask | |||
| } | |||
| else | |||
| { | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| newFiles = sfs.restrict( files, baseDir, baseDir, mapper ); | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| newFiles = scanner.restrict( files, baseDir, baseDir, mapper ); | |||
| } | |||
| for( int i = 0; i < newFiles.length; i++ ) | |||
| @@ -226,7 +226,8 @@ public class Tar | |||
| private boolean archiveIsUpToDate( final String[] files ) | |||
| throws TaskException | |||
| { | |||
| final SourceFileScanner scanner = new SourceFileScanner( this ); | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| final MergingMapper mapper = new MergingMapper(); | |||
| mapper.setTo( tarFile.getAbsolutePath() ); | |||
| return scanner.restrict( files, baseDir, null, mapper ).length == 0; | |||
| @@ -161,7 +161,8 @@ public class UpToDate extends MatchingTask implements Condition | |||
| protected boolean scanDir( File srcDir, String files[] ) | |||
| throws TaskException | |||
| { | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| FileNameMapper mapper = null; | |||
| File dir = srcDir; | |||
| if( mapperElement == null ) | |||
| @@ -175,7 +176,7 @@ public class UpToDate extends MatchingTask implements Condition | |||
| { | |||
| mapper = mapperElement.getImplementation(); | |||
| } | |||
| return sfs.restrict( files, srcDir, dir, mapper ).length == 0; | |||
| return scanner.restrict( files, srcDir, dir, mapper ).length == 0; | |||
| } | |||
| /** | |||
| @@ -458,12 +458,13 @@ public class Zip | |||
| if( !zipFile.exists() ) | |||
| return false; | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| MergingMapper mm = new MergingMapper(); | |||
| mm.setTo( zipFile.getAbsolutePath() ); | |||
| for( int i = 0; i < scanners.length; i++ ) | |||
| { | |||
| if( sfs.restrict( fileNames[ i ], scanners[ i ].getBasedir(), null, | |||
| if( scanner.restrict( fileNames[ i ], scanners[ i ].getBasedir(), null, | |||
| mm ).length > 0 ) | |||
| { | |||
| return false; | |||
| @@ -176,7 +176,7 @@ public class ExecTask | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| checkConfiguration(); | |||
| validate(); | |||
| if( isValidOs() ) | |||
| { | |||
| runExec( prepareExec() ); | |||
| @@ -250,7 +250,7 @@ public class ExecTask | |||
| * | |||
| * @exception TaskException Description of Exception | |||
| */ | |||
| protected void checkConfiguration() | |||
| protected void validate() | |||
| throws TaskException | |||
| { | |||
| if( m_command.getExecutable() == null ) | |||
| @@ -313,8 +313,9 @@ public class ExecuteOn extends ExecTask | |||
| { | |||
| if( mapper != null ) | |||
| { | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| return sfs.restrict( ds.getIncludedDirectories(), baseDir, destDir, | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| return scanner.restrict( ds.getIncludedDirectories(), baseDir, destDir, | |||
| mapper ); | |||
| } | |||
| else | |||
| @@ -336,8 +337,9 @@ public class ExecuteOn extends ExecTask | |||
| { | |||
| if( mapper != null ) | |||
| { | |||
| SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| return sfs.restrict( ds.getIncludedFiles(), baseDir, destDir, | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| return scanner.restrict( ds.getIncludedFiles(), baseDir, destDir, | |||
| mapper ); | |||
| } | |||
| else | |||
| @@ -346,10 +348,10 @@ public class ExecuteOn extends ExecTask | |||
| } | |||
| } | |||
| protected void checkConfiguration() | |||
| protected void validate() | |||
| throws TaskException | |||
| { | |||
| super.checkConfiguration(); | |||
| super.validate(); | |||
| if( filesets.size() == 0 ) | |||
| { | |||
| throw new TaskException( "no filesets specified" ); | |||
| @@ -305,7 +305,8 @@ public class Copy | |||
| } | |||
| else | |||
| { | |||
| final SourceFileScanner scanner = new SourceFileScanner( this ); | |||
| final SourceFileScanner scanner = new SourceFileScanner(); | |||
| setupLogger( scanner ); | |||
| return scanner.restrict( names, fromDir, toDir, mapper ); | |||
| } | |||
| } | |||
| @@ -96,7 +96,7 @@ public class Javadoc | |||
| public void setAdditionalparam( String add ) | |||
| throws TaskException | |||
| { | |||
| m_command.createArgument().setLine( add ); | |||
| m_command.addLine( add ); | |||
| } | |||
| public void setAuthor( boolean src ) | |||
| @@ -258,7 +258,7 @@ public class Cab | |||
| if( m_options != null ) | |||
| { | |||
| cmd.createArgument().setLine( m_options ); | |||
| cmd.addLine( m_options ); | |||
| } | |||
| cmd.addArgument( "n" ); | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.ant.taskdefs.optional; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.types.Argument; | |||
| /** | |||
| * Basic task for apache stylebook. | |||
| @@ -57,12 +58,12 @@ public class StyleBook | |||
| { | |||
| validate(); | |||
| createArg().setValue( "targetDirectory=" + m_targetDirectory ); | |||
| createArg().setValue( m_book.toString() ); | |||
| createArg().setValue( m_skinDirectory.toString() ); | |||
| addArg( new Argument( "targetDirectory=" + m_targetDirectory ) ); | |||
| addArg( new Argument( m_book.toString() ) ); | |||
| addArg( new Argument( m_skinDirectory.toString() ) ); | |||
| if( null != m_loaderConfig ) | |||
| { | |||
| createArg().setValue( "loaderConfig=" + m_loaderConfig ); | |||
| addArg( new Argument( "loaderConfig=" + m_loaderConfig ) ); | |||
| } | |||
| super.execute(); | |||
| @@ -13,6 +13,7 @@ import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute2; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Argument; | |||
| /** | |||
| * BorlandGenerateClient is dedicated to the Borland Application Server 4.5 This | |||
| @@ -219,31 +220,32 @@ public class BorlandGenerateClient extends Task | |||
| //execTask.addClasspath( classpath.concatSystemClasspath( "last" ) ); | |||
| execTask.setFork( true ); | |||
| execTask.createArg().setValue( "generateclient" ); | |||
| execTask.addArg( new Argument( "generateclient" ) ); | |||
| if( debug ) | |||
| { | |||
| execTask.createArg().setValue( "-trace" ); | |||
| execTask.addArg( new Argument( "-trace" ) ); | |||
| }// end of if () | |||
| // | |||
| execTask.createArg().setValue( "-short" ); | |||
| execTask.createArg().setValue( "-jarfile" ); | |||
| execTask.addArg( new Argument( "-short" ) ); | |||
| execTask.addArg( new Argument( "-jarfile" ) ); | |||
| // ejb jar file | |||
| execTask.createArg().setValue( ejbjarfile.getAbsolutePath() ); | |||
| execTask.addArg( new Argument( ejbjarfile.getAbsolutePath() ) ); | |||
| //client jar file | |||
| execTask.createArg().setValue( "-single" ); | |||
| execTask.createArg().setValue( "-clientjarfile" ); | |||
| execTask.createArg().setValue( clientjarfile.getAbsolutePath() ); | |||
| execTask.addArg( new Argument( "-single" ) ); | |||
| execTask.addArg( new Argument( "-clientjarfile" ) ); | |||
| execTask.addArg( new Argument( clientjarfile.getAbsolutePath() ) ); | |||
| getLogger().debug( "Calling EJBUtilities" ); | |||
| execTask.execute(); | |||
| } | |||
| catch( Exception e ) | |||
| catch( final Exception e ) | |||
| { | |||
| // Have to catch this because of the semantics of calling main() | |||
| String msg = "Exception while calling generateclient Details: " + e.toString(); | |||
| throw new TaskException( msg, e ); | |||
| final String message = | |||
| "Exception while calling generateclient Details: " + e.toString(); | |||
| throw new TaskException( message, e ); | |||
| } | |||
| } | |||
| } | |||
| @@ -16,6 +16,7 @@ import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Argument; | |||
| /** | |||
| * Class to precompile JSP's using weblogic's jsp compiler (weblogic.jspc) | |||
| @@ -230,7 +231,7 @@ public class WLJspc extends MatchingTask | |||
| System.out.println( "arg = " + arg ); | |||
| //helperTask.clearArgs(); | |||
| helperTask.createArg().setValue( arg ); | |||
| helperTask.addArg( new Argument( arg ) ); | |||
| helperTask.addClasspath( compileClasspath ); | |||
| if( helperTask.executeJava() != 0 ) | |||
| { | |||
| @@ -11,6 +11,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.taskdefs.optional.jsp.JspC; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Argument; | |||
| /** | |||
| * The implementation of the jasper compiler. This is a cut-and-paste of the | |||
| @@ -41,7 +42,7 @@ public class JasperC | |||
| java.setClassname( "org.apache.jasper.JspC" ); | |||
| String args[] = cmd.getArguments(); | |||
| for( int i = 0; i < args.length; i++ ) | |||
| java.createArg().setValue( args[ i ] ); | |||
| java.addArg( new Argument( args[ i ] ) ); | |||
| java.execute(); | |||
| return true; | |||
| } | |||
| @@ -210,8 +210,8 @@ public abstract class AbstractMetamataTask | |||
| ArrayList options = getOptions(); | |||
| m_optionsFile = createTmpFile(); | |||
| generateOptionsFile( m_optionsFile, options ); | |||
| Argument args = m_cmdl.createArgument(); | |||
| args.setLine( "-arguments " + m_optionsFile.getAbsolutePath() ); | |||
| m_cmdl.addArgument( "-arguments " ); | |||
| m_cmdl.addArgument( m_optionsFile.getAbsolutePath() ); | |||
| } | |||
| /** | |||
| @@ -211,8 +211,8 @@ public class MParse | |||
| String[] options = getOptions(); | |||
| m_optionsFile = createTmpFile(); | |||
| generateOptionsFile( m_optionsFile, options ); | |||
| Argument args = m_cmdl.createArgument(); | |||
| args.setLine( "-arguments " + m_optionsFile.getAbsolutePath() ); | |||
| m_cmdl.addArgument( "-arguments" ); | |||
| m_cmdl.addArgument( m_optionsFile.getAbsolutePath() ); | |||
| } | |||
| /** | |||
| @@ -150,7 +150,7 @@ public abstract class P4Base | |||
| { | |||
| cmd.addArgument( m_p4Client ); | |||
| } | |||
| cmd.createArgument().setLine( command ); | |||
| cmd.addLine( command ); | |||
| String[] cmdline = cmd.getCommandline(); | |||
| String cmdl = ""; | |||
| @@ -113,7 +113,8 @@ public class Native2Ascii | |||
| final DirectoryScanner scanner = getDirectoryScanner( m_srcDir ); | |||
| String[] files = scanner.getIncludedFiles(); | |||
| final SourceFileScanner sfs = new SourceFileScanner( this ); | |||
| final SourceFileScanner sfs = new SourceFileScanner(); | |||
| setupLogger( sfs ); | |||
| final FileNameMapper mapper = buildMapper(); | |||
| files = sfs.restrict( files, m_srcDir, m_destDir, mapper ); | |||
| int count = files.length; | |||
| @@ -9,13 +9,14 @@ package org.apache.tools.ant.taskdefs.unix; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.aut.nativelib.Os; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecuteOn; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecuteOn; | |||
| import org.apache.tools.ant.types.Argument; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.types.NameEntry; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| /** | |||
| * Chmod equivalent for unix-like environments. | |||
| @@ -26,13 +27,12 @@ import org.apache.tools.ant.types.NameEntry; | |||
| * mnowostawski@infoscience.otago.ac.nz</a> | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| */ | |||
| public class Chmod extends ExecuteOn | |||
| public class Chmod | |||
| extends ExecuteOn | |||
| { | |||
| private FileSet defaultSet = new FileSet(); | |||
| private boolean defaultSetDefined = false; | |||
| private boolean havePerm = false; | |||
| private FileSet m_defaultSet = new FileSet(); | |||
| private boolean m_defaultSetDefined; | |||
| private boolean m_havePerm; | |||
| public Chmod() | |||
| throws TaskException | |||
| @@ -51,14 +51,14 @@ public class Chmod extends ExecuteOn | |||
| public void setDefaultexcludes( boolean useDefaultExcludes ) | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| defaultSet.setDefaultexcludes( useDefaultExcludes ); | |||
| m_defaultSetDefined = true; | |||
| m_defaultSet.setDefaultexcludes( useDefaultExcludes ); | |||
| } | |||
| public void setDir( File src ) | |||
| throws TaskException | |||
| { | |||
| defaultSet.setDir( src ); | |||
| m_defaultSet.setDir( src ); | |||
| } | |||
| /** | |||
| @@ -70,8 +70,8 @@ public class Chmod extends ExecuteOn | |||
| public void setExcludes( String excludes ) | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| defaultSet.setExcludes( excludes ); | |||
| m_defaultSetDefined = true; | |||
| m_defaultSet.setExcludes( excludes ); | |||
| } | |||
| public void setExecutable( String e ) | |||
| @@ -98,14 +98,14 @@ public class Chmod extends ExecuteOn | |||
| public void setIncludes( String includes ) | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| defaultSet.setIncludes( includes ); | |||
| m_defaultSetDefined = true; | |||
| m_defaultSet.setIncludes( includes ); | |||
| } | |||
| public void setPerm( String perm ) | |||
| { | |||
| createArg().setValue( perm ); | |||
| havePerm = true; | |||
| addArg( new Argument( perm ) ); | |||
| m_havePerm = true; | |||
| } | |||
| public void setSkipEmptyFilesets( final boolean skip ) | |||
| @@ -122,8 +122,8 @@ public class Chmod extends ExecuteOn | |||
| public NameEntry createExclude() | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| return defaultSet.createExclude(); | |||
| m_defaultSetDefined = true; | |||
| return m_defaultSet.createExclude(); | |||
| } | |||
| /** | |||
| @@ -134,8 +134,8 @@ public class Chmod extends ExecuteOn | |||
| public NameEntry createInclude() | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| return defaultSet.createInclude(); | |||
| m_defaultSetDefined = true; | |||
| return m_defaultSet.createInclude(); | |||
| } | |||
| /** | |||
| @@ -146,31 +146,31 @@ public class Chmod extends ExecuteOn | |||
| public PatternSet createPatternSet() | |||
| throws TaskException | |||
| { | |||
| defaultSetDefined = true; | |||
| return defaultSet.createPatternSet(); | |||
| m_defaultSetDefined = true; | |||
| return m_defaultSet.createPatternSet(); | |||
| } | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| if( defaultSetDefined || defaultSet.getDir() == null ) | |||
| if( m_defaultSetDefined || m_defaultSet.getDir() == null ) | |||
| { | |||
| super.execute(); | |||
| } | |||
| else if( isValidOs() ) | |||
| { | |||
| // we are chmodding the given directory | |||
| createArg().setValue( defaultSet.getDir().getPath() ); | |||
| addArg( new Argument( m_defaultSet.getDir().getPath() ) ); | |||
| Execute execute = prepareExec(); | |||
| try | |||
| { | |||
| execute.setCommandline( getCommand().getCommandline() ); | |||
| runExecute( execute ); | |||
| } | |||
| catch( IOException e ) | |||
| catch( final IOException ioe ) | |||
| { | |||
| final String message = "Execute failed: " + e; | |||
| throw new TaskException( message, e ); | |||
| final String message = "Execute failed: " + ioe; | |||
| throw new TaskException( message, ioe ); | |||
| } | |||
| finally | |||
| { | |||
| @@ -185,18 +185,18 @@ public class Chmod extends ExecuteOn | |||
| return Os.isFamily( "unix" ) && super.isValidOs(); | |||
| } | |||
| protected void checkConfiguration() | |||
| protected void validate() | |||
| throws TaskException | |||
| { | |||
| if( !havePerm ) | |||
| if( !m_havePerm ) | |||
| { | |||
| throw new TaskException( "Required attribute perm not set in chmod" ); | |||
| } | |||
| if( defaultSetDefined && defaultSet.getDir() != null ) | |||
| if( m_defaultSetDefined && m_defaultSet.getDir() != null ) | |||
| { | |||
| addFileset( defaultSet ); | |||
| addFileset( m_defaultSet ); | |||
| } | |||
| super.checkConfiguration(); | |||
| super.validate(); | |||
| } | |||
| } | |||
| @@ -124,7 +124,7 @@ public class Rpm | |||
| cmd.addArgument( "_topdir" + m_topDir ); | |||
| } | |||
| cmd.createArgument().setLine( m_command ); | |||
| cmd.addLine( m_command ); | |||
| if( m_cleanBuildDir ) | |||
| { | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| /** | |||
| * Commandline objects help handling command lines specifying processes to | |||
| @@ -132,6 +133,14 @@ public class Commandline | |||
| m_arguments.add( argument ); | |||
| } | |||
| public void addLine( final String line ) | |||
| throws TaskException | |||
| { | |||
| final Argument argument = new Argument(); | |||
| argument.setLine( line ); | |||
| addArgument( argument ); | |||
| } | |||
| /** | |||
| * Return a marker. <p> | |||
| * | |||
| @@ -178,11 +178,6 @@ public class CommandlineJava | |||
| m_sysProperties.addVariable( sysp ); | |||
| } | |||
| public Argument createArgument() | |||
| { | |||
| return m_javaCommand.createArgument(); | |||
| } | |||
| public void addArgument( final String argument ) | |||
| { | |||
| m_javaCommand.addArgument( argument ); | |||
| @@ -13,7 +13,6 @@ import org.apache.aut.nativelib.Os; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.util.mappers.FileNameMapper; | |||
| /** | |||
| @@ -29,16 +28,6 @@ import org.apache.tools.ant.util.mappers.FileNameMapper; | |||
| public class SourceFileScanner | |||
| extends AbstractLogEnabled | |||
| { | |||
| private Task m_task; | |||
| /** | |||
| * @param task The task we should log messages through | |||
| */ | |||
| public SourceFileScanner( Task task ) | |||
| { | |||
| this.m_task = task; | |||
| } | |||
| /** | |||
| * Restrict the given set of files to those that are newer than their | |||
| * corresponding target files. | |||