git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270499 13f79535-47bb-0310-9956-ffa450edef68master
@@ -259,12 +259,12 @@ public class XMLValidateTask | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] files = ds.getIncludedFiles(); | |||
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 ); | |||
fileProcessed++; | |||
} | |||
@@ -473,11 +473,11 @@ public class Checksum extends MatchingTask implements Condition | |||
for( int i = 0; i < sizeofFileSet; i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
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 ); | |||
} | |||
} | |||
@@ -154,13 +154,13 @@ public class DependSet extends MatchingTask | |||
{ | |||
FileSet targetFS = (FileSet)enumTargetSets.next(); | |||
DirectoryScanner targetDS = targetFS.getDirectoryScanner( getProject() ); | |||
DirectoryScanner targetDS = targetFS.getDirectoryScanner(); | |||
String[] targetFiles = targetDS.getIncludedFiles(); | |||
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 ); | |||
if( dest.lastModified() > now ) | |||
@@ -212,12 +212,12 @@ public class DependSet extends MatchingTask | |||
{ | |||
FileSet sourceFS = (FileSet)enumSourceSets.next(); | |||
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( getProject() ); | |||
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(); | |||
String[] sourceFiles = sourceDS.getIncludedFiles(); | |||
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 ) | |||
{ | |||
@@ -385,8 +385,8 @@ public class ExecuteOn extends ExecTask | |||
for( int i = 0; i < filesets.size(); 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 ) ) | |||
{ | |||
@@ -131,8 +131,8 @@ public class Expand extends MatchingTask | |||
for( int j = 0; j < filesets.size(); 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(); | |||
for( int i = 0; i < files.length; ++i ) | |||
@@ -157,7 +157,7 @@ public abstract class MatchingTask extends Task | |||
{ | |||
fileset.setDir( baseDir ); | |||
fileset.setDefaultexcludes( useDefaultExcludes ); | |||
return fileset.getDirectoryScanner( getProject() ); | |||
return fileset.getDirectoryScanner(); | |||
} | |||
} |
@@ -407,8 +407,8 @@ public class SQLExec | |||
for( int i = 0; i < filesets.size(); 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(); | |||
@@ -129,7 +129,7 @@ public class Tar | |||
} | |||
// add the main fileset to the list of filesets to process. | |||
TarFileSet mainFileSet = new TarFileSet( fileset ); | |||
TarFileSet mainFileSet = new TarFileSet( /*fileset*/ ); | |||
mainFileSet.setDir( baseDir ); | |||
filesets.add( mainFileSet ); | |||
} | |||
@@ -154,7 +154,7 @@ public class Tar | |||
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" ); | |||
} | |||
@@ -196,7 +196,7 @@ public class Tar | |||
String[] files = fs.getFiles( getProject() ); | |||
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, '/' ); | |||
tarFile( f, tOut, name, fs ); | |||
} | |||
@@ -322,16 +322,6 @@ public class Tar | |||
private String userName = ""; | |||
private String groupName = ""; | |||
public TarFileSet( FileSet fileset ) | |||
{ | |||
super( fileset ); | |||
} | |||
public TarFileSet() | |||
{ | |||
super(); | |||
} | |||
public void setGroup( String groupName ) | |||
{ | |||
this.groupName = groupName; | |||
@@ -359,7 +349,7 @@ public class Tar | |||
{ | |||
if( files == null ) | |||
{ | |||
DirectoryScanner ds = getDirectoryScanner( p ); | |||
DirectoryScanner ds = getDirectoryScanner(); | |||
String[] directories = ds.getIncludedDirectories(); | |||
String[] filesPerSe = ds.getIncludedFiles(); | |||
files = new String[ directories.length + filesPerSe.length ]; | |||
@@ -127,8 +127,8 @@ public class UpToDate extends MatchingTask implements Condition | |||
while( upToDate && enum.hasNext() ) | |||
{ | |||
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() ); | |||
} | |||
return upToDate; | |||
@@ -264,7 +264,7 @@ public class Zip extends MatchingTask | |||
for( int i = 0; i < filesets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
dss.add( fs.getDirectoryScanner( getProject() ) ); | |||
dss.add( fs.getDirectoryScanner() ); | |||
} | |||
int dssSize = dss.size(); | |||
FileScanner[] scanners = new FileScanner[ dssSize ]; | |||
@@ -541,7 +541,7 @@ public class Zip extends MatchingTask | |||
for( int i = 0; i < filesets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String prefix = ""; | |||
String fullpath = ""; | |||
@@ -229,8 +229,8 @@ public class Copy | |||
for( int i = 0; i < m_filesets.size(); 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[] srcDirs = scanner.getIncludedDirectories(); | |||
@@ -486,7 +486,7 @@ public class Copy | |||
else | |||
{ | |||
FileSet fs = (FileSet)m_filesets.get( 0 ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
if( srcFiles.length > 0 ) | |||
@@ -44,7 +44,7 @@ public class Delete | |||
* | |||
* @param dir the directory path. | |||
*/ | |||
public void setDir( File dir ) | |||
public void setDir( final File dir ) | |||
{ | |||
m_dir = dir; | |||
} | |||
@@ -54,7 +54,7 @@ public class Delete | |||
* | |||
* @param file the file to be deleted | |||
*/ | |||
public void setFile( File file ) | |||
public void setFile( final File file ) | |||
{ | |||
m_file = file; | |||
} | |||
@@ -100,14 +100,16 @@ public class Delete | |||
getLogger().info( "Deleting: " + m_file.getAbsolutePath() ); | |||
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 ); | |||
} | |||
} | |||
} | |||
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 ); | |||
try | |||
{ | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] files = ds.getIncludedFiles(); | |||
String[] dirs = ds.getIncludedDirectories(); | |||
removeFiles( fs.getDir( getProject() ), files, dirs ); | |||
removeFiles( fs.getDir(), files, dirs ); | |||
} | |||
catch( TaskException be ) | |||
{ | |||
@@ -205,7 +205,7 @@ public class Move | |||
while( e.hasNext() ) | |||
{ | |||
FileSet fs = (FileSet)e.next(); | |||
File dir = fs.getDir( getProject() ); | |||
File dir = fs.getDir(); | |||
if( okToDelete( dir ) ) | |||
{ | |||
@@ -157,8 +157,8 @@ public class Touch | |||
for( int i = 0; i < size; 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[] srcDirs = ds.getIncludedDirectories(); | |||
@@ -1022,7 +1022,7 @@ public class Javadoc | |||
final File source = resolveFile( list[ j ] ); | |||
fs.setDir( source ); | |||
final DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
final DirectoryScanner ds = fs.getDirectoryScanner(); | |||
final String[] packageDirs = ds.getIncludedDirectories(); | |||
for( int i = 0; i < packageDirs.length; i++ ) | |||
@@ -204,7 +204,7 @@ public class Cab extends MatchingTask | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
if( fs != null ) | |||
{ | |||
appendFiles( files, fs.getDirectoryScanner( getProject() ) ); | |||
appendFiles( files, fs.getDirectoryScanner() ); | |||
} | |||
} | |||
} | |||
@@ -559,8 +559,8 @@ public class GenericDeploymentTool | |||
for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) | |||
{ | |||
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(); | |||
String[] supportFiles = supportScanner.getIncludedFiles(); | |||
for( int j = 0; j < supportFiles.length; ++j ) | |||
@@ -518,7 +518,7 @@ public class Translate | |||
for( int i = 0; i < filesets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
for( int j = 0; j < srcFiles.length; j++ ) | |||
{ | |||
@@ -224,7 +224,7 @@ public class VAJImport extends VAJTask | |||
*/ | |||
protected void importFileset( FileSet fileset ) | |||
{ | |||
DirectoryScanner ds = fileset.getDirectoryScanner( this.getProject() ); | |||
DirectoryScanner ds = fileset.getDirectoryScanner(); | |||
if( ds.getIncludedFiles().length == 0 ) | |||
{ | |||
return; | |||
@@ -127,7 +127,7 @@ public final class BatchTest extends BaseTest | |||
for( int j = 0; j < size; j++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( j ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( project ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
ds.scan(); | |||
String[] f = ds.getIncludedFiles(); | |||
for( int k = 0; k < f.length; k++ ) | |||
@@ -200,7 +200,7 @@ public class XMLResultAggregator extends Task implements XMLConstants | |||
for( int i = 0; i < size; i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
ds.scan(); | |||
String[] f = ds.getIncludedFiles(); | |||
for( int j = 0; j < f.length; j++ ) | |||
@@ -365,7 +365,7 @@ public abstract class AbstractMetamataTask extends Task | |||
for( int i = 0; i < fileSets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)fileSets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
ds.scan(); | |||
String[] f = ds.getIncludedFiles(); | |||
getLogger().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() ); | |||
@@ -792,12 +792,12 @@ public class FTP | |||
if( action == SEND_FILES ) | |||
{ | |||
ds = fs.getDirectoryScanner( getProject() ); | |||
ds = fs.getDirectoryScanner(); | |||
} | |||
else | |||
{ | |||
ds = new FTPDirectoryScanner( ftp ); | |||
fs.setupDirectoryScanner( ds, getProject() ); | |||
fs.setupDirectoryScanner( ds ); | |||
ds.scan(); | |||
} | |||
@@ -307,7 +307,7 @@ public class MimeMail extends Task | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
if( fs != null ) | |||
{ | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] dsfiles = ds.getIncludedFiles(); | |||
File baseDir = ds.getBasedir(); | |||
@@ -123,7 +123,7 @@ public class P4Add extends P4Base | |||
for( int i = 0; i < filesets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
//File fromDir = fs.getDir(project); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
@@ -152,7 +152,7 @@ public class CovMerge extends Task | |||
for( int i = 0; i < size; i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
ds.scan(); | |||
String[] f = ds.getIncludedFiles(); | |||
for( int j = 0; j < f.length; j++ ) | |||
@@ -151,12 +151,12 @@ public class SignJar | |||
for( int i = 0; i < m_filesets.size(); 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(); | |||
for( int j = 0; j < jarFiles.length; j++ ) | |||
{ | |||
final File file = | |||
new File( fileSet.getDir( null ), jarFiles[ j ] ); | |||
new File( fileSet.getDir(), jarFiles[ j ] ); | |||
doOneJar( file, null ); | |||
} | |||
} | |||
@@ -205,7 +205,7 @@ public class ReplaceRegExp extends Task | |||
for( int i = 0; i < sz; i++ ) | |||
{ | |||
FileSet fs = (FileSet)( filesets.get( i ) ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String files[] = ds.getIncludedFiles(); | |||
for( int j = 0; j < files.length; j++ ) | |||
@@ -152,14 +152,14 @@ public class Chmod extends ExecuteOn | |||
public void execute() | |||
throws TaskException | |||
{ | |||
if( defaultSetDefined || defaultSet.getDir( getProject() ) == null ) | |||
if( defaultSetDefined || defaultSet.getDir() == null ) | |||
{ | |||
super.execute(); | |||
} | |||
else if( isValidOs() ) | |||
{ | |||
// we are chmodding the given directory | |||
createArg().setValue( defaultSet.getDir( getProject() ).getPath() ); | |||
createArg().setValue( defaultSet.getDir().getPath() ); | |||
Execute execute = prepareExec(); | |||
try | |||
{ | |||
@@ -191,7 +191,7 @@ public class Chmod extends ExecuteOn | |||
throw new TaskException( "Required attribute perm not set in chmod" ); | |||
} | |||
if( defaultSetDefined && defaultSet.getDir( getProject() ) != null ) | |||
if( defaultSetDefined && defaultSet.getDir() != null ) | |||
{ | |||
addFileset( defaultSet ); | |||
} | |||
@@ -9,11 +9,9 @@ package org.apache.tools.ant.types; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Stack; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
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 | |||
@@ -31,64 +29,36 @@ public class FileSet | |||
extends DataType | |||
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() | |||
{ | |||
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 | |||
* | |||
* @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. | |||
* | |||
* @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 | |||
{ | |||
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 | |||
*/ | |||
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. | |||
* | |||
* @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 | |||
*/ | |||
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. | |||
* | |||
* @param incl The file to fetch the include patterns from. | |||
* @exception TaskException Description of Exception | |||
*/ | |||
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 | |||
{ | |||
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.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. | |||
* | |||
* @param p Description of Parameter | |||
* @return The DirectoryScanner value | |||
*/ | |||
public DirectoryScanner getDirectoryScanner( Project p ) | |||
public DirectoryScanner getDirectoryScanner() | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
return getRef( p ).getDirectoryScanner( p ); | |||
} | |||
if( dir == null ) | |||
if( m_dir == null ) | |||
{ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
public PatternSet.NameEntry createIncludesFile() | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw noChildrenAllowed(); | |||
} | |||
return defaultPatterns.createIncludesFile(); | |||
return m_defaultPatterns.createIncludesFile(); | |||
} | |||
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; | |||
} | |||
/** | |||
* 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; | |||
} | |||
} | |||
} |
@@ -588,9 +588,9 @@ public class Path | |||
else if( o instanceof FileSet ) | |||
{ | |||
FileSet fs = (FileSet)o; | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] s = ds.getIncludedFiles(); | |||
File dir = fs.getDir( getProject() ); | |||
File dir = fs.getDir(); | |||
for( int j = 0; j < s.length; j++ ) | |||
{ | |||
File f = new File( dir, s[ j ] ); | |||
@@ -13,7 +13,6 @@ import java.io.FileReader; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.Stack; | |||
import java.util.StringTokenizer; | |||
import org.apache.myrmidon.api.TaskException; | |||
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 <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() | |||
{ | |||
@@ -50,12 +50,7 @@ public class PatternSet extends DataType | |||
* @param excludes the string containing the exclude patterns | |||
*/ | |||
public void setExcludes( String excludes ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw tooManyAttributes(); | |||
} | |||
if( excludes != null && excludes.length() > 0 ) | |||
{ | |||
StringTokenizer tok = new StringTokenizer( excludes, ", ", false ); | |||
@@ -73,12 +68,7 @@ public class PatternSet extends DataType | |||
* @exception TaskException Description of Exception | |||
*/ | |||
public void setExcludesfile( File excludesFile ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw tooManyAttributes(); | |||
} | |||
createExcludesFile().setName( excludesFile.getAbsolutePath() ); | |||
} | |||
@@ -89,12 +79,7 @@ public class PatternSet extends DataType | |||
* @param includes the string containing the include patterns | |||
*/ | |||
public void setIncludes( String includes ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw tooManyAttributes(); | |||
} | |||
if( includes != null && includes.length() > 0 ) | |||
{ | |||
StringTokenizer tok = new StringTokenizer( includes, ", ", false ); | |||
@@ -112,53 +97,18 @@ public class PatternSet extends DataType | |||
* @exception TaskException Description of Exception | |||
*/ | |||
public void setIncludesfile( File includesFile ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw tooManyAttributes(); | |||
} | |||
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. | |||
* | |||
* @param p Description of Parameter | |||
* @return The ExcludePatterns value | |||
*/ | |||
public String[] getExcludePatterns( Project p ) | |||
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 ) | |||
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. | |||
* | |||
* @param other Description of Parameter | |||
* @param p Description of Parameter | |||
*/ | |||
public void append( PatternSet other, Project p ) | |||
protected void append( PatternSet other ) | |||
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 ) | |||
{ | |||
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 ) | |||
{ | |||
for( int i = 0; i < excl.length; i++ ) | |||
@@ -220,13 +155,8 @@ public class PatternSet extends DataType | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
*/ | |||
public NameEntry createExcludesFile() | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw noChildrenAllowed(); | |||
} | |||
return addPatternToList( excludesFileList ); | |||
return addPatternToList( m_excludesFileList ); | |||
} | |||
/** | |||
* add a name entry on the include list | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
public NameEntry createIncludesFile() | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw noChildrenAllowed(); | |||
} | |||
return addPatternToList( includesFileList ); | |||
return addPatternToList( m_includesFileList ); | |||
} | |||
public String toString() | |||
{ | |||
return "patternSet{ includes: " + includeList + | |||
" excludes: " + excludeList + " }"; | |||
return "patternSet{ includes: " + m_includeList + | |||
" excludes: " + m_excludeList + " }"; | |||
} | |||
/** | |||
* helper for FileSet. | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @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 ); | |||
return result; | |||
} | |||
/** | |||
* 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 ) | |||
{ | |||
return null; | |||
} | |||
ArrayList tmpNames = new ArrayList(); | |||
final ArrayList tmpNames = new ArrayList(); | |||
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 ) | |||
{ | |||
tmpNames.add( pattern ); | |||
@@ -362,15 +237,13 @@ public class PatternSet extends DataType | |||
/** | |||
* Read includesfile ot excludesfile if not already done so. | |||
* | |||
* @param p Description of Parameter | |||
*/ | |||
private void readFiles( Project p ) | |||
throws TaskException | |||
{ | |||
if( includesFileList.size() > 0 ) | |||
if( m_includesFileList.size() > 0 ) | |||
{ | |||
Iterator e = includesFileList.iterator(); | |||
Iterator e = m_includesFileList.iterator(); | |||
while( e.hasNext() ) | |||
{ | |||
NameEntry ne = (NameEntry)e.next(); | |||
@@ -382,15 +255,15 @@ public class PatternSet extends DataType | |||
throw new TaskException( "Includesfile " | |||
+ inclFile.getAbsolutePath() | |||
+ " 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() ) | |||
{ | |||
NameEntry ne = (NameEntry)e.next(); | |||
@@ -402,10 +275,10 @@ public class PatternSet extends DataType | |||
throw new TaskException( "Excludesfile " | |||
+ exclFile.getAbsolutePath() | |||
+ " 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; | |||
} | |||
} | |||
} |
@@ -38,16 +38,14 @@ public class ZipFileSet | |||
/** | |||
* Set the directory for the fileset. Prevents both "dir" and "src" from | |||
* 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 | |||
{ | |||
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 | |||
{ | |||
@@ -104,22 +102,18 @@ public class ZipFileSet | |||
public DirectoryScanner getDirectoryScanner( Project p ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
return getRef( p ).getDirectoryScanner( p ); | |||
} | |||
if( srcFile != null ) | |||
{ | |||
ZipScanner zs = new ZipScanner(); | |||
zs.setSrc( srcFile ); | |||
super.setDir( p.getBaseDir() ); | |||
setupDirectoryScanner( zs, p ); | |||
setupDirectoryScanner( zs ); | |||
zs.init(); | |||
return zs; | |||
} | |||
else | |||
{ | |||
return super.getDirectoryScanner( p ); | |||
return super.getDirectoryScanner(); | |||
} | |||
} | |||
@@ -47,7 +47,7 @@ public class ClassfileSet extends FileSet | |||
public DirectoryScanner getDirectoryScanner( Project p ) | |||
{ | |||
DependScanner scanner = new DependScanner(); | |||
scanner.setBasedir( getDir( p ) ); | |||
scanner.setBasedir( getDir() ); | |||
scanner.setRootClasses( rootClasses ); | |||
scanner.scan(); | |||
return scanner; | |||
@@ -473,11 +473,11 @@ public class Checksum extends MatchingTask implements Condition | |||
for( int i = 0; i < sizeofFileSet; i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
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 ); | |||
} | |||
} | |||
@@ -154,13 +154,13 @@ public class DependSet extends MatchingTask | |||
{ | |||
FileSet targetFS = (FileSet)enumTargetSets.next(); | |||
DirectoryScanner targetDS = targetFS.getDirectoryScanner( getProject() ); | |||
DirectoryScanner targetDS = targetFS.getDirectoryScanner(); | |||
String[] targetFiles = targetDS.getIncludedFiles(); | |||
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 ); | |||
if( dest.lastModified() > now ) | |||
@@ -212,12 +212,12 @@ public class DependSet extends MatchingTask | |||
{ | |||
FileSet sourceFS = (FileSet)enumSourceSets.next(); | |||
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( getProject() ); | |||
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(); | |||
String[] sourceFiles = sourceDS.getIncludedFiles(); | |||
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 ) | |||
{ | |||
@@ -385,8 +385,8 @@ public class ExecuteOn extends ExecTask | |||
for( int i = 0; i < filesets.size(); 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 ) ) | |||
{ | |||
@@ -131,8 +131,8 @@ public class Expand extends MatchingTask | |||
for( int j = 0; j < filesets.size(); 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(); | |||
for( int i = 0; i < files.length; ++i ) | |||
@@ -157,7 +157,7 @@ public abstract class MatchingTask extends Task | |||
{ | |||
fileset.setDir( baseDir ); | |||
fileset.setDefaultexcludes( useDefaultExcludes ); | |||
return fileset.getDirectoryScanner( getProject() ); | |||
return fileset.getDirectoryScanner(); | |||
} | |||
} |
@@ -407,8 +407,8 @@ public class SQLExec | |||
for( int i = 0; i < filesets.size(); 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(); | |||
@@ -129,7 +129,7 @@ public class Tar | |||
} | |||
// add the main fileset to the list of filesets to process. | |||
TarFileSet mainFileSet = new TarFileSet( fileset ); | |||
TarFileSet mainFileSet = new TarFileSet( /*fileset*/ ); | |||
mainFileSet.setDir( baseDir ); | |||
filesets.add( mainFileSet ); | |||
} | |||
@@ -154,7 +154,7 @@ public class Tar | |||
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" ); | |||
} | |||
@@ -196,7 +196,7 @@ public class Tar | |||
String[] files = fs.getFiles( getProject() ); | |||
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, '/' ); | |||
tarFile( f, tOut, name, fs ); | |||
} | |||
@@ -322,16 +322,6 @@ public class Tar | |||
private String userName = ""; | |||
private String groupName = ""; | |||
public TarFileSet( FileSet fileset ) | |||
{ | |||
super( fileset ); | |||
} | |||
public TarFileSet() | |||
{ | |||
super(); | |||
} | |||
public void setGroup( String groupName ) | |||
{ | |||
this.groupName = groupName; | |||
@@ -359,7 +349,7 @@ public class Tar | |||
{ | |||
if( files == null ) | |||
{ | |||
DirectoryScanner ds = getDirectoryScanner( p ); | |||
DirectoryScanner ds = getDirectoryScanner(); | |||
String[] directories = ds.getIncludedDirectories(); | |||
String[] filesPerSe = ds.getIncludedFiles(); | |||
files = new String[ directories.length + filesPerSe.length ]; | |||
@@ -127,8 +127,8 @@ public class UpToDate extends MatchingTask implements Condition | |||
while( upToDate && enum.hasNext() ) | |||
{ | |||
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() ); | |||
} | |||
return upToDate; | |||
@@ -264,7 +264,7 @@ public class Zip extends MatchingTask | |||
for( int i = 0; i < filesets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
dss.add( fs.getDirectoryScanner( getProject() ) ); | |||
dss.add( fs.getDirectoryScanner() ); | |||
} | |||
int dssSize = dss.size(); | |||
FileScanner[] scanners = new FileScanner[ dssSize ]; | |||
@@ -541,7 +541,7 @@ public class Zip extends MatchingTask | |||
for( int i = 0; i < filesets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String prefix = ""; | |||
String fullpath = ""; | |||
@@ -229,8 +229,8 @@ public class Copy | |||
for( int i = 0; i < m_filesets.size(); 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[] srcDirs = scanner.getIncludedDirectories(); | |||
@@ -486,7 +486,7 @@ public class Copy | |||
else | |||
{ | |||
FileSet fs = (FileSet)m_filesets.get( 0 ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
if( srcFiles.length > 0 ) | |||
@@ -44,7 +44,7 @@ public class Delete | |||
* | |||
* @param dir the directory path. | |||
*/ | |||
public void setDir( File dir ) | |||
public void setDir( final File dir ) | |||
{ | |||
m_dir = dir; | |||
} | |||
@@ -54,7 +54,7 @@ public class Delete | |||
* | |||
* @param file the file to be deleted | |||
*/ | |||
public void setFile( File file ) | |||
public void setFile( final File file ) | |||
{ | |||
m_file = file; | |||
} | |||
@@ -100,14 +100,16 @@ public class Delete | |||
getLogger().info( "Deleting: " + m_file.getAbsolutePath() ); | |||
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 ); | |||
} | |||
} | |||
} | |||
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 ); | |||
try | |||
{ | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] files = ds.getIncludedFiles(); | |||
String[] dirs = ds.getIncludedDirectories(); | |||
removeFiles( fs.getDir( getProject() ), files, dirs ); | |||
removeFiles( fs.getDir(), files, dirs ); | |||
} | |||
catch( TaskException be ) | |||
{ | |||
@@ -205,7 +205,7 @@ public class Move | |||
while( e.hasNext() ) | |||
{ | |||
FileSet fs = (FileSet)e.next(); | |||
File dir = fs.getDir( getProject() ); | |||
File dir = fs.getDir(); | |||
if( okToDelete( dir ) ) | |||
{ | |||
@@ -157,8 +157,8 @@ public class Touch | |||
for( int i = 0; i < size; 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[] srcDirs = ds.getIncludedDirectories(); | |||
@@ -1022,7 +1022,7 @@ public class Javadoc | |||
final File source = resolveFile( list[ j ] ); | |||
fs.setDir( source ); | |||
final DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
final DirectoryScanner ds = fs.getDirectoryScanner(); | |||
final String[] packageDirs = ds.getIncludedDirectories(); | |||
for( int i = 0; i < packageDirs.length; i++ ) | |||
@@ -204,7 +204,7 @@ public class Cab extends MatchingTask | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
if( fs != null ) | |||
{ | |||
appendFiles( files, fs.getDirectoryScanner( getProject() ) ); | |||
appendFiles( files, fs.getDirectoryScanner() ); | |||
} | |||
} | |||
} | |||
@@ -559,8 +559,8 @@ public class GenericDeploymentTool | |||
for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) | |||
{ | |||
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(); | |||
String[] supportFiles = supportScanner.getIncludedFiles(); | |||
for( int j = 0; j < supportFiles.length; ++j ) | |||
@@ -518,7 +518,7 @@ public class Translate | |||
for( int i = 0; i < filesets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
for( int j = 0; j < srcFiles.length; j++ ) | |||
{ | |||
@@ -224,7 +224,7 @@ public class VAJImport extends VAJTask | |||
*/ | |||
protected void importFileset( FileSet fileset ) | |||
{ | |||
DirectoryScanner ds = fileset.getDirectoryScanner( this.getProject() ); | |||
DirectoryScanner ds = fileset.getDirectoryScanner(); | |||
if( ds.getIncludedFiles().length == 0 ) | |||
{ | |||
return; | |||
@@ -127,7 +127,7 @@ public final class BatchTest extends BaseTest | |||
for( int j = 0; j < size; j++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( j ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( project ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
ds.scan(); | |||
String[] f = ds.getIncludedFiles(); | |||
for( int k = 0; k < f.length; k++ ) | |||
@@ -200,7 +200,7 @@ public class XMLResultAggregator extends Task implements XMLConstants | |||
for( int i = 0; i < size; i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
ds.scan(); | |||
String[] f = ds.getIncludedFiles(); | |||
for( int j = 0; j < f.length; j++ ) | |||
@@ -365,7 +365,7 @@ public abstract class AbstractMetamataTask extends Task | |||
for( int i = 0; i < fileSets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)fileSets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
ds.scan(); | |||
String[] f = ds.getIncludedFiles(); | |||
getLogger().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() ); | |||
@@ -792,12 +792,12 @@ public class FTP | |||
if( action == SEND_FILES ) | |||
{ | |||
ds = fs.getDirectoryScanner( getProject() ); | |||
ds = fs.getDirectoryScanner(); | |||
} | |||
else | |||
{ | |||
ds = new FTPDirectoryScanner( ftp ); | |||
fs.setupDirectoryScanner( ds, getProject() ); | |||
fs.setupDirectoryScanner( ds ); | |||
ds.scan(); | |||
} | |||
@@ -307,7 +307,7 @@ public class MimeMail extends Task | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
if( fs != null ) | |||
{ | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] dsfiles = ds.getIncludedFiles(); | |||
File baseDir = ds.getBasedir(); | |||
@@ -123,7 +123,7 @@ public class P4Add extends P4Base | |||
for( int i = 0; i < filesets.size(); i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
//File fromDir = fs.getDir(project); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
@@ -152,7 +152,7 @@ public class CovMerge extends Task | |||
for( int i = 0; i < size; i++ ) | |||
{ | |||
FileSet fs = (FileSet)filesets.get( i ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
ds.scan(); | |||
String[] f = ds.getIncludedFiles(); | |||
for( int j = 0; j < f.length; j++ ) | |||
@@ -151,12 +151,12 @@ public class SignJar | |||
for( int i = 0; i < m_filesets.size(); 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(); | |||
for( int j = 0; j < jarFiles.length; j++ ) | |||
{ | |||
final File file = | |||
new File( fileSet.getDir( null ), jarFiles[ j ] ); | |||
new File( fileSet.getDir(), jarFiles[ j ] ); | |||
doOneJar( file, null ); | |||
} | |||
} | |||
@@ -205,7 +205,7 @@ public class ReplaceRegExp extends Task | |||
for( int i = 0; i < sz; i++ ) | |||
{ | |||
FileSet fs = (FileSet)( filesets.get( i ) ); | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String files[] = ds.getIncludedFiles(); | |||
for( int j = 0; j < files.length; j++ ) | |||
@@ -152,14 +152,14 @@ public class Chmod extends ExecuteOn | |||
public void execute() | |||
throws TaskException | |||
{ | |||
if( defaultSetDefined || defaultSet.getDir( getProject() ) == null ) | |||
if( defaultSetDefined || defaultSet.getDir() == null ) | |||
{ | |||
super.execute(); | |||
} | |||
else if( isValidOs() ) | |||
{ | |||
// we are chmodding the given directory | |||
createArg().setValue( defaultSet.getDir( getProject() ).getPath() ); | |||
createArg().setValue( defaultSet.getDir().getPath() ); | |||
Execute execute = prepareExec(); | |||
try | |||
{ | |||
@@ -191,7 +191,7 @@ public class Chmod extends ExecuteOn | |||
throw new TaskException( "Required attribute perm not set in chmod" ); | |||
} | |||
if( defaultSetDefined && defaultSet.getDir( getProject() ) != null ) | |||
if( defaultSetDefined && defaultSet.getDir() != null ) | |||
{ | |||
addFileset( defaultSet ); | |||
} | |||
@@ -9,11 +9,9 @@ package org.apache.tools.ant.types; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Stack; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
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 | |||
@@ -31,64 +29,36 @@ public class FileSet | |||
extends DataType | |||
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() | |||
{ | |||
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 | |||
* | |||
* @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. | |||
* | |||
* @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 | |||
{ | |||
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 | |||
*/ | |||
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. | |||
* | |||
* @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 | |||
*/ | |||
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. | |||
* | |||
* @param incl The file to fetch the include patterns from. | |||
* @exception TaskException Description of Exception | |||
*/ | |||
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 | |||
{ | |||
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.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. | |||
* | |||
* @param p Description of Parameter | |||
* @return The DirectoryScanner value | |||
*/ | |||
public DirectoryScanner getDirectoryScanner( Project p ) | |||
public DirectoryScanner getDirectoryScanner() | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
return getRef( p ).getDirectoryScanner( p ); | |||
} | |||
if( dir == null ) | |||
if( m_dir == null ) | |||
{ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
public PatternSet.NameEntry createIncludesFile() | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw noChildrenAllowed(); | |||
} | |||
return defaultPatterns.createIncludesFile(); | |||
return m_defaultPatterns.createIncludesFile(); | |||
} | |||
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; | |||
} | |||
/** | |||
* 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; | |||
} | |||
} | |||
} |
@@ -588,9 +588,9 @@ public class Path | |||
else if( o instanceof FileSet ) | |||
{ | |||
FileSet fs = (FileSet)o; | |||
DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | |||
DirectoryScanner ds = fs.getDirectoryScanner(); | |||
String[] s = ds.getIncludedFiles(); | |||
File dir = fs.getDir( getProject() ); | |||
File dir = fs.getDir(); | |||
for( int j = 0; j < s.length; j++ ) | |||
{ | |||
File f = new File( dir, s[ j ] ); | |||
@@ -13,7 +13,6 @@ import java.io.FileReader; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.Stack; | |||
import java.util.StringTokenizer; | |||
import org.apache.myrmidon.api.TaskException; | |||
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 <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() | |||
{ | |||
@@ -50,12 +50,7 @@ public class PatternSet extends DataType | |||
* @param excludes the string containing the exclude patterns | |||
*/ | |||
public void setExcludes( String excludes ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw tooManyAttributes(); | |||
} | |||
if( excludes != null && excludes.length() > 0 ) | |||
{ | |||
StringTokenizer tok = new StringTokenizer( excludes, ", ", false ); | |||
@@ -73,12 +68,7 @@ public class PatternSet extends DataType | |||
* @exception TaskException Description of Exception | |||
*/ | |||
public void setExcludesfile( File excludesFile ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw tooManyAttributes(); | |||
} | |||
createExcludesFile().setName( excludesFile.getAbsolutePath() ); | |||
} | |||
@@ -89,12 +79,7 @@ public class PatternSet extends DataType | |||
* @param includes the string containing the include patterns | |||
*/ | |||
public void setIncludes( String includes ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw tooManyAttributes(); | |||
} | |||
if( includes != null && includes.length() > 0 ) | |||
{ | |||
StringTokenizer tok = new StringTokenizer( includes, ", ", false ); | |||
@@ -112,53 +97,18 @@ public class PatternSet extends DataType | |||
* @exception TaskException Description of Exception | |||
*/ | |||
public void setIncludesfile( File includesFile ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw tooManyAttributes(); | |||
} | |||
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. | |||
* | |||
* @param p Description of Parameter | |||
* @return The ExcludePatterns value | |||
*/ | |||
public String[] getExcludePatterns( Project p ) | |||
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 ) | |||
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. | |||
* | |||
* @param other Description of Parameter | |||
* @param p Description of Parameter | |||
*/ | |||
public void append( PatternSet other, Project p ) | |||
protected void append( PatternSet other ) | |||
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 ) | |||
{ | |||
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 ) | |||
{ | |||
for( int i = 0; i < excl.length; i++ ) | |||
@@ -220,13 +155,8 @@ public class PatternSet extends DataType | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
*/ | |||
public NameEntry createExcludesFile() | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw noChildrenAllowed(); | |||
} | |||
return addPatternToList( excludesFileList ); | |||
return addPatternToList( m_excludesFileList ); | |||
} | |||
/** | |||
* add a name entry on the include list | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
public NameEntry createIncludesFile() | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
throw noChildrenAllowed(); | |||
} | |||
return addPatternToList( includesFileList ); | |||
return addPatternToList( m_includesFileList ); | |||
} | |||
public String toString() | |||
{ | |||
return "patternSet{ includes: " + includeList + | |||
" excludes: " + excludeList + " }"; | |||
return "patternSet{ includes: " + m_includeList + | |||
" excludes: " + m_excludeList + " }"; | |||
} | |||
/** | |||
* helper for FileSet. | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
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 | |||
* | |||
* @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 ); | |||
return result; | |||
} | |||
/** | |||
* 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 ) | |||
{ | |||
return null; | |||
} | |||
ArrayList tmpNames = new ArrayList(); | |||
final ArrayList tmpNames = new ArrayList(); | |||
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 ) | |||
{ | |||
tmpNames.add( pattern ); | |||
@@ -362,15 +237,13 @@ public class PatternSet extends DataType | |||
/** | |||
* Read includesfile ot excludesfile if not already done so. | |||
* | |||
* @param p Description of Parameter | |||
*/ | |||
private void readFiles( Project p ) | |||
throws TaskException | |||
{ | |||
if( includesFileList.size() > 0 ) | |||
if( m_includesFileList.size() > 0 ) | |||
{ | |||
Iterator e = includesFileList.iterator(); | |||
Iterator e = m_includesFileList.iterator(); | |||
while( e.hasNext() ) | |||
{ | |||
NameEntry ne = (NameEntry)e.next(); | |||
@@ -382,15 +255,15 @@ public class PatternSet extends DataType | |||
throw new TaskException( "Includesfile " | |||
+ inclFile.getAbsolutePath() | |||
+ " 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() ) | |||
{ | |||
NameEntry ne = (NameEntry)e.next(); | |||
@@ -402,10 +275,10 @@ public class PatternSet extends DataType | |||
throw new TaskException( "Excludesfile " | |||
+ exclFile.getAbsolutePath() | |||
+ " 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; | |||
} | |||
} | |||
} |
@@ -38,16 +38,14 @@ public class ZipFileSet | |||
/** | |||
* Set the directory for the fileset. Prevents both "dir" and "src" from | |||
* 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 | |||
{ | |||
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 | |||
{ | |||
@@ -104,22 +102,18 @@ public class ZipFileSet | |||
public DirectoryScanner getDirectoryScanner( Project p ) | |||
throws TaskException | |||
{ | |||
if( isReference() ) | |||
{ | |||
return getRef( p ).getDirectoryScanner( p ); | |||
} | |||
if( srcFile != null ) | |||
{ | |||
ZipScanner zs = new ZipScanner(); | |||
zs.setSrc( srcFile ); | |||
super.setDir( p.getBaseDir() ); | |||
setupDirectoryScanner( zs, p ); | |||
setupDirectoryScanner( zs ); | |||
zs.init(); | |||
return zs; | |||
} | |||
else | |||
{ | |||
return super.getDirectoryScanner( p ); | |||
return super.getDirectoryScanner(); | |||
} | |||
} | |||
@@ -47,7 +47,7 @@ public class ClassfileSet extends FileSet | |||
public DirectoryScanner getDirectoryScanner( Project p ) | |||
{ | |||
DependScanner scanner = new DependScanner(); | |||
scanner.setBasedir( getDir( p ) ); | |||
scanner.setBasedir( getDir() ); | |||
scanner.setRootClasses( rootClasses ); | |||
scanner.scan(); | |||
return scanner; | |||