Browse Source

Started to migrate FileSet away from using Project and for implementing references itself (rather than letting container manage references)

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270499 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
ce6c8d711c
67 changed files with 308 additions and 942 deletions
  1. +2
    -2
      proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java
  2. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java
  3. +4
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/DependSet.java
  4. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  5. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java
  6. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
  7. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  8. +4
    -14
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java
  9. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java
  10. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java
  11. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java
  12. +8
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Delete.java
  13. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Move.java
  14. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Touch.java
  15. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java
  16. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  17. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  18. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
  19. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java
  20. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
  21. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  22. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java
  23. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  24. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java
  25. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java
  26. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java
  27. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/security/SignJar.java
  28. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java
  29. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java
  30. +53
    -228
      proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java
  31. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java
  32. +37
    -165
      proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java
  33. +5
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java
  34. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java
  35. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java
  36. +4
    -4
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/DependSet.java
  37. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java
  38. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java
  39. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java
  40. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java
  41. +4
    -14
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java
  42. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java
  43. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java
  44. +3
    -3
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Copy.java
  45. +8
    -6
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Delete.java
  46. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Move.java
  47. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Touch.java
  48. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java
  49. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Cab.java
  50. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  51. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
  52. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java
  53. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
  54. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  55. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java
  56. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  57. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java
  58. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java
  59. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java
  60. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/security/SignJar.java
  61. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java
  62. +3
    -3
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java
  63. +53
    -228
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java
  64. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java
  65. +37
    -165
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java
  66. +5
    -11
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/ZipFileSet.java
  67. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/optional/depend/ClassfileSet.java

+ 2
- 2
proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java View File

@@ -259,12 +259,12 @@ public class XMLValidateTask
{ {


FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] files = ds.getIncludedFiles(); String[] files = ds.getIncludedFiles();


for( int j = 0; j < files.length; j++ ) for( int j = 0; j < files.length; j++ )
{ {
File srcFile = new File( fs.getDir( getProject() ), files[ j ] );
File srcFile = new File( fs.getDir(), files[ j ] );
doValidate( srcFile ); doValidate( srcFile );
fileProcessed++; fileProcessed++;
} }


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

@@ -473,11 +473,11 @@ public class Checksum extends MatchingTask implements Condition
for( int i = 0; i < sizeofFileSet; i++ ) for( int i = 0; i < sizeofFileSet; i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();
for( int j = 0; j < srcFiles.length; j++ ) for( int j = 0; j < srcFiles.length; j++ )
{ {
File src = new File( fs.getDir( getProject() ), srcFiles[ j ] );
File src = new File( fs.getDir(), srcFiles[ j ] );
addToIncludeFileMap( src ); addToIncludeFileMap( src );
} }
} }


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

@@ -154,13 +154,13 @@ public class DependSet extends MatchingTask
{ {


FileSet targetFS = (FileSet)enumTargetSets.next(); FileSet targetFS = (FileSet)enumTargetSets.next();
DirectoryScanner targetDS = targetFS.getDirectoryScanner( getProject() );
DirectoryScanner targetDS = targetFS.getDirectoryScanner();
String[] targetFiles = targetDS.getIncludedFiles(); String[] targetFiles = targetDS.getIncludedFiles();


for( int i = 0; i < targetFiles.length; i++ ) for( int i = 0; i < targetFiles.length; i++ )
{ {


File dest = new File( targetFS.getDir( getProject() ), targetFiles[ i ] );
File dest = new File( targetFS.getDir(), targetFiles[ i ] );
allTargets.add( dest ); allTargets.add( dest );


if( dest.lastModified() > now ) if( dest.lastModified() > now )
@@ -212,12 +212,12 @@ public class DependSet extends MatchingTask
{ {


FileSet sourceFS = (FileSet)enumSourceSets.next(); FileSet sourceFS = (FileSet)enumSourceSets.next();
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( getProject() );
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner();
String[] sourceFiles = sourceDS.getIncludedFiles(); String[] sourceFiles = sourceDS.getIncludedFiles();


for( int i = 0; upToDate && i < sourceFiles.length; i++ ) for( int i = 0; upToDate && i < sourceFiles.length; i++ )
{ {
File src = new File( sourceFS.getDir( getProject() ), sourceFiles[ i ] );
File src = new File( sourceFS.getDir(), sourceFiles[ i ] );


if( src.lastModified() > now ) if( src.lastModified() > now )
{ {


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

@@ -385,8 +385,8 @@ public class ExecuteOn extends ExecTask
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
File base = fs.getDir( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
File base = fs.getDir();
DirectoryScanner ds = fs.getDirectoryScanner();


if( !"dir".equals( type ) ) if( !"dir".equals( type ) )
{ {


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

@@ -131,8 +131,8 @@ public class Expand extends MatchingTask
for( int j = 0; j < filesets.size(); j++ ) for( int j = 0; j < filesets.size(); j++ )
{ {
FileSet fs = (FileSet)filesets.get( j ); FileSet fs = (FileSet)filesets.get( j );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
File fromDir = fs.getDir( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
File fromDir = fs.getDir();


String[] files = ds.getIncludedFiles(); String[] files = ds.getIncludedFiles();
for( int i = 0; i < files.length; ++i ) for( int i = 0; i < files.length; ++i )


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java View File

@@ -157,7 +157,7 @@ public abstract class MatchingTask extends Task
{ {
fileset.setDir( baseDir ); fileset.setDir( baseDir );
fileset.setDefaultexcludes( useDefaultExcludes ); fileset.setDefaultexcludes( useDefaultExcludes );
return fileset.getDirectoryScanner( getProject() );
return fileset.getDirectoryScanner();
} }


} }

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

@@ -407,8 +407,8 @@ public class SQLExec
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
File srcDir = fs.getDir( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
File srcDir = fs.getDir();


String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();




+ 4
- 14
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -129,7 +129,7 @@ public class Tar
} }


// add the main fileset to the list of filesets to process. // add the main fileset to the list of filesets to process.
TarFileSet mainFileSet = new TarFileSet( fileset );
TarFileSet mainFileSet = new TarFileSet( /*fileset*/ );
mainFileSet.setDir( baseDir ); mainFileSet.setDir( baseDir );
filesets.add( mainFileSet ); filesets.add( mainFileSet );
} }
@@ -154,7 +154,7 @@ public class Tar


for( int i = 0; i < files.length; ++i ) for( int i = 0; i < files.length; ++i )
{ {
if( tarFile.equals( new File( fs.getDir( getProject() ), files[ i ] ) ) )
if( tarFile.equals( new File( fs.getDir(), files[ i ] ) ) )
{ {
throw new TaskException( "A tar file cannot include itself" ); throw new TaskException( "A tar file cannot include itself" );
} }
@@ -196,7 +196,7 @@ public class Tar
String[] files = fs.getFiles( getProject() ); String[] files = fs.getFiles( getProject() );
for( int i = 0; i < files.length; i++ ) for( int i = 0; i < files.length; i++ )
{ {
File f = new File( fs.getDir( getProject() ), files[ i ] );
File f = new File( fs.getDir(), files[ i ] );
String name = files[ i ].replace( File.separatorChar, '/' ); String name = files[ i ].replace( File.separatorChar, '/' );
tarFile( f, tOut, name, fs ); tarFile( f, tOut, name, fs );
} }
@@ -322,16 +322,6 @@ public class Tar
private String userName = ""; private String userName = "";
private String groupName = ""; private String groupName = "";


public TarFileSet( FileSet fileset )
{
super( fileset );
}

public TarFileSet()
{
super();
}

public void setGroup( String groupName ) public void setGroup( String groupName )
{ {
this.groupName = groupName; this.groupName = groupName;
@@ -359,7 +349,7 @@ public class Tar
{ {
if( files == null ) if( files == null )
{ {
DirectoryScanner ds = getDirectoryScanner( p );
DirectoryScanner ds = getDirectoryScanner();
String[] directories = ds.getIncludedDirectories(); String[] directories = ds.getIncludedDirectories();
String[] filesPerSe = ds.getIncludedFiles(); String[] filesPerSe = ds.getIncludedFiles();
files = new String[ directories.length + filesPerSe.length ]; files = new String[ directories.length + filesPerSe.length ];


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

@@ -127,8 +127,8 @@ public class UpToDate extends MatchingTask implements Condition
while( upToDate && enum.hasNext() ) while( upToDate && enum.hasNext() )
{ {
FileSet fs = (FileSet)enum.next(); FileSet fs = (FileSet)enum.next();
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
upToDate = upToDate && scanDir( fs.getDir( getProject() ),
DirectoryScanner ds = fs.getDirectoryScanner();
upToDate = upToDate && scanDir( fs.getDir(),
ds.getIncludedFiles() ); ds.getIncludedFiles() );
} }
return upToDate; return upToDate;


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

@@ -264,7 +264,7 @@ public class Zip extends MatchingTask
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
dss.add( fs.getDirectoryScanner( getProject() ) );
dss.add( fs.getDirectoryScanner() );
} }
int dssSize = dss.size(); int dssSize = dss.size();
FileScanner[] scanners = new FileScanner[ dssSize ]; FileScanner[] scanners = new FileScanner[ dssSize ];
@@ -541,7 +541,7 @@ public class Zip extends MatchingTask
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();


String prefix = ""; String prefix = "";
String fullpath = ""; String fullpath = "";


+ 3
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java View File

@@ -229,8 +229,8 @@ public class Copy
for( int i = 0; i < m_filesets.size(); i++ ) for( int i = 0; i < m_filesets.size(); i++ )
{ {
final FileSet fileSet = (FileSet)m_filesets.get( i ); final FileSet fileSet = (FileSet)m_filesets.get( i );
final DirectoryScanner scanner = fileSet.getDirectoryScanner( getProject() );
final File fromDir = fileSet.getDir( getProject() );
final DirectoryScanner scanner = fileSet.getDirectoryScanner();
final File fromDir = fileSet.getDir();


final String[] srcFiles = scanner.getIncludedFiles(); final String[] srcFiles = scanner.getIncludedFiles();
final String[] srcDirs = scanner.getIncludedDirectories(); final String[] srcDirs = scanner.getIncludedDirectories();
@@ -486,7 +486,7 @@ public class Copy
else else
{ {
FileSet fs = (FileSet)m_filesets.get( 0 ); FileSet fs = (FileSet)m_filesets.get( 0 );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();


if( srcFiles.length > 0 ) if( srcFiles.length > 0 )


+ 8
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Delete.java View File

@@ -44,7 +44,7 @@ public class Delete
* *
* @param dir the directory path. * @param dir the directory path.
*/ */
public void setDir( File dir )
public void setDir( final File dir )
{ {
m_dir = dir; m_dir = dir;
} }
@@ -54,7 +54,7 @@ public class Delete
* *
* @param file the file to be deleted * @param file the file to be deleted
*/ */
public void setFile( File file )
public void setFile( final File file )
{ {
m_file = file; m_file = file;
} }
@@ -100,14 +100,16 @@ public class Delete
getLogger().info( "Deleting: " + m_file.getAbsolutePath() ); getLogger().info( "Deleting: " + m_file.getAbsolutePath() );
if( !m_file.delete() ) if( !m_file.delete() )
{ {
String message = "Unable to delete file " + m_file.getAbsolutePath();
final String message = "Unable to delete file " + m_file.getAbsolutePath();
throw new TaskException( message ); throw new TaskException( message );
} }
} }
} }
else else
{ {
getLogger().debug( "Could not find file " + m_file.getAbsolutePath() + " to delete." );
final String message =
"Could not find file " + m_file.getAbsolutePath() + " to delete.";
getLogger().debug( message );
} }
} }


@@ -124,10 +126,10 @@ public class Delete
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
try try
{ {
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] files = ds.getIncludedFiles(); String[] files = ds.getIncludedFiles();
String[] dirs = ds.getIncludedDirectories(); String[] dirs = ds.getIncludedDirectories();
removeFiles( fs.getDir( getProject() ), files, dirs );
removeFiles( fs.getDir(), files, dirs );
} }
catch( TaskException be ) catch( TaskException be )
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Move.java View File

@@ -205,7 +205,7 @@ public class Move
while( e.hasNext() ) while( e.hasNext() )
{ {
FileSet fs = (FileSet)e.next(); FileSet fs = (FileSet)e.next();
File dir = fs.getDir( getProject() );
File dir = fs.getDir();


if( okToDelete( dir ) ) if( okToDelete( dir ) )
{ {


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Touch.java View File

@@ -157,8 +157,8 @@ public class Touch
for( int i = 0; i < size; i++ ) for( int i = 0; i < size; i++ )
{ {
final FileSet fs = (FileSet)m_filesets.get( i ); final FileSet fs = (FileSet)m_filesets.get( i );
final DirectoryScanner ds = fs.getDirectoryScanner( null );
final File fromDir = fs.getDir( null );
final DirectoryScanner ds = fs.getDirectoryScanner();
final File fromDir = fs.getDir();


final String[] srcFiles = ds.getIncludedFiles(); final String[] srcFiles = ds.getIncludedFiles();
final String[] srcDirs = ds.getIncludedDirectories(); final String[] srcDirs = ds.getIncludedDirectories();


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java View File

@@ -1022,7 +1022,7 @@ public class Javadoc
final File source = resolveFile( list[ j ] ); final File source = resolveFile( list[ j ] );
fs.setDir( source ); fs.setDir( source );


final DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
final DirectoryScanner ds = fs.getDirectoryScanner();
final String[] packageDirs = ds.getIncludedDirectories(); final String[] packageDirs = ds.getIncludedDirectories();


for( int i = 0; i < packageDirs.length; i++ ) for( int i = 0; i < packageDirs.length; i++ )


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java View File

@@ -204,7 +204,7 @@ public class Cab extends MatchingTask
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
if( fs != null ) if( fs != null )
{ {
appendFiles( files, fs.getDirectoryScanner( getProject() ) );
appendFiles( files, fs.getDirectoryScanner() );
} }
} }
} }


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java View File

@@ -559,8 +559,8 @@ public class GenericDeploymentTool
for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); )
{ {
FileSet supportFileSet = (FileSet)i.next(); FileSet supportFileSet = (FileSet)i.next();
File supportBaseDir = supportFileSet.getDir( project );
DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner( project );
File supportBaseDir = supportFileSet.getDir();
DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner();
supportScanner.scan(); supportScanner.scan();
String[] supportFiles = supportScanner.getIncludedFiles(); String[] supportFiles = supportScanner.getIncludedFiles();
for( int j = 0; j < supportFiles.length; ++j ) for( int j = 0; j < supportFiles.length; ++j )


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java View File

@@ -518,7 +518,7 @@ public class Translate
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();
for( int j = 0; j < srcFiles.length; j++ ) for( int j = 0; j < srcFiles.length; j++ )
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java View File

@@ -224,7 +224,7 @@ public class VAJImport extends VAJTask
*/ */
protected void importFileset( FileSet fileset ) protected void importFileset( FileSet fileset )
{ {
DirectoryScanner ds = fileset.getDirectoryScanner( this.getProject() );
DirectoryScanner ds = fileset.getDirectoryScanner();
if( ds.getIncludedFiles().length == 0 ) if( ds.getIncludedFiles().length == 0 )
{ {
return; return;


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java View File

@@ -127,7 +127,7 @@ public final class BatchTest extends BaseTest
for( int j = 0; j < size; j++ ) for( int j = 0; j < size; j++ )
{ {
FileSet fs = (FileSet)filesets.get( j ); FileSet fs = (FileSet)filesets.get( j );
DirectoryScanner ds = fs.getDirectoryScanner( project );
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan(); ds.scan();
String[] f = ds.getIncludedFiles(); String[] f = ds.getIncludedFiles();
for( int k = 0; k < f.length; k++ ) for( int k = 0; k < f.length; k++ )


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java View File

@@ -200,7 +200,7 @@ public class XMLResultAggregator extends Task implements XMLConstants
for( int i = 0; i < size; i++ ) for( int i = 0; i < size; i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan(); ds.scan();
String[] f = ds.getIncludedFiles(); String[] f = ds.getIncludedFiles();
for( int j = 0; j < f.length; j++ ) for( int j = 0; j < f.length; j++ )


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java View File

@@ -365,7 +365,7 @@ public abstract class AbstractMetamataTask extends Task
for( int i = 0; i < fileSets.size(); i++ ) for( int i = 0; i < fileSets.size(); i++ )
{ {
FileSet fs = (FileSet)fileSets.get( i ); FileSet fs = (FileSet)fileSets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan(); ds.scan();
String[] f = ds.getIncludedFiles(); String[] f = ds.getIncludedFiles();
getLogger().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() ); getLogger().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() );


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -792,12 +792,12 @@ public class FTP


if( action == SEND_FILES ) if( action == SEND_FILES )
{ {
ds = fs.getDirectoryScanner( getProject() );
ds = fs.getDirectoryScanner();
} }
else else
{ {
ds = new FTPDirectoryScanner( ftp ); ds = new FTPDirectoryScanner( ftp );
fs.setupDirectoryScanner( ds, getProject() );
fs.setupDirectoryScanner( ds );
ds.scan(); ds.scan();
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java View File

@@ -307,7 +307,7 @@ public class MimeMail extends Task
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
if( fs != null ) if( fs != null )
{ {
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] dsfiles = ds.getIncludedFiles(); String[] dsfiles = ds.getIncludedFiles();
File baseDir = ds.getBasedir(); File baseDir = ds.getBasedir();




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java View File

@@ -123,7 +123,7 @@ public class P4Add extends P4Base
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
//File fromDir = fs.getDir(project); //File fromDir = fs.getDir(project);


String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java View File

@@ -152,7 +152,7 @@ public class CovMerge extends Task
for( int i = 0; i < size; i++ ) for( int i = 0; i < size; i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan(); ds.scan();
String[] f = ds.getIncludedFiles(); String[] f = ds.getIncludedFiles();
for( int j = 0; j < f.length; j++ ) for( int j = 0; j < f.length; j++ )


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/security/SignJar.java View File

@@ -151,12 +151,12 @@ public class SignJar
for( int i = 0; i < m_filesets.size(); i++ ) for( int i = 0; i < m_filesets.size(); i++ )
{ {
final FileSet fileSet = (FileSet)m_filesets.get( i ); final FileSet fileSet = (FileSet)m_filesets.get( i );
final DirectoryScanner scanner = fileSet.getDirectoryScanner( null );
final DirectoryScanner scanner = fileSet.getDirectoryScanner();
final String[] jarFiles = scanner.getIncludedFiles(); final String[] jarFiles = scanner.getIncludedFiles();
for( int j = 0; j < jarFiles.length; j++ ) for( int j = 0; j < jarFiles.length; j++ )
{ {
final File file = final File file =
new File( fileSet.getDir( null ), jarFiles[ j ] );
new File( fileSet.getDir(), jarFiles[ j ] );
doOneJar( file, null ); doOneJar( file, null );
} }
} }


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java View File

@@ -205,7 +205,7 @@ public class ReplaceRegExp extends Task
for( int i = 0; i < sz; i++ ) for( int i = 0; i < sz; i++ )
{ {
FileSet fs = (FileSet)( filesets.get( i ) ); FileSet fs = (FileSet)( filesets.get( i ) );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();


String files[] = ds.getIncludedFiles(); String files[] = ds.getIncludedFiles();
for( int j = 0; j < files.length; j++ ) for( int j = 0; j < files.length; j++ )


+ 3
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java View File

@@ -152,14 +152,14 @@ public class Chmod extends ExecuteOn
public void execute() public void execute()
throws TaskException throws TaskException
{ {
if( defaultSetDefined || defaultSet.getDir( getProject() ) == null )
if( defaultSetDefined || defaultSet.getDir() == null )
{ {
super.execute(); super.execute();
} }
else if( isValidOs() ) else if( isValidOs() )
{ {
// we are chmodding the given directory // we are chmodding the given directory
createArg().setValue( defaultSet.getDir( getProject() ).getPath() );
createArg().setValue( defaultSet.getDir().getPath() );
Execute execute = prepareExec(); Execute execute = prepareExec();
try try
{ {
@@ -191,7 +191,7 @@ public class Chmod extends ExecuteOn
throw new TaskException( "Required attribute perm not set in chmod" ); throw new TaskException( "Required attribute perm not set in chmod" );
} }


if( defaultSetDefined && defaultSet.getDir( getProject() ) != null )
if( defaultSetDefined && defaultSet.getDir() != null )
{ {
addFileset( defaultSet ); addFileset( defaultSet );
} }


+ 53
- 228
proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java View File

@@ -9,11 +9,9 @@ package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Stack;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.FileScanner; import org.apache.tools.ant.FileScanner;
import org.apache.tools.ant.Project;


/** /**
* Moved out of MatchingTask to make it a standalone object that could be * Moved out of MatchingTask to make it a standalone object that could be
@@ -31,64 +29,36 @@ public class FileSet
extends DataType extends DataType
implements Cloneable implements Cloneable
{ {
private PatternSet defaultPatterns = new PatternSet();
private ArrayList additionalPatterns = new ArrayList();
private boolean useDefaultExcludes = true;
private boolean isCaseSensitive = true;

private File dir;
private PatternSet m_defaultPatterns = new PatternSet();
private ArrayList m_additionalPatterns = new ArrayList();
private boolean m_useDefaultExcludes = true;
private boolean m_isCaseSensitive = true;
private File m_dir;


public FileSet() public FileSet()
{ {
super();
}

protected FileSet( FileSet fileset )
{
this.dir = fileset.dir;
this.defaultPatterns = fileset.defaultPatterns;
this.additionalPatterns = fileset.additionalPatterns;
this.useDefaultExcludes = fileset.useDefaultExcludes;
this.isCaseSensitive = fileset.isCaseSensitive;
} }


/** /**
* Sets case sensitivity of the file system * Sets case sensitivity of the file system
*
* @param isCaseSensitive "true"|"on"|"yes" if file system is case
* sensitive, "false"|"off"|"no" when not.
*/ */
public void setCaseSensitive( boolean isCaseSensitive )
public void setCaseSensitive( final boolean isCaseSensitive )
{ {
this.isCaseSensitive = isCaseSensitive;
m_isCaseSensitive = isCaseSensitive;
} }


/** /**
* Sets whether default exclusions should be used or not. * Sets whether default exclusions should be used or not.
*
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
* should be used, "false"|"off"|"no" when they shouldn't be used.
*/ */
public void setDefaultexcludes( boolean useDefaultExcludes )
throws TaskException
public void setDefaultexcludes( final boolean useDefaultExcludes )
{ {
if( isReference() )
{
throw tooManyAttributes();
}

this.useDefaultExcludes = useDefaultExcludes;
m_useDefaultExcludes = useDefaultExcludes;
} }


public void setDir( File dir )
public void setDir( final File dir )
throws TaskException throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}

this.dir = dir;
m_dir = dir;
} }


/** /**
@@ -97,32 +67,19 @@ public class FileSet
* *
* @param excludes the string containing the exclude patterns * @param excludes the string containing the exclude patterns
*/ */
public void setExcludes( String excludes )
throws TaskException
public void setExcludes( final String excludes )
{ {
if( isReference() )
{
throw tooManyAttributes();
}

defaultPatterns.setExcludes( excludes );
m_defaultPatterns.setExcludes( excludes );
} }


/** /**
* Sets the name of the file containing the includes patterns. * Sets the name of the file containing the includes patterns.
* *
* @param excl The file to fetch the exclude patterns from. * @param excl The file to fetch the exclude patterns from.
* @exception TaskException Description of Exception
*/ */
public void setExcludesfile( File excl )
throws TaskException
public void setExcludesfile( final File excl )
{ {
if( isReference() )
{
throw tooManyAttributes();
}

defaultPatterns.setExcludesfile( excl );
m_defaultPatterns.setExcludesfile( excl );
} }


/** /**
@@ -132,250 +89,118 @@ public class FileSet
* @param includes the string containing the include patterns * @param includes the string containing the include patterns
*/ */
public void setIncludes( String includes ) public void setIncludes( String includes )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}

defaultPatterns.setIncludes( includes );
m_defaultPatterns.setIncludes( includes );
} }


/** /**
* Sets the name of the file containing the includes patterns. * Sets the name of the file containing the includes patterns.
* *
* @param incl The file to fetch the include patterns from. * @param incl The file to fetch the include patterns from.
* @exception TaskException Description of Exception
*/ */
public void setIncludesfile( File incl ) public void setIncludesfile( File incl )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}

defaultPatterns.setIncludesfile( incl );
m_defaultPatterns.setIncludesfile( incl );
} }


/**
* Makes this instance in effect a reference to another PatternSet instance.
* <p>
*
* You must not set another attribute or nest elements inside this element
* if you make it a reference.</p>
*
* @param r The new Refid value
* @exception TaskException Description of Exception
*/
public void setRefid( Reference r )
public void setupDirectoryScanner( final FileScanner ds )
throws TaskException throws TaskException
{ {
if( dir != null || defaultPatterns.hasPatterns() )
if( null == ds )
{ {
throw tooManyAttributes();
final String message = "ds cannot be null";
throw new IllegalArgumentException( message );
} }
if( !additionalPatterns.isEmpty() )
{
throw noChildrenAllowed();
}
super.setRefid( r );
}


public void setupDirectoryScanner( FileScanner ds, Project p )
throws TaskException
{
if( ds == null )
{
throw new IllegalArgumentException( "ds cannot be null" );
}

ds.setBasedir( dir );
ds.setBasedir( m_dir );


for( int i = 0; i < additionalPatterns.size(); i++ )
final int size = m_additionalPatterns.size();
for( int i = 0; i < size; i++ )
{ {
Object o = additionalPatterns.get( i );
defaultPatterns.append( (PatternSet)o, p );
final Object o = m_additionalPatterns.get( i );
m_defaultPatterns.append( (PatternSet)o );
} }


getLogger().debug( "FileSet: Setup file scanner in dir " + dir + " with " + defaultPatterns );
final String message = "FileSet: Setup file scanner in dir " +
m_dir + " with " + m_defaultPatterns;
getLogger().debug( message );


ds.setIncludes( defaultPatterns.getIncludePatterns( p ) );
ds.setExcludes( defaultPatterns.getExcludePatterns( p ) );
if( useDefaultExcludes )
ds.setIncludes( m_defaultPatterns.getIncludePatterns( null ) );
ds.setExcludes( m_defaultPatterns.getExcludePatterns( null ) );
if( m_useDefaultExcludes )
{
ds.addDefaultExcludes(); ds.addDefaultExcludes();
ds.setCaseSensitive( isCaseSensitive );
}
ds.setCaseSensitive( m_isCaseSensitive );
} }


public File getDir( Project p )
throws TaskException
public File getDir()
{ {
if( isReference() )
{
return getRef( p ).getDir( p );
}
return dir;
return m_dir;
} }


/** /**
* Returns the directory scanner needed to access the files to process. * Returns the directory scanner needed to access the files to process.
*
* @param p Description of Parameter
* @return The DirectoryScanner value
*/ */
public DirectoryScanner getDirectoryScanner( Project p )
public DirectoryScanner getDirectoryScanner()
throws TaskException throws TaskException
{ {
if( isReference() )
{
return getRef( p ).getDirectoryScanner( p );
}

if( dir == null )
if( m_dir == null )
{ {
throw new TaskException( "No directory specified for fileset." ); throw new TaskException( "No directory specified for fileset." );
} }


if( !dir.exists() )
if( !m_dir.exists() )
{ {
throw new TaskException( dir.getAbsolutePath() + " not found." );
throw new TaskException( m_dir.getAbsolutePath() + " not found." );
} }
if( !dir.isDirectory() )
if( !m_dir.isDirectory() )
{ {
throw new TaskException( dir.getAbsolutePath() + " is not a directory." );
throw new TaskException( m_dir.getAbsolutePath() + " is not a directory." );
} }


DirectoryScanner ds = new DirectoryScanner();
setupDirectoryScanner( ds, p );
ds.scan();
return ds;
}

/**
* Return a FileSet that has the same basedir and same patternsets as this
* one.
*
* @return Description of the Returned Value
*/
public Object clone()
{
try
{
if( isReference() )
{
return new FileSet( getRef( getProject() ) );
}
else
{
return new FileSet( this );
}
}
catch( TaskException e )
{
throw new IllegalStateException( e.getMessage() );
}
final DirectoryScanner scanner = new DirectoryScanner();
setupDirectoryScanner( scanner );
scanner.scan();
return scanner;
} }


/** /**
* add a name entry on the exclude list * add a name entry on the exclude list
*
* @return Description of the Returned Value
*/ */
public PatternSet.NameEntry createExclude() public PatternSet.NameEntry createExclude()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return defaultPatterns.createExclude();
return m_defaultPatterns.createExclude();
} }


/** /**
* add a name entry on the include files list * add a name entry on the include files list
*
* @return Description of the Returned Value
*/ */
public PatternSet.NameEntry createExcludesFile() public PatternSet.NameEntry createExcludesFile()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return defaultPatterns.createExcludesFile();
return m_defaultPatterns.createExcludesFile();
} }


/** /**
* add a name entry on the include list * add a name entry on the include list
*
* @return Description of the Returned Value
*/ */
public PatternSet.NameEntry createInclude() public PatternSet.NameEntry createInclude()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return defaultPatterns.createInclude();
return m_defaultPatterns.createInclude();
} }


/** /**
* add a name entry on the include files list * add a name entry on the include files list
*
* @return Description of the Returned Value
*/ */
public PatternSet.NameEntry createIncludesFile() public PatternSet.NameEntry createIncludesFile()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return defaultPatterns.createIncludesFile();
return m_defaultPatterns.createIncludesFile();
} }


public PatternSet createPatternSet() public PatternSet createPatternSet()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
PatternSet patterns = new PatternSet();
additionalPatterns.add( patterns );
final PatternSet patterns = new PatternSet();
m_additionalPatterns.add( patterns );
return patterns; return patterns;
} }

/**
* Performs the check for circular references and returns the referenced
* FileSet.
*
* @param p Description of Parameter
* @return The Ref value
*/
protected FileSet getRef( Project p )
throws TaskException
{
if( !checked )
{
Stack stk = new Stack();
stk.push( this );
dieOnCircularReference( stk, p );
}

Object o = ref.getReferencedObject( p );
if( !( o instanceof FileSet ) )
{
String msg = ref.getRefId() + " doesn\'t denote a fileset";
throw new TaskException( msg );
}
else
{
return (FileSet)o;
}
}

} }

+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java View File

@@ -588,9 +588,9 @@ public class Path
else if( o instanceof FileSet ) else if( o instanceof FileSet )
{ {
FileSet fs = (FileSet)o; FileSet fs = (FileSet)o;
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] s = ds.getIncludedFiles(); String[] s = ds.getIncludedFiles();
File dir = fs.getDir( getProject() );
File dir = fs.getDir();
for( int j = 0; j < s.length; j++ ) for( int j = 0; j < s.length; j++ )
{ {
File f = new File( dir, s[ j ] ); File f = new File( dir, s[ j ] );


+ 37
- 165
proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java View File

@@ -13,7 +13,6 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Stack;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
@@ -31,12 +30,13 @@ import org.apache.tools.ant.Project;
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/ */
public class PatternSet extends DataType
public class PatternSet
extends DataType
{ {
private ArrayList includeList = new ArrayList();
private ArrayList excludeList = new ArrayList();
private ArrayList includesFileList = new ArrayList();
private ArrayList excludesFileList = new ArrayList();
private ArrayList m_includeList = new ArrayList();
private ArrayList m_excludeList = new ArrayList();
private ArrayList m_includesFileList = new ArrayList();
private ArrayList m_excludesFileList = new ArrayList();


public PatternSet() public PatternSet()
{ {
@@ -50,12 +50,7 @@ public class PatternSet extends DataType
* @param excludes the string containing the exclude patterns * @param excludes the string containing the exclude patterns
*/ */
public void setExcludes( String excludes ) public void setExcludes( String excludes )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}
if( excludes != null && excludes.length() > 0 ) if( excludes != null && excludes.length() > 0 )
{ {
StringTokenizer tok = new StringTokenizer( excludes, ", ", false ); StringTokenizer tok = new StringTokenizer( excludes, ", ", false );
@@ -73,12 +68,7 @@ public class PatternSet extends DataType
* @exception TaskException Description of Exception * @exception TaskException Description of Exception
*/ */
public void setExcludesfile( File excludesFile ) public void setExcludesfile( File excludesFile )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}
createExcludesFile().setName( excludesFile.getAbsolutePath() ); createExcludesFile().setName( excludesFile.getAbsolutePath() );
} }


@@ -89,12 +79,7 @@ public class PatternSet extends DataType
* @param includes the string containing the include patterns * @param includes the string containing the include patterns
*/ */
public void setIncludes( String includes ) public void setIncludes( String includes )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}
if( includes != null && includes.length() > 0 ) if( includes != null && includes.length() > 0 )
{ {
StringTokenizer tok = new StringTokenizer( includes, ", ", false ); StringTokenizer tok = new StringTokenizer( includes, ", ", false );
@@ -112,53 +97,18 @@ public class PatternSet extends DataType
* @exception TaskException Description of Exception * @exception TaskException Description of Exception
*/ */
public void setIncludesfile( File includesFile ) public void setIncludesfile( File includesFile )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}
createIncludesFile().setName( includesFile.getAbsolutePath() ); createIncludesFile().setName( includesFile.getAbsolutePath() );
} }


/**
* Makes this instance in effect a reference to another PatternSet instance.
* <p>
*
* You must not set another attribute or nest elements inside this element
* if you make it a reference.</p>
*
* @param r The new Refid value
* @exception TaskException Description of Exception
*/
public void setRefid( Reference r )
throws TaskException
{
if( !includeList.isEmpty() || !excludeList.isEmpty() )
{
throw tooManyAttributes();
}
super.setRefid( r );
}

/** /**
* Returns the filtered include patterns. * Returns the filtered include patterns.
*
* @param p Description of Parameter
* @return The ExcludePatterns value
*/ */
public String[] getExcludePatterns( Project p ) public String[] getExcludePatterns( Project p )
throws TaskException throws TaskException
{ {
if( isReference() )
{
return getRef( p ).getExcludePatterns( p );
}
else
{
readFiles( p );
return makeArray( excludeList, p );
}
readFiles( p );
return makeArray( m_excludeList );
} }


/** /**
@@ -170,32 +120,17 @@ public class PatternSet extends DataType
public String[] getIncludePatterns( Project p ) public String[] getIncludePatterns( Project p )
throws TaskException throws TaskException
{ {
if( isReference() )
{
return getRef( p ).getIncludePatterns( p );
}
else
{
readFiles( p );
return makeArray( includeList, p );
}
readFiles( p );
return makeArray( m_includeList );
} }


/** /**
* Adds the patterns of the other instance to this set. * Adds the patterns of the other instance to this set.
*
* @param other Description of Parameter
* @param p Description of Parameter
*/ */
public void append( PatternSet other, Project p )
protected void append( PatternSet other )
throws TaskException throws TaskException
{ {
if( isReference() )
{
throw new TaskException( "Cannot append to a reference" );
}

String[] incl = other.getIncludePatterns( p );
String[] incl = other.getIncludePatterns( null );
if( incl != null ) if( incl != null )
{ {
for( int i = 0; i < incl.length; i++ ) for( int i = 0; i < incl.length; i++ )
@@ -204,7 +139,7 @@ public class PatternSet extends DataType
} }
} }


String[] excl = other.getExcludePatterns( p );
String[] excl = other.getExcludePatterns( null );
if( excl != null ) if( excl != null )
{ {
for( int i = 0; i < excl.length; i++ ) for( int i = 0; i < excl.length; i++ )
@@ -220,13 +155,8 @@ public class PatternSet extends DataType
* @return Description of the Returned Value * @return Description of the Returned Value
*/ */
public NameEntry createExclude() public NameEntry createExclude()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return addPatternToList( excludeList );
return addPatternToList( m_excludeList );
} }


/** /**
@@ -235,121 +165,66 @@ public class PatternSet extends DataType
* @return Description of the Returned Value * @return Description of the Returned Value
*/ */
public NameEntry createExcludesFile() public NameEntry createExcludesFile()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return addPatternToList( excludesFileList );
return addPatternToList( m_excludesFileList );
} }


/** /**
* add a name entry on the include list * add a name entry on the include list
*
* @return Description of the Returned Value
*/ */
public NameEntry createInclude() public NameEntry createInclude()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return addPatternToList( includeList );
return addPatternToList( m_includeList );
} }


/** /**
* add a name entry on the include files list * add a name entry on the include files list
*
* @return Description of the Returned Value
*/ */
public NameEntry createIncludesFile() public NameEntry createIncludesFile()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return addPatternToList( includesFileList );
return addPatternToList( m_includesFileList );
} }


public String toString() public String toString()
{ {
return "patternSet{ includes: " + includeList +
" excludes: " + excludeList + " }";
return "patternSet{ includes: " + m_includeList +
" excludes: " + m_excludeList + " }";
} }


/** /**
* helper for FileSet. * helper for FileSet.
*
* @return Description of the Returned Value
*/ */
boolean hasPatterns() boolean hasPatterns()
{ {
return includesFileList.size() > 0 || excludesFileList.size() > 0
|| includeList.size() > 0 || excludeList.size() > 0;
}

/**
* Performs the check for circular references and returns the referenced
* PatternSet.
*
* @param p Description of Parameter
* @return The Ref value
*/
private PatternSet getRef( Project p )
throws TaskException
{
if( !checked )
{
Stack stk = new Stack();
stk.push( this );
dieOnCircularReference( stk, p );
}

Object o = ref.getReferencedObject( p );
if( !( o instanceof PatternSet ) )
{
String msg = ref.getRefId() + " doesn\'t denote a patternset";
throw new TaskException( msg );
}
else
{
return (PatternSet)o;
}
return m_includesFileList.size() > 0 || m_excludesFileList.size() > 0 ||
m_includeList.size() > 0 || m_excludeList.size() > 0;
} }


/** /**
* add a name entry to the given list * add a name entry to the given list
*
* @param list The feature to be added to the PatternToList attribute
* @return Description of the Returned Value
*/ */
private NameEntry addPatternToList( ArrayList list )
private NameEntry addPatternToList( final ArrayList list )
{ {
NameEntry result = new NameEntry();
final NameEntry result = new NameEntry();
list.add( result ); list.add( result );
return result; return result;
} }


/** /**
* Convert a vector of NameEntry elements into an array of Strings. * Convert a vector of NameEntry elements into an array of Strings.
*
* @param list Description of Parameter
* @param p Description of Parameter
* @return Description of the Returned Value
*/ */
private String[] makeArray( ArrayList list, Project p )
private String[] makeArray( final ArrayList list )
{ {
if( list.size() == 0 ) if( list.size() == 0 )
{
return null; return null;
}


ArrayList tmpNames = new ArrayList();
final ArrayList tmpNames = new ArrayList();
for( Iterator e = list.iterator(); e.hasNext(); ) for( Iterator e = list.iterator(); e.hasNext(); )
{ {
NameEntry ne = (NameEntry)e.next();
String pattern = ne.evalName( p );
final NameEntry ne = (NameEntry)e.next();
final String pattern = ne.evalName( null );
if( pattern != null && pattern.length() > 0 ) if( pattern != null && pattern.length() > 0 )
{ {
tmpNames.add( pattern ); tmpNames.add( pattern );
@@ -362,15 +237,13 @@ public class PatternSet extends DataType


/** /**
* Read includesfile ot excludesfile if not already done so. * Read includesfile ot excludesfile if not already done so.
*
* @param p Description of Parameter
*/ */
private void readFiles( Project p ) private void readFiles( Project p )
throws TaskException throws TaskException
{ {
if( includesFileList.size() > 0 )
if( m_includesFileList.size() > 0 )
{ {
Iterator e = includesFileList.iterator();
Iterator e = m_includesFileList.iterator();
while( e.hasNext() ) while( e.hasNext() )
{ {
NameEntry ne = (NameEntry)e.next(); NameEntry ne = (NameEntry)e.next();
@@ -382,15 +255,15 @@ public class PatternSet extends DataType
throw new TaskException( "Includesfile " throw new TaskException( "Includesfile "
+ inclFile.getAbsolutePath() + inclFile.getAbsolutePath()
+ " not found." ); + " not found." );
readPatterns( inclFile, includeList, p );
readPatterns( inclFile, m_includeList, p );
} }
} }
includesFileList.clear();
m_includesFileList.clear();
} }


if( excludesFileList.size() > 0 )
if( m_excludesFileList.size() > 0 )
{ {
Iterator e = excludesFileList.iterator();
Iterator e = m_excludesFileList.iterator();
while( e.hasNext() ) while( e.hasNext() )
{ {
NameEntry ne = (NameEntry)e.next(); NameEntry ne = (NameEntry)e.next();
@@ -402,10 +275,10 @@ public class PatternSet extends DataType
throw new TaskException( "Excludesfile " throw new TaskException( "Excludesfile "
+ exclFile.getAbsolutePath() + exclFile.getAbsolutePath()
+ " not found." ); + " not found." );
readPatterns( exclFile, excludeList, p );
readPatterns( exclFile, m_excludeList, p );
} }
} }
excludesFileList.clear();
m_excludesFileList.clear();
} }
} }


@@ -538,5 +411,4 @@ public class PatternSet extends DataType
return true; return true;
} }
} }

} }

+ 5
- 11
proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java View File

@@ -38,16 +38,14 @@ public class ZipFileSet
/** /**
* Set the directory for the fileset. Prevents both "dir" and "src" from * Set the directory for the fileset. Prevents both "dir" and "src" from
* being specified. * being specified.
*
* @param dir The new Dir value
* @exception TaskException Description of Exception
*/ */
public void setDir( File dir )
public void setDir( final File dir )
throws TaskException throws TaskException
{ {
if( srcFile != null ) if( srcFile != null )
{ {
throw new TaskException( "Cannot set both dir and src attributes" );
final String message = "Cannot set both dir and src attributes";
throw new TaskException( message );
} }
else else
{ {
@@ -104,22 +102,18 @@ public class ZipFileSet
public DirectoryScanner getDirectoryScanner( Project p ) public DirectoryScanner getDirectoryScanner( Project p )
throws TaskException throws TaskException
{ {
if( isReference() )
{
return getRef( p ).getDirectoryScanner( p );
}
if( srcFile != null ) if( srcFile != null )
{ {
ZipScanner zs = new ZipScanner(); ZipScanner zs = new ZipScanner();
zs.setSrc( srcFile ); zs.setSrc( srcFile );
super.setDir( p.getBaseDir() ); super.setDir( p.getBaseDir() );
setupDirectoryScanner( zs, p );
setupDirectoryScanner( zs );
zs.init(); zs.init();
return zs; return zs;
} }
else else
{ {
return super.getDirectoryScanner( p );
return super.getDirectoryScanner();
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java View File

@@ -47,7 +47,7 @@ public class ClassfileSet extends FileSet
public DirectoryScanner getDirectoryScanner( Project p ) public DirectoryScanner getDirectoryScanner( Project p )
{ {
DependScanner scanner = new DependScanner(); DependScanner scanner = new DependScanner();
scanner.setBasedir( getDir( p ) );
scanner.setBasedir( getDir() );
scanner.setRootClasses( rootClasses ); scanner.setRootClasses( rootClasses );
scanner.scan(); scanner.scan();
return scanner; return scanner;


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

@@ -473,11 +473,11 @@ public class Checksum extends MatchingTask implements Condition
for( int i = 0; i < sizeofFileSet; i++ ) for( int i = 0; i < sizeofFileSet; i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();
for( int j = 0; j < srcFiles.length; j++ ) for( int j = 0; j < srcFiles.length; j++ )
{ {
File src = new File( fs.getDir( getProject() ), srcFiles[ j ] );
File src = new File( fs.getDir(), srcFiles[ j ] );
addToIncludeFileMap( src ); addToIncludeFileMap( src );
} }
} }


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

@@ -154,13 +154,13 @@ public class DependSet extends MatchingTask
{ {


FileSet targetFS = (FileSet)enumTargetSets.next(); FileSet targetFS = (FileSet)enumTargetSets.next();
DirectoryScanner targetDS = targetFS.getDirectoryScanner( getProject() );
DirectoryScanner targetDS = targetFS.getDirectoryScanner();
String[] targetFiles = targetDS.getIncludedFiles(); String[] targetFiles = targetDS.getIncludedFiles();


for( int i = 0; i < targetFiles.length; i++ ) for( int i = 0; i < targetFiles.length; i++ )
{ {


File dest = new File( targetFS.getDir( getProject() ), targetFiles[ i ] );
File dest = new File( targetFS.getDir(), targetFiles[ i ] );
allTargets.add( dest ); allTargets.add( dest );


if( dest.lastModified() > now ) if( dest.lastModified() > now )
@@ -212,12 +212,12 @@ public class DependSet extends MatchingTask
{ {


FileSet sourceFS = (FileSet)enumSourceSets.next(); FileSet sourceFS = (FileSet)enumSourceSets.next();
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( getProject() );
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner();
String[] sourceFiles = sourceDS.getIncludedFiles(); String[] sourceFiles = sourceDS.getIncludedFiles();


for( int i = 0; upToDate && i < sourceFiles.length; i++ ) for( int i = 0; upToDate && i < sourceFiles.length; i++ )
{ {
File src = new File( sourceFS.getDir( getProject() ), sourceFiles[ i ] );
File src = new File( sourceFS.getDir(), sourceFiles[ i ] );


if( src.lastModified() > now ) if( src.lastModified() > now )
{ {


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

@@ -385,8 +385,8 @@ public class ExecuteOn extends ExecTask
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
File base = fs.getDir( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
File base = fs.getDir();
DirectoryScanner ds = fs.getDirectoryScanner();


if( !"dir".equals( type ) ) if( !"dir".equals( type ) )
{ {


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

@@ -131,8 +131,8 @@ public class Expand extends MatchingTask
for( int j = 0; j < filesets.size(); j++ ) for( int j = 0; j < filesets.size(); j++ )
{ {
FileSet fs = (FileSet)filesets.get( j ); FileSet fs = (FileSet)filesets.get( j );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
File fromDir = fs.getDir( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
File fromDir = fs.getDir();


String[] files = ds.getIncludedFiles(); String[] files = ds.getIncludedFiles();
for( int i = 0; i < files.length; ++i ) for( int i = 0; i < files.length; ++i )


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java View File

@@ -157,7 +157,7 @@ public abstract class MatchingTask extends Task
{ {
fileset.setDir( baseDir ); fileset.setDir( baseDir );
fileset.setDefaultexcludes( useDefaultExcludes ); fileset.setDefaultexcludes( useDefaultExcludes );
return fileset.getDirectoryScanner( getProject() );
return fileset.getDirectoryScanner();
} }


} }

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

@@ -407,8 +407,8 @@ public class SQLExec
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
File srcDir = fs.getDir( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
File srcDir = fs.getDir();


String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();




+ 4
- 14
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -129,7 +129,7 @@ public class Tar
} }


// add the main fileset to the list of filesets to process. // add the main fileset to the list of filesets to process.
TarFileSet mainFileSet = new TarFileSet( fileset );
TarFileSet mainFileSet = new TarFileSet( /*fileset*/ );
mainFileSet.setDir( baseDir ); mainFileSet.setDir( baseDir );
filesets.add( mainFileSet ); filesets.add( mainFileSet );
} }
@@ -154,7 +154,7 @@ public class Tar


for( int i = 0; i < files.length; ++i ) for( int i = 0; i < files.length; ++i )
{ {
if( tarFile.equals( new File( fs.getDir( getProject() ), files[ i ] ) ) )
if( tarFile.equals( new File( fs.getDir(), files[ i ] ) ) )
{ {
throw new TaskException( "A tar file cannot include itself" ); throw new TaskException( "A tar file cannot include itself" );
} }
@@ -196,7 +196,7 @@ public class Tar
String[] files = fs.getFiles( getProject() ); String[] files = fs.getFiles( getProject() );
for( int i = 0; i < files.length; i++ ) for( int i = 0; i < files.length; i++ )
{ {
File f = new File( fs.getDir( getProject() ), files[ i ] );
File f = new File( fs.getDir(), files[ i ] );
String name = files[ i ].replace( File.separatorChar, '/' ); String name = files[ i ].replace( File.separatorChar, '/' );
tarFile( f, tOut, name, fs ); tarFile( f, tOut, name, fs );
} }
@@ -322,16 +322,6 @@ public class Tar
private String userName = ""; private String userName = "";
private String groupName = ""; private String groupName = "";


public TarFileSet( FileSet fileset )
{
super( fileset );
}

public TarFileSet()
{
super();
}

public void setGroup( String groupName ) public void setGroup( String groupName )
{ {
this.groupName = groupName; this.groupName = groupName;
@@ -359,7 +349,7 @@ public class Tar
{ {
if( files == null ) if( files == null )
{ {
DirectoryScanner ds = getDirectoryScanner( p );
DirectoryScanner ds = getDirectoryScanner();
String[] directories = ds.getIncludedDirectories(); String[] directories = ds.getIncludedDirectories();
String[] filesPerSe = ds.getIncludedFiles(); String[] filesPerSe = ds.getIncludedFiles();
files = new String[ directories.length + filesPerSe.length ]; files = new String[ directories.length + filesPerSe.length ];


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

@@ -127,8 +127,8 @@ public class UpToDate extends MatchingTask implements Condition
while( upToDate && enum.hasNext() ) while( upToDate && enum.hasNext() )
{ {
FileSet fs = (FileSet)enum.next(); FileSet fs = (FileSet)enum.next();
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
upToDate = upToDate && scanDir( fs.getDir( getProject() ),
DirectoryScanner ds = fs.getDirectoryScanner();
upToDate = upToDate && scanDir( fs.getDir(),
ds.getIncludedFiles() ); ds.getIncludedFiles() );
} }
return upToDate; return upToDate;


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

@@ -264,7 +264,7 @@ public class Zip extends MatchingTask
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
dss.add( fs.getDirectoryScanner( getProject() ) );
dss.add( fs.getDirectoryScanner() );
} }
int dssSize = dss.size(); int dssSize = dss.size();
FileScanner[] scanners = new FileScanner[ dssSize ]; FileScanner[] scanners = new FileScanner[ dssSize ];
@@ -541,7 +541,7 @@ public class Zip extends MatchingTask
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();


String prefix = ""; String prefix = "";
String fullpath = ""; String fullpath = "";


+ 3
- 3
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Copy.java View File

@@ -229,8 +229,8 @@ public class Copy
for( int i = 0; i < m_filesets.size(); i++ ) for( int i = 0; i < m_filesets.size(); i++ )
{ {
final FileSet fileSet = (FileSet)m_filesets.get( i ); final FileSet fileSet = (FileSet)m_filesets.get( i );
final DirectoryScanner scanner = fileSet.getDirectoryScanner( getProject() );
final File fromDir = fileSet.getDir( getProject() );
final DirectoryScanner scanner = fileSet.getDirectoryScanner();
final File fromDir = fileSet.getDir();


final String[] srcFiles = scanner.getIncludedFiles(); final String[] srcFiles = scanner.getIncludedFiles();
final String[] srcDirs = scanner.getIncludedDirectories(); final String[] srcDirs = scanner.getIncludedDirectories();
@@ -486,7 +486,7 @@ public class Copy
else else
{ {
FileSet fs = (FileSet)m_filesets.get( 0 ); FileSet fs = (FileSet)m_filesets.get( 0 );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();


if( srcFiles.length > 0 ) if( srcFiles.length > 0 )


+ 8
- 6
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Delete.java View File

@@ -44,7 +44,7 @@ public class Delete
* *
* @param dir the directory path. * @param dir the directory path.
*/ */
public void setDir( File dir )
public void setDir( final File dir )
{ {
m_dir = dir; m_dir = dir;
} }
@@ -54,7 +54,7 @@ public class Delete
* *
* @param file the file to be deleted * @param file the file to be deleted
*/ */
public void setFile( File file )
public void setFile( final File file )
{ {
m_file = file; m_file = file;
} }
@@ -100,14 +100,16 @@ public class Delete
getLogger().info( "Deleting: " + m_file.getAbsolutePath() ); getLogger().info( "Deleting: " + m_file.getAbsolutePath() );
if( !m_file.delete() ) if( !m_file.delete() )
{ {
String message = "Unable to delete file " + m_file.getAbsolutePath();
final String message = "Unable to delete file " + m_file.getAbsolutePath();
throw new TaskException( message ); throw new TaskException( message );
} }
} }
} }
else else
{ {
getLogger().debug( "Could not find file " + m_file.getAbsolutePath() + " to delete." );
final String message =
"Could not find file " + m_file.getAbsolutePath() + " to delete.";
getLogger().debug( message );
} }
} }


@@ -124,10 +126,10 @@ public class Delete
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
try try
{ {
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] files = ds.getIncludedFiles(); String[] files = ds.getIncludedFiles();
String[] dirs = ds.getIncludedDirectories(); String[] dirs = ds.getIncludedDirectories();
removeFiles( fs.getDir( getProject() ), files, dirs );
removeFiles( fs.getDir(), files, dirs );
} }
catch( TaskException be ) catch( TaskException be )
{ {


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Move.java View File

@@ -205,7 +205,7 @@ public class Move
while( e.hasNext() ) while( e.hasNext() )
{ {
FileSet fs = (FileSet)e.next(); FileSet fs = (FileSet)e.next();
File dir = fs.getDir( getProject() );
File dir = fs.getDir();


if( okToDelete( dir ) ) if( okToDelete( dir ) )
{ {


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Touch.java View File

@@ -157,8 +157,8 @@ public class Touch
for( int i = 0; i < size; i++ ) for( int i = 0; i < size; i++ )
{ {
final FileSet fs = (FileSet)m_filesets.get( i ); final FileSet fs = (FileSet)m_filesets.get( i );
final DirectoryScanner ds = fs.getDirectoryScanner( null );
final File fromDir = fs.getDir( null );
final DirectoryScanner ds = fs.getDirectoryScanner();
final File fromDir = fs.getDir();


final String[] srcFiles = ds.getIncludedFiles(); final String[] srcFiles = ds.getIncludedFiles();
final String[] srcDirs = ds.getIncludedDirectories(); final String[] srcDirs = ds.getIncludedDirectories();


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java View File

@@ -1022,7 +1022,7 @@ public class Javadoc
final File source = resolveFile( list[ j ] ); final File source = resolveFile( list[ j ] );
fs.setDir( source ); fs.setDir( source );


final DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
final DirectoryScanner ds = fs.getDirectoryScanner();
final String[] packageDirs = ds.getIncludedDirectories(); final String[] packageDirs = ds.getIncludedDirectories();


for( int i = 0; i < packageDirs.length; i++ ) for( int i = 0; i < packageDirs.length; i++ )


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Cab.java View File

@@ -204,7 +204,7 @@ public class Cab extends MatchingTask
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
if( fs != null ) if( fs != null )
{ {
appendFiles( files, fs.getDirectoryScanner( getProject() ) );
appendFiles( files, fs.getDirectoryScanner() );
} }
} }
} }


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java View File

@@ -559,8 +559,8 @@ public class GenericDeploymentTool
for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); )
{ {
FileSet supportFileSet = (FileSet)i.next(); FileSet supportFileSet = (FileSet)i.next();
File supportBaseDir = supportFileSet.getDir( project );
DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner( project );
File supportBaseDir = supportFileSet.getDir();
DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner();
supportScanner.scan(); supportScanner.scan();
String[] supportFiles = supportScanner.getIncludedFiles(); String[] supportFiles = supportScanner.getIncludedFiles();
for( int j = 0; j < supportFiles.length; ++j ) for( int j = 0; j < supportFiles.length; ++j )


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java View File

@@ -518,7 +518,7 @@ public class Translate
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();
for( int j = 0; j < srcFiles.length; j++ ) for( int j = 0; j < srcFiles.length; j++ )
{ {


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java View File

@@ -224,7 +224,7 @@ public class VAJImport extends VAJTask
*/ */
protected void importFileset( FileSet fileset ) protected void importFileset( FileSet fileset )
{ {
DirectoryScanner ds = fileset.getDirectoryScanner( this.getProject() );
DirectoryScanner ds = fileset.getDirectoryScanner();
if( ds.getIncludedFiles().length == 0 ) if( ds.getIncludedFiles().length == 0 )
{ {
return; return;


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java View File

@@ -127,7 +127,7 @@ public final class BatchTest extends BaseTest
for( int j = 0; j < size; j++ ) for( int j = 0; j < size; j++ )
{ {
FileSet fs = (FileSet)filesets.get( j ); FileSet fs = (FileSet)filesets.get( j );
DirectoryScanner ds = fs.getDirectoryScanner( project );
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan(); ds.scan();
String[] f = ds.getIncludedFiles(); String[] f = ds.getIncludedFiles();
for( int k = 0; k < f.length; k++ ) for( int k = 0; k < f.length; k++ )


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java View File

@@ -200,7 +200,7 @@ public class XMLResultAggregator extends Task implements XMLConstants
for( int i = 0; i < size; i++ ) for( int i = 0; i < size; i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan(); ds.scan();
String[] f = ds.getIncludedFiles(); String[] f = ds.getIncludedFiles();
for( int j = 0; j < f.length; j++ ) for( int j = 0; j < f.length; j++ )


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java View File

@@ -365,7 +365,7 @@ public abstract class AbstractMetamataTask extends Task
for( int i = 0; i < fileSets.size(); i++ ) for( int i = 0; i < fileSets.size(); i++ )
{ {
FileSet fs = (FileSet)fileSets.get( i ); FileSet fs = (FileSet)fileSets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan(); ds.scan();
String[] f = ds.getIncludedFiles(); String[] f = ds.getIncludedFiles();
getLogger().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() ); getLogger().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() );


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -792,12 +792,12 @@ public class FTP


if( action == SEND_FILES ) if( action == SEND_FILES )
{ {
ds = fs.getDirectoryScanner( getProject() );
ds = fs.getDirectoryScanner();
} }
else else
{ {
ds = new FTPDirectoryScanner( ftp ); ds = new FTPDirectoryScanner( ftp );
fs.setupDirectoryScanner( ds, getProject() );
fs.setupDirectoryScanner( ds );
ds.scan(); ds.scan();
} }




+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java View File

@@ -307,7 +307,7 @@ public class MimeMail extends Task
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
if( fs != null ) if( fs != null )
{ {
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] dsfiles = ds.getIncludedFiles(); String[] dsfiles = ds.getIncludedFiles();
File baseDir = ds.getBasedir(); File baseDir = ds.getBasedir();




+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java View File

@@ -123,7 +123,7 @@ public class P4Add extends P4Base
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
//File fromDir = fs.getDir(project); //File fromDir = fs.getDir(project);


String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java View File

@@ -152,7 +152,7 @@ public class CovMerge extends Task
for( int i = 0; i < size; i++ ) for( int i = 0; i < size; i++ )
{ {
FileSet fs = (FileSet)filesets.get( i ); FileSet fs = (FileSet)filesets.get( i );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan(); ds.scan();
String[] f = ds.getIncludedFiles(); String[] f = ds.getIncludedFiles();
for( int j = 0; j < f.length; j++ ) for( int j = 0; j < f.length; j++ )


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/security/SignJar.java View File

@@ -151,12 +151,12 @@ public class SignJar
for( int i = 0; i < m_filesets.size(); i++ ) for( int i = 0; i < m_filesets.size(); i++ )
{ {
final FileSet fileSet = (FileSet)m_filesets.get( i ); final FileSet fileSet = (FileSet)m_filesets.get( i );
final DirectoryScanner scanner = fileSet.getDirectoryScanner( null );
final DirectoryScanner scanner = fileSet.getDirectoryScanner();
final String[] jarFiles = scanner.getIncludedFiles(); final String[] jarFiles = scanner.getIncludedFiles();
for( int j = 0; j < jarFiles.length; j++ ) for( int j = 0; j < jarFiles.length; j++ )
{ {
final File file = final File file =
new File( fileSet.getDir( null ), jarFiles[ j ] );
new File( fileSet.getDir(), jarFiles[ j ] );
doOneJar( file, null ); doOneJar( file, null );
} }
} }


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java View File

@@ -205,7 +205,7 @@ public class ReplaceRegExp extends Task
for( int i = 0; i < sz; i++ ) for( int i = 0; i < sz; i++ )
{ {
FileSet fs = (FileSet)( filesets.get( i ) ); FileSet fs = (FileSet)( filesets.get( i ) );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();


String files[] = ds.getIncludedFiles(); String files[] = ds.getIncludedFiles();
for( int j = 0; j < files.length; j++ ) for( int j = 0; j < files.length; j++ )


+ 3
- 3
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java View File

@@ -152,14 +152,14 @@ public class Chmod extends ExecuteOn
public void execute() public void execute()
throws TaskException throws TaskException
{ {
if( defaultSetDefined || defaultSet.getDir( getProject() ) == null )
if( defaultSetDefined || defaultSet.getDir() == null )
{ {
super.execute(); super.execute();
} }
else if( isValidOs() ) else if( isValidOs() )
{ {
// we are chmodding the given directory // we are chmodding the given directory
createArg().setValue( defaultSet.getDir( getProject() ).getPath() );
createArg().setValue( defaultSet.getDir().getPath() );
Execute execute = prepareExec(); Execute execute = prepareExec();
try try
{ {
@@ -191,7 +191,7 @@ public class Chmod extends ExecuteOn
throw new TaskException( "Required attribute perm not set in chmod" ); throw new TaskException( "Required attribute perm not set in chmod" );
} }


if( defaultSetDefined && defaultSet.getDir( getProject() ) != null )
if( defaultSetDefined && defaultSet.getDir() != null )
{ {
addFileset( defaultSet ); addFileset( defaultSet );
} }


+ 53
- 228
proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java View File

@@ -9,11 +9,9 @@ package org.apache.tools.ant.types;


import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Stack;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.FileScanner; import org.apache.tools.ant.FileScanner;
import org.apache.tools.ant.Project;


/** /**
* Moved out of MatchingTask to make it a standalone object that could be * Moved out of MatchingTask to make it a standalone object that could be
@@ -31,64 +29,36 @@ public class FileSet
extends DataType extends DataType
implements Cloneable implements Cloneable
{ {
private PatternSet defaultPatterns = new PatternSet();
private ArrayList additionalPatterns = new ArrayList();
private boolean useDefaultExcludes = true;
private boolean isCaseSensitive = true;

private File dir;
private PatternSet m_defaultPatterns = new PatternSet();
private ArrayList m_additionalPatterns = new ArrayList();
private boolean m_useDefaultExcludes = true;
private boolean m_isCaseSensitive = true;
private File m_dir;


public FileSet() public FileSet()
{ {
super();
}

protected FileSet( FileSet fileset )
{
this.dir = fileset.dir;
this.defaultPatterns = fileset.defaultPatterns;
this.additionalPatterns = fileset.additionalPatterns;
this.useDefaultExcludes = fileset.useDefaultExcludes;
this.isCaseSensitive = fileset.isCaseSensitive;
} }


/** /**
* Sets case sensitivity of the file system * Sets case sensitivity of the file system
*
* @param isCaseSensitive "true"|"on"|"yes" if file system is case
* sensitive, "false"|"off"|"no" when not.
*/ */
public void setCaseSensitive( boolean isCaseSensitive )
public void setCaseSensitive( final boolean isCaseSensitive )
{ {
this.isCaseSensitive = isCaseSensitive;
m_isCaseSensitive = isCaseSensitive;
} }


/** /**
* Sets whether default exclusions should be used or not. * Sets whether default exclusions should be used or not.
*
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
* should be used, "false"|"off"|"no" when they shouldn't be used.
*/ */
public void setDefaultexcludes( boolean useDefaultExcludes )
throws TaskException
public void setDefaultexcludes( final boolean useDefaultExcludes )
{ {
if( isReference() )
{
throw tooManyAttributes();
}

this.useDefaultExcludes = useDefaultExcludes;
m_useDefaultExcludes = useDefaultExcludes;
} }


public void setDir( File dir )
public void setDir( final File dir )
throws TaskException throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}

this.dir = dir;
m_dir = dir;
} }


/** /**
@@ -97,32 +67,19 @@ public class FileSet
* *
* @param excludes the string containing the exclude patterns * @param excludes the string containing the exclude patterns
*/ */
public void setExcludes( String excludes )
throws TaskException
public void setExcludes( final String excludes )
{ {
if( isReference() )
{
throw tooManyAttributes();
}

defaultPatterns.setExcludes( excludes );
m_defaultPatterns.setExcludes( excludes );
} }


/** /**
* Sets the name of the file containing the includes patterns. * Sets the name of the file containing the includes patterns.
* *
* @param excl The file to fetch the exclude patterns from. * @param excl The file to fetch the exclude patterns from.
* @exception TaskException Description of Exception
*/ */
public void setExcludesfile( File excl )
throws TaskException
public void setExcludesfile( final File excl )
{ {
if( isReference() )
{
throw tooManyAttributes();
}

defaultPatterns.setExcludesfile( excl );
m_defaultPatterns.setExcludesfile( excl );
} }


/** /**
@@ -132,250 +89,118 @@ public class FileSet
* @param includes the string containing the include patterns * @param includes the string containing the include patterns
*/ */
public void setIncludes( String includes ) public void setIncludes( String includes )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}

defaultPatterns.setIncludes( includes );
m_defaultPatterns.setIncludes( includes );
} }


/** /**
* Sets the name of the file containing the includes patterns. * Sets the name of the file containing the includes patterns.
* *
* @param incl The file to fetch the include patterns from. * @param incl The file to fetch the include patterns from.
* @exception TaskException Description of Exception
*/ */
public void setIncludesfile( File incl ) public void setIncludesfile( File incl )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}

defaultPatterns.setIncludesfile( incl );
m_defaultPatterns.setIncludesfile( incl );
} }


/**
* Makes this instance in effect a reference to another PatternSet instance.
* <p>
*
* You must not set another attribute or nest elements inside this element
* if you make it a reference.</p>
*
* @param r The new Refid value
* @exception TaskException Description of Exception
*/
public void setRefid( Reference r )
public void setupDirectoryScanner( final FileScanner ds )
throws TaskException throws TaskException
{ {
if( dir != null || defaultPatterns.hasPatterns() )
if( null == ds )
{ {
throw tooManyAttributes();
final String message = "ds cannot be null";
throw new IllegalArgumentException( message );
} }
if( !additionalPatterns.isEmpty() )
{
throw noChildrenAllowed();
}
super.setRefid( r );
}


public void setupDirectoryScanner( FileScanner ds, Project p )
throws TaskException
{
if( ds == null )
{
throw new IllegalArgumentException( "ds cannot be null" );
}

ds.setBasedir( dir );
ds.setBasedir( m_dir );


for( int i = 0; i < additionalPatterns.size(); i++ )
final int size = m_additionalPatterns.size();
for( int i = 0; i < size; i++ )
{ {
Object o = additionalPatterns.get( i );
defaultPatterns.append( (PatternSet)o, p );
final Object o = m_additionalPatterns.get( i );
m_defaultPatterns.append( (PatternSet)o );
} }


getLogger().debug( "FileSet: Setup file scanner in dir " + dir + " with " + defaultPatterns );
final String message = "FileSet: Setup file scanner in dir " +
m_dir + " with " + m_defaultPatterns;
getLogger().debug( message );


ds.setIncludes( defaultPatterns.getIncludePatterns( p ) );
ds.setExcludes( defaultPatterns.getExcludePatterns( p ) );
if( useDefaultExcludes )
ds.setIncludes( m_defaultPatterns.getIncludePatterns( null ) );
ds.setExcludes( m_defaultPatterns.getExcludePatterns( null ) );
if( m_useDefaultExcludes )
{
ds.addDefaultExcludes(); ds.addDefaultExcludes();
ds.setCaseSensitive( isCaseSensitive );
}
ds.setCaseSensitive( m_isCaseSensitive );
} }


public File getDir( Project p )
throws TaskException
public File getDir()
{ {
if( isReference() )
{
return getRef( p ).getDir( p );
}
return dir;
return m_dir;
} }


/** /**
* Returns the directory scanner needed to access the files to process. * Returns the directory scanner needed to access the files to process.
*
* @param p Description of Parameter
* @return The DirectoryScanner value
*/ */
public DirectoryScanner getDirectoryScanner( Project p )
public DirectoryScanner getDirectoryScanner()
throws TaskException throws TaskException
{ {
if( isReference() )
{
return getRef( p ).getDirectoryScanner( p );
}

if( dir == null )
if( m_dir == null )
{ {
throw new TaskException( "No directory specified for fileset." ); throw new TaskException( "No directory specified for fileset." );
} }


if( !dir.exists() )
if( !m_dir.exists() )
{ {
throw new TaskException( dir.getAbsolutePath() + " not found." );
throw new TaskException( m_dir.getAbsolutePath() + " not found." );
} }
if( !dir.isDirectory() )
if( !m_dir.isDirectory() )
{ {
throw new TaskException( dir.getAbsolutePath() + " is not a directory." );
throw new TaskException( m_dir.getAbsolutePath() + " is not a directory." );
} }


DirectoryScanner ds = new DirectoryScanner();
setupDirectoryScanner( ds, p );
ds.scan();
return ds;
}

/**
* Return a FileSet that has the same basedir and same patternsets as this
* one.
*
* @return Description of the Returned Value
*/
public Object clone()
{
try
{
if( isReference() )
{
return new FileSet( getRef( getProject() ) );
}
else
{
return new FileSet( this );
}
}
catch( TaskException e )
{
throw new IllegalStateException( e.getMessage() );
}
final DirectoryScanner scanner = new DirectoryScanner();
setupDirectoryScanner( scanner );
scanner.scan();
return scanner;
} }


/** /**
* add a name entry on the exclude list * add a name entry on the exclude list
*
* @return Description of the Returned Value
*/ */
public PatternSet.NameEntry createExclude() public PatternSet.NameEntry createExclude()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return defaultPatterns.createExclude();
return m_defaultPatterns.createExclude();
} }


/** /**
* add a name entry on the include files list * add a name entry on the include files list
*
* @return Description of the Returned Value
*/ */
public PatternSet.NameEntry createExcludesFile() public PatternSet.NameEntry createExcludesFile()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return defaultPatterns.createExcludesFile();
return m_defaultPatterns.createExcludesFile();
} }


/** /**
* add a name entry on the include list * add a name entry on the include list
*
* @return Description of the Returned Value
*/ */
public PatternSet.NameEntry createInclude() public PatternSet.NameEntry createInclude()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return defaultPatterns.createInclude();
return m_defaultPatterns.createInclude();
} }


/** /**
* add a name entry on the include files list * add a name entry on the include files list
*
* @return Description of the Returned Value
*/ */
public PatternSet.NameEntry createIncludesFile() public PatternSet.NameEntry createIncludesFile()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return defaultPatterns.createIncludesFile();
return m_defaultPatterns.createIncludesFile();
} }


public PatternSet createPatternSet() public PatternSet createPatternSet()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
PatternSet patterns = new PatternSet();
additionalPatterns.add( patterns );
final PatternSet patterns = new PatternSet();
m_additionalPatterns.add( patterns );
return patterns; return patterns;
} }

/**
* Performs the check for circular references and returns the referenced
* FileSet.
*
* @param p Description of Parameter
* @return The Ref value
*/
protected FileSet getRef( Project p )
throws TaskException
{
if( !checked )
{
Stack stk = new Stack();
stk.push( this );
dieOnCircularReference( stk, p );
}

Object o = ref.getReferencedObject( p );
if( !( o instanceof FileSet ) )
{
String msg = ref.getRefId() + " doesn\'t denote a fileset";
throw new TaskException( msg );
}
else
{
return (FileSet)o;
}
}

} }

+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java View File

@@ -588,9 +588,9 @@ public class Path
else if( o instanceof FileSet ) else if( o instanceof FileSet )
{ {
FileSet fs = (FileSet)o; FileSet fs = (FileSet)o;
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
DirectoryScanner ds = fs.getDirectoryScanner();
String[] s = ds.getIncludedFiles(); String[] s = ds.getIncludedFiles();
File dir = fs.getDir( getProject() );
File dir = fs.getDir();
for( int j = 0; j < s.length; j++ ) for( int j = 0; j < s.length; j++ )
{ {
File f = new File( dir, s[ j ] ); File f = new File( dir, s[ j ] );


+ 37
- 165
proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java View File

@@ -13,7 +13,6 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Stack;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
@@ -31,12 +30,13 @@ import org.apache.tools.ant.Project;
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/ */
public class PatternSet extends DataType
public class PatternSet
extends DataType
{ {
private ArrayList includeList = new ArrayList();
private ArrayList excludeList = new ArrayList();
private ArrayList includesFileList = new ArrayList();
private ArrayList excludesFileList = new ArrayList();
private ArrayList m_includeList = new ArrayList();
private ArrayList m_excludeList = new ArrayList();
private ArrayList m_includesFileList = new ArrayList();
private ArrayList m_excludesFileList = new ArrayList();


public PatternSet() public PatternSet()
{ {
@@ -50,12 +50,7 @@ public class PatternSet extends DataType
* @param excludes the string containing the exclude patterns * @param excludes the string containing the exclude patterns
*/ */
public void setExcludes( String excludes ) public void setExcludes( String excludes )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}
if( excludes != null && excludes.length() > 0 ) if( excludes != null && excludes.length() > 0 )
{ {
StringTokenizer tok = new StringTokenizer( excludes, ", ", false ); StringTokenizer tok = new StringTokenizer( excludes, ", ", false );
@@ -73,12 +68,7 @@ public class PatternSet extends DataType
* @exception TaskException Description of Exception * @exception TaskException Description of Exception
*/ */
public void setExcludesfile( File excludesFile ) public void setExcludesfile( File excludesFile )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}
createExcludesFile().setName( excludesFile.getAbsolutePath() ); createExcludesFile().setName( excludesFile.getAbsolutePath() );
} }


@@ -89,12 +79,7 @@ public class PatternSet extends DataType
* @param includes the string containing the include patterns * @param includes the string containing the include patterns
*/ */
public void setIncludes( String includes ) public void setIncludes( String includes )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}
if( includes != null && includes.length() > 0 ) if( includes != null && includes.length() > 0 )
{ {
StringTokenizer tok = new StringTokenizer( includes, ", ", false ); StringTokenizer tok = new StringTokenizer( includes, ", ", false );
@@ -112,53 +97,18 @@ public class PatternSet extends DataType
* @exception TaskException Description of Exception * @exception TaskException Description of Exception
*/ */
public void setIncludesfile( File includesFile ) public void setIncludesfile( File includesFile )
throws TaskException
{ {
if( isReference() )
{
throw tooManyAttributes();
}
createIncludesFile().setName( includesFile.getAbsolutePath() ); createIncludesFile().setName( includesFile.getAbsolutePath() );
} }


/**
* Makes this instance in effect a reference to another PatternSet instance.
* <p>
*
* You must not set another attribute or nest elements inside this element
* if you make it a reference.</p>
*
* @param r The new Refid value
* @exception TaskException Description of Exception
*/
public void setRefid( Reference r )
throws TaskException
{
if( !includeList.isEmpty() || !excludeList.isEmpty() )
{
throw tooManyAttributes();
}
super.setRefid( r );
}

/** /**
* Returns the filtered include patterns. * Returns the filtered include patterns.
*
* @param p Description of Parameter
* @return The ExcludePatterns value
*/ */
public String[] getExcludePatterns( Project p ) public String[] getExcludePatterns( Project p )
throws TaskException throws TaskException
{ {
if( isReference() )
{
return getRef( p ).getExcludePatterns( p );
}
else
{
readFiles( p );
return makeArray( excludeList, p );
}
readFiles( p );
return makeArray( m_excludeList );
} }


/** /**
@@ -170,32 +120,17 @@ public class PatternSet extends DataType
public String[] getIncludePatterns( Project p ) public String[] getIncludePatterns( Project p )
throws TaskException throws TaskException
{ {
if( isReference() )
{
return getRef( p ).getIncludePatterns( p );
}
else
{
readFiles( p );
return makeArray( includeList, p );
}
readFiles( p );
return makeArray( m_includeList );
} }


/** /**
* Adds the patterns of the other instance to this set. * Adds the patterns of the other instance to this set.
*
* @param other Description of Parameter
* @param p Description of Parameter
*/ */
public void append( PatternSet other, Project p )
protected void append( PatternSet other )
throws TaskException throws TaskException
{ {
if( isReference() )
{
throw new TaskException( "Cannot append to a reference" );
}

String[] incl = other.getIncludePatterns( p );
String[] incl = other.getIncludePatterns( null );
if( incl != null ) if( incl != null )
{ {
for( int i = 0; i < incl.length; i++ ) for( int i = 0; i < incl.length; i++ )
@@ -204,7 +139,7 @@ public class PatternSet extends DataType
} }
} }


String[] excl = other.getExcludePatterns( p );
String[] excl = other.getExcludePatterns( null );
if( excl != null ) if( excl != null )
{ {
for( int i = 0; i < excl.length; i++ ) for( int i = 0; i < excl.length; i++ )
@@ -220,13 +155,8 @@ public class PatternSet extends DataType
* @return Description of the Returned Value * @return Description of the Returned Value
*/ */
public NameEntry createExclude() public NameEntry createExclude()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return addPatternToList( excludeList );
return addPatternToList( m_excludeList );
} }


/** /**
@@ -235,121 +165,66 @@ public class PatternSet extends DataType
* @return Description of the Returned Value * @return Description of the Returned Value
*/ */
public NameEntry createExcludesFile() public NameEntry createExcludesFile()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return addPatternToList( excludesFileList );
return addPatternToList( m_excludesFileList );
} }


/** /**
* add a name entry on the include list * add a name entry on the include list
*
* @return Description of the Returned Value
*/ */
public NameEntry createInclude() public NameEntry createInclude()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return addPatternToList( includeList );
return addPatternToList( m_includeList );
} }


/** /**
* add a name entry on the include files list * add a name entry on the include files list
*
* @return Description of the Returned Value
*/ */
public NameEntry createIncludesFile() public NameEntry createIncludesFile()
throws TaskException
{ {
if( isReference() )
{
throw noChildrenAllowed();
}
return addPatternToList( includesFileList );
return addPatternToList( m_includesFileList );
} }


public String toString() public String toString()
{ {
return "patternSet{ includes: " + includeList +
" excludes: " + excludeList + " }";
return "patternSet{ includes: " + m_includeList +
" excludes: " + m_excludeList + " }";
} }


/** /**
* helper for FileSet. * helper for FileSet.
*
* @return Description of the Returned Value
*/ */
boolean hasPatterns() boolean hasPatterns()
{ {
return includesFileList.size() > 0 || excludesFileList.size() > 0
|| includeList.size() > 0 || excludeList.size() > 0;
}

/**
* Performs the check for circular references and returns the referenced
* PatternSet.
*
* @param p Description of Parameter
* @return The Ref value
*/
private PatternSet getRef( Project p )
throws TaskException
{
if( !checked )
{
Stack stk = new Stack();
stk.push( this );
dieOnCircularReference( stk, p );
}

Object o = ref.getReferencedObject( p );
if( !( o instanceof PatternSet ) )
{
String msg = ref.getRefId() + " doesn\'t denote a patternset";
throw new TaskException( msg );
}
else
{
return (PatternSet)o;
}
return m_includesFileList.size() > 0 || m_excludesFileList.size() > 0 ||
m_includeList.size() > 0 || m_excludeList.size() > 0;
} }


/** /**
* add a name entry to the given list * add a name entry to the given list
*
* @param list The feature to be added to the PatternToList attribute
* @return Description of the Returned Value
*/ */
private NameEntry addPatternToList( ArrayList list )
private NameEntry addPatternToList( final ArrayList list )
{ {
NameEntry result = new NameEntry();
final NameEntry result = new NameEntry();
list.add( result ); list.add( result );
return result; return result;
} }


/** /**
* Convert a vector of NameEntry elements into an array of Strings. * Convert a vector of NameEntry elements into an array of Strings.
*
* @param list Description of Parameter
* @param p Description of Parameter
* @return Description of the Returned Value
*/ */
private String[] makeArray( ArrayList list, Project p )
private String[] makeArray( final ArrayList list )
{ {
if( list.size() == 0 ) if( list.size() == 0 )
{
return null; return null;
}


ArrayList tmpNames = new ArrayList();
final ArrayList tmpNames = new ArrayList();
for( Iterator e = list.iterator(); e.hasNext(); ) for( Iterator e = list.iterator(); e.hasNext(); )
{ {
NameEntry ne = (NameEntry)e.next();
String pattern = ne.evalName( p );
final NameEntry ne = (NameEntry)e.next();
final String pattern = ne.evalName( null );
if( pattern != null && pattern.length() > 0 ) if( pattern != null && pattern.length() > 0 )
{ {
tmpNames.add( pattern ); tmpNames.add( pattern );
@@ -362,15 +237,13 @@ public class PatternSet extends DataType


/** /**
* Read includesfile ot excludesfile if not already done so. * Read includesfile ot excludesfile if not already done so.
*
* @param p Description of Parameter
*/ */
private void readFiles( Project p ) private void readFiles( Project p )
throws TaskException throws TaskException
{ {
if( includesFileList.size() > 0 )
if( m_includesFileList.size() > 0 )
{ {
Iterator e = includesFileList.iterator();
Iterator e = m_includesFileList.iterator();
while( e.hasNext() ) while( e.hasNext() )
{ {
NameEntry ne = (NameEntry)e.next(); NameEntry ne = (NameEntry)e.next();
@@ -382,15 +255,15 @@ public class PatternSet extends DataType
throw new TaskException( "Includesfile " throw new TaskException( "Includesfile "
+ inclFile.getAbsolutePath() + inclFile.getAbsolutePath()
+ " not found." ); + " not found." );
readPatterns( inclFile, includeList, p );
readPatterns( inclFile, m_includeList, p );
} }
} }
includesFileList.clear();
m_includesFileList.clear();
} }


if( excludesFileList.size() > 0 )
if( m_excludesFileList.size() > 0 )
{ {
Iterator e = excludesFileList.iterator();
Iterator e = m_excludesFileList.iterator();
while( e.hasNext() ) while( e.hasNext() )
{ {
NameEntry ne = (NameEntry)e.next(); NameEntry ne = (NameEntry)e.next();
@@ -402,10 +275,10 @@ public class PatternSet extends DataType
throw new TaskException( "Excludesfile " throw new TaskException( "Excludesfile "
+ exclFile.getAbsolutePath() + exclFile.getAbsolutePath()
+ " not found." ); + " not found." );
readPatterns( exclFile, excludeList, p );
readPatterns( exclFile, m_excludeList, p );
} }
} }
excludesFileList.clear();
m_excludesFileList.clear();
} }
} }


@@ -538,5 +411,4 @@ public class PatternSet extends DataType
return true; return true;
} }
} }

} }

+ 5
- 11
proposal/myrmidon/src/todo/org/apache/tools/ant/types/ZipFileSet.java View File

@@ -38,16 +38,14 @@ public class ZipFileSet
/** /**
* Set the directory for the fileset. Prevents both "dir" and "src" from * Set the directory for the fileset. Prevents both "dir" and "src" from
* being specified. * being specified.
*
* @param dir The new Dir value
* @exception TaskException Description of Exception
*/ */
public void setDir( File dir )
public void setDir( final File dir )
throws TaskException throws TaskException
{ {
if( srcFile != null ) if( srcFile != null )
{ {
throw new TaskException( "Cannot set both dir and src attributes" );
final String message = "Cannot set both dir and src attributes";
throw new TaskException( message );
} }
else else
{ {
@@ -104,22 +102,18 @@ public class ZipFileSet
public DirectoryScanner getDirectoryScanner( Project p ) public DirectoryScanner getDirectoryScanner( Project p )
throws TaskException throws TaskException
{ {
if( isReference() )
{
return getRef( p ).getDirectoryScanner( p );
}
if( srcFile != null ) if( srcFile != null )
{ {
ZipScanner zs = new ZipScanner(); ZipScanner zs = new ZipScanner();
zs.setSrc( srcFile ); zs.setSrc( srcFile );
super.setDir( p.getBaseDir() ); super.setDir( p.getBaseDir() );
setupDirectoryScanner( zs, p );
setupDirectoryScanner( zs );
zs.init(); zs.init();
return zs; return zs;
} }
else else
{ {
return super.getDirectoryScanner( p );
return super.getDirectoryScanner();
} }
} }




+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/types/optional/depend/ClassfileSet.java View File

@@ -47,7 +47,7 @@ public class ClassfileSet extends FileSet
public DirectoryScanner getDirectoryScanner( Project p ) public DirectoryScanner getDirectoryScanner( Project p )
{ {
DependScanner scanner = new DependScanner(); DependScanner scanner = new DependScanner();
scanner.setBasedir( getDir( p ) );
scanner.setBasedir( getDir() );
scanner.setRootClasses( rootClasses ); scanner.setRootClasses( rootClasses );
scanner.scan(); scanner.scan();
return scanner; return scanner;


Loading…
Cancel
Save