git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270938 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -10,27 +10,25 @@ package org.apache.tools.ant.taskdefs; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.myrmidon.framework.PatternSet; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.ScannerUtil; | |||
| import org.apache.myrmidon.framework.PatternSet; | |||
| /** | |||
| * This is an abstract task that should be used by all those tasks that require | |||
| * to include or exclude files based on pattern matching. | |||
| * | |||
| * @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> | |||
| * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org"> | |||
| * stefano@apache.org</a> | |||
| * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> | |||
| * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | |||
| * @author <a href="mailto:ajkuiper@wxs.nl">Arnout J. Kuiper</a> | |||
| * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a> | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a> | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| */ | |||
| public abstract class MatchingTask | |||
| extends Task | |||
| { | |||
| private boolean m_useDefaultExcludes = true; | |||
| private FileSet m_fileset = new FileSet(); | |||
| /** | |||
| @@ -38,7 +36,7 @@ public abstract class MatchingTask | |||
| */ | |||
| public void setDefaultexcludes( final boolean useDefaultExcludes ) | |||
| { | |||
| m_useDefaultExcludes = useDefaultExcludes; | |||
| m_fileset.setDefaultExcludes( useDefaultExcludes ); | |||
| } | |||
| /** | |||
| @@ -48,7 +46,6 @@ public abstract class MatchingTask | |||
| * @param excludes the string containing the exclude patterns | |||
| */ | |||
| public void setExcludes( final String excludes ) | |||
| throws TaskException | |||
| { | |||
| m_fileset.setExcludes( excludes ); | |||
| } | |||
| @@ -60,7 +57,6 @@ public abstract class MatchingTask | |||
| * @param includes the string containing the include patterns | |||
| */ | |||
| public void setIncludes( final String includes ) | |||
| throws TaskException | |||
| { | |||
| m_fileset.setIncludes( includes ); | |||
| } | |||
| @@ -100,7 +96,6 @@ public abstract class MatchingTask | |||
| throws TaskException | |||
| { | |||
| m_fileset.setDir( baseDir ); | |||
| m_fileset.setDefaultexcludes( m_useDefaultExcludes ); | |||
| return ScannerUtil.getDirectoryScanner( m_fileset ); | |||
| } | |||
| } | |||
| @@ -20,17 +20,17 @@ import java.util.Hashtable; | |||
| import java.util.Stack; | |||
| import java.util.zip.CRC32; | |||
| import java.util.zip.ZipInputStream; | |||
| import org.apache.aut.zip.ZipEntry; | |||
| import org.apache.aut.zip.ZipOutputStream; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.types.FileScanner; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.ScannerUtil; | |||
| import org.apache.tools.ant.types.SourceFileScanner; | |||
| import org.apache.tools.ant.types.ZipFileSet; | |||
| import org.apache.tools.ant.types.ZipScanner; | |||
| import org.apache.tools.ant.types.ScannerUtil; | |||
| import org.apache.tools.ant.util.mappers.MergingMapper; | |||
| import org.apache.aut.zip.ZipEntry; | |||
| import org.apache.aut.zip.ZipOutputStream; | |||
| /** | |||
| * Create a ZIP archive. | |||
| @@ -266,8 +266,9 @@ public class Zip | |||
| } | |||
| for( int i = 0; i < m_filesets.size(); i++ ) | |||
| { | |||
| FileSet fs = (FileSet)m_filesets.get( i ); | |||
| dss.add( ScannerUtil.getDirectoryScanner( fs ) ); | |||
| final FileSet fileSet = (FileSet)m_filesets.get( i ); | |||
| final DirectoryScanner scanner = getScanner( fileSet ); | |||
| dss.add( scanner ); | |||
| } | |||
| int dssSize = dss.size(); | |||
| FileScanner[] scanners = new FileScanner[ dssSize ]; | |||
| @@ -350,7 +351,8 @@ public class Zip | |||
| // before we added any files, then we must swallow this exception. Otherwise, | |||
| // the error that's reported will be the close() error, which is not the real | |||
| // cause of the problem. | |||
| if( success ) { | |||
| if( success ) | |||
| { | |||
| throw ex; | |||
| } | |||
| } | |||
| @@ -390,6 +392,20 @@ public class Zip | |||
| } | |||
| } | |||
| private DirectoryScanner getScanner( final FileSet fileSet ) | |||
| throws TaskException | |||
| { | |||
| if( fileSet instanceof ZipFileSet ) | |||
| { | |||
| final ZipFileSet zipFileSet = (ZipFileSet)fileSet; | |||
| return ScannerUtil.getZipScanner( zipFileSet ); | |||
| } | |||
| else | |||
| { | |||
| return ScannerUtil.getDirectoryScanner( fileSet ); | |||
| } | |||
| } | |||
| protected void addFileAs( final File file, final String name ) | |||
| throws TaskException | |||
| { | |||
| @@ -457,7 +473,8 @@ public class Zip | |||
| } | |||
| } | |||
| if( !zipFile.exists() ) { | |||
| if( !zipFile.exists() ) | |||
| { | |||
| return false; | |||
| } | |||
| @@ -468,7 +485,7 @@ public class Zip | |||
| for( int i = 0; i < scanners.length; i++ ) | |||
| { | |||
| if( scanner.restrict( fileNames[ i ], scanners[ i ].getBasedir(), null, | |||
| mm ).length > 0 ) | |||
| mm ).length > 0 ) | |||
| { | |||
| return false; | |||
| } | |||
| @@ -493,7 +510,8 @@ public class Zip | |||
| String prefix, String fullpath ) | |||
| throws IOException, TaskException | |||
| { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) | |||
| { | |||
| throw new TaskException( "Both prefix and fullpath attributes may not be set on the same fileset." ); | |||
| } | |||
| @@ -501,7 +519,8 @@ public class Zip | |||
| // directories that matched include patterns | |||
| String[] dirs = scanner.getIncludedDirectories(); | |||
| if( dirs.length > 0 && fullpath.length() > 0 ) { | |||
| if( dirs.length > 0 && fullpath.length() > 0 ) | |||
| { | |||
| throw new TaskException( "fullpath attribute may only be specified for filesets that specify a single file." ); | |||
| } | |||
| for( int i = 0; i < dirs.length; i++ ) | |||
| @@ -520,7 +539,8 @@ public class Zip | |||
| // files that matched include patterns | |||
| String[] files = scanner.getIncludedFiles(); | |||
| if( files.length > 1 && fullpath.length() > 0 ) { | |||
| if( files.length > 1 && fullpath.length() > 0 ) | |||
| { | |||
| throw new TaskException( "fullpath attribute may only be specified for filesets that specify a single file." ); | |||
| } | |||
| for( int i = 0; i < files.length; i++ ) | |||
| @@ -557,7 +577,7 @@ public class Zip | |||
| for( int i = 0; i < filesets.size(); i++ ) | |||
| { | |||
| FileSet fs = (FileSet)filesets.get( i ); | |||
| DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fs ); | |||
| DirectoryScanner ds = getScanner( fs ); | |||
| String prefix = ""; | |||
| String fullpath = ""; | |||
| @@ -649,7 +669,8 @@ public class Zip | |||
| ZipOutputStream zOut, String prefix, String fullpath ) | |||
| throws IOException, TaskException | |||
| { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) | |||
| { | |||
| throw new TaskException( "Both prefix and fullpath attributes may not be set on the same fileset." ); | |||
| } | |||
| @@ -941,7 +941,7 @@ public class Javadoc | |||
| } | |||
| FileSet fs = new FileSet(); | |||
| fs.setDefaultexcludes( m_useDefaultExcludes ); | |||
| fs.setDefaultExcludes( m_useDefaultExcludes ); | |||
| Iterator e = packages.iterator(); | |||
| while( e.hasNext() ) | |||
| @@ -48,15 +48,13 @@ public class Chmod | |||
| * @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( boolean useDefaultExcludes ) | |||
| { | |||
| m_defaultSetDefined = true; | |||
| m_defaultSet.setDefaultexcludes( useDefaultExcludes ); | |||
| m_defaultSet.setDefaultExcludes( useDefaultExcludes ); | |||
| } | |||
| public void setDir( File src ) | |||
| throws TaskException | |||
| { | |||
| m_defaultSet.setDir( src ); | |||
| } | |||
| @@ -78,7 +76,6 @@ public class Chmod | |||
| } | |||
| public void setFile( File src ) | |||
| throws TaskException | |||
| { | |||
| final FileSet fileSet = new FileSet(); | |||
| fileSet.setDir( new File( src.getParent() ) ); | |||
| @@ -8,9 +8,6 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.Project; | |||
| /** | |||
| * A ZipFileSet is a FileSet with extra attributes useful in the context of | |||
| @@ -25,43 +22,23 @@ import org.apache.tools.ant.Project; | |||
| * task, and attributes in the refering ZipFileSet can augment FileSet | |||
| * definition. | |||
| * | |||
| * @author Don Ferguson <a href="mailto:don@bea.com">don@bea.com</a> | |||
| * @author <a href="mailto:don@bea.com">Don Ferguson</a> | |||
| */ | |||
| public class ZipFileSet | |||
| extends FileSet | |||
| { | |||
| private File srcFile = null; | |||
| private String prefix = ""; | |||
| private String fullpath = ""; | |||
| private boolean hasDir = false; | |||
| /** | |||
| * Set the directory for the fileset. Prevents both "dir" and "src" from | |||
| * being specified. | |||
| */ | |||
| public void setDir( final File dir ) | |||
| throws TaskException | |||
| { | |||
| if( srcFile != null ) | |||
| { | |||
| final String message = "Cannot set both dir and src attributes"; | |||
| throw new TaskException( message ); | |||
| } | |||
| else | |||
| { | |||
| super.setDir( dir ); | |||
| hasDir = true; | |||
| } | |||
| } | |||
| private File m_src; | |||
| private String m_prefix = ""; | |||
| private String m_fullpath = ""; | |||
| /** | |||
| * Set the full pathname of the single entry in this fileset. | |||
| * | |||
| * @param fullpath The new Fullpath value | |||
| */ | |||
| public void setFullpath( String fullpath ) | |||
| public void setFullpath( final String fullpath ) | |||
| { | |||
| this.fullpath = fullpath; | |||
| m_fullpath = fullpath; | |||
| } | |||
| /** | |||
| @@ -70,9 +47,9 @@ public class ZipFileSet | |||
| * | |||
| * @param prefix The prefix to prepend to entries in the zip file. | |||
| */ | |||
| public void setPrefix( String prefix ) | |||
| public void setPrefix( final String prefix ) | |||
| { | |||
| this.prefix = prefix; | |||
| m_prefix = prefix; | |||
| } | |||
| /** | |||
| @@ -81,40 +58,9 @@ public class ZipFileSet | |||
| * | |||
| * @param srcFile The zip file from which to extract entries. | |||
| */ | |||
| public void setSrc( File srcFile ) | |||
| throws TaskException | |||
| { | |||
| if( hasDir ) | |||
| { | |||
| throw new TaskException( "Cannot set both dir and src attributes" ); | |||
| } | |||
| this.srcFile = srcFile; | |||
| } | |||
| /** | |||
| * Return the DirectoryScanner associated with this FileSet. If the | |||
| * ZipFileSet defines a source Zip file, then a ZipScanner is returned | |||
| * instead. | |||
| * | |||
| * @param p Description of Parameter | |||
| * @return The DirectoryScanner value | |||
| */ | |||
| public DirectoryScanner getDirectoryScanner( Project p ) | |||
| throws TaskException | |||
| public void setSrc( final File src ) | |||
| { | |||
| if( srcFile != null ) | |||
| { | |||
| final ZipScanner zs = new ZipScanner(); | |||
| zs.setSrc( srcFile ); | |||
| super.setDir( p.getBaseDir() ); | |||
| ScannerUtil.setupDirectoryScanner( this, zs, null ); | |||
| zs.init(); | |||
| return zs; | |||
| } | |||
| else | |||
| { | |||
| return ScannerUtil.getDirectoryScanner( this ); | |||
| } | |||
| m_src = src; | |||
| } | |||
| /** | |||
| @@ -124,7 +70,7 @@ public class ZipFileSet | |||
| */ | |||
| public String getFullpath() | |||
| { | |||
| return fullpath; | |||
| return m_fullpath; | |||
| } | |||
| /** | |||
| @@ -134,7 +80,7 @@ public class ZipFileSet | |||
| */ | |||
| public String getPrefix() | |||
| { | |||
| return prefix; | |||
| return m_prefix; | |||
| } | |||
| /** | |||
| @@ -146,6 +92,6 @@ public class ZipFileSet | |||
| */ | |||
| public File getSrc() | |||
| { | |||
| return srcFile; | |||
| return m_src; | |||
| } | |||
| } | |||
| @@ -10,27 +10,25 @@ package org.apache.tools.ant.taskdefs; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Pattern; | |||
| import org.apache.myrmidon.framework.PatternSet; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.ScannerUtil; | |||
| import org.apache.myrmidon.framework.PatternSet; | |||
| /** | |||
| * This is an abstract task that should be used by all those tasks that require | |||
| * to include or exclude files based on pattern matching. | |||
| * | |||
| * @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> | |||
| * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org"> | |||
| * stefano@apache.org</a> | |||
| * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> | |||
| * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | |||
| * @author <a href="mailto:ajkuiper@wxs.nl">Arnout J. Kuiper</a> | |||
| * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a> | |||
| * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> | |||
| * @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a> | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| */ | |||
| public abstract class MatchingTask | |||
| extends Task | |||
| { | |||
| private boolean m_useDefaultExcludes = true; | |||
| private FileSet m_fileset = new FileSet(); | |||
| /** | |||
| @@ -38,7 +36,7 @@ public abstract class MatchingTask | |||
| */ | |||
| public void setDefaultexcludes( final boolean useDefaultExcludes ) | |||
| { | |||
| m_useDefaultExcludes = useDefaultExcludes; | |||
| m_fileset.setDefaultExcludes( useDefaultExcludes ); | |||
| } | |||
| /** | |||
| @@ -48,7 +46,6 @@ public abstract class MatchingTask | |||
| * @param excludes the string containing the exclude patterns | |||
| */ | |||
| public void setExcludes( final String excludes ) | |||
| throws TaskException | |||
| { | |||
| m_fileset.setExcludes( excludes ); | |||
| } | |||
| @@ -60,7 +57,6 @@ public abstract class MatchingTask | |||
| * @param includes the string containing the include patterns | |||
| */ | |||
| public void setIncludes( final String includes ) | |||
| throws TaskException | |||
| { | |||
| m_fileset.setIncludes( includes ); | |||
| } | |||
| @@ -100,7 +96,6 @@ public abstract class MatchingTask | |||
| throws TaskException | |||
| { | |||
| m_fileset.setDir( baseDir ); | |||
| m_fileset.setDefaultexcludes( m_useDefaultExcludes ); | |||
| return ScannerUtil.getDirectoryScanner( m_fileset ); | |||
| } | |||
| } | |||
| @@ -20,17 +20,17 @@ import java.util.Hashtable; | |||
| import java.util.Stack; | |||
| import java.util.zip.CRC32; | |||
| import java.util.zip.ZipInputStream; | |||
| import org.apache.aut.zip.ZipEntry; | |||
| import org.apache.aut.zip.ZipOutputStream; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.DirectoryScanner; | |||
| import org.apache.tools.ant.types.FileScanner; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.ScannerUtil; | |||
| import org.apache.tools.ant.types.SourceFileScanner; | |||
| import org.apache.tools.ant.types.ZipFileSet; | |||
| import org.apache.tools.ant.types.ZipScanner; | |||
| import org.apache.tools.ant.types.ScannerUtil; | |||
| import org.apache.tools.ant.util.mappers.MergingMapper; | |||
| import org.apache.aut.zip.ZipEntry; | |||
| import org.apache.aut.zip.ZipOutputStream; | |||
| /** | |||
| * Create a ZIP archive. | |||
| @@ -266,8 +266,9 @@ public class Zip | |||
| } | |||
| for( int i = 0; i < m_filesets.size(); i++ ) | |||
| { | |||
| FileSet fs = (FileSet)m_filesets.get( i ); | |||
| dss.add( ScannerUtil.getDirectoryScanner( fs ) ); | |||
| final FileSet fileSet = (FileSet)m_filesets.get( i ); | |||
| final DirectoryScanner scanner = getScanner( fileSet ); | |||
| dss.add( scanner ); | |||
| } | |||
| int dssSize = dss.size(); | |||
| FileScanner[] scanners = new FileScanner[ dssSize ]; | |||
| @@ -350,7 +351,8 @@ public class Zip | |||
| // before we added any files, then we must swallow this exception. Otherwise, | |||
| // the error that's reported will be the close() error, which is not the real | |||
| // cause of the problem. | |||
| if( success ) { | |||
| if( success ) | |||
| { | |||
| throw ex; | |||
| } | |||
| } | |||
| @@ -390,6 +392,20 @@ public class Zip | |||
| } | |||
| } | |||
| private DirectoryScanner getScanner( final FileSet fileSet ) | |||
| throws TaskException | |||
| { | |||
| if( fileSet instanceof ZipFileSet ) | |||
| { | |||
| final ZipFileSet zipFileSet = (ZipFileSet)fileSet; | |||
| return ScannerUtil.getZipScanner( zipFileSet ); | |||
| } | |||
| else | |||
| { | |||
| return ScannerUtil.getDirectoryScanner( fileSet ); | |||
| } | |||
| } | |||
| protected void addFileAs( final File file, final String name ) | |||
| throws TaskException | |||
| { | |||
| @@ -457,7 +473,8 @@ public class Zip | |||
| } | |||
| } | |||
| if( !zipFile.exists() ) { | |||
| if( !zipFile.exists() ) | |||
| { | |||
| return false; | |||
| } | |||
| @@ -468,7 +485,7 @@ public class Zip | |||
| for( int i = 0; i < scanners.length; i++ ) | |||
| { | |||
| if( scanner.restrict( fileNames[ i ], scanners[ i ].getBasedir(), null, | |||
| mm ).length > 0 ) | |||
| mm ).length > 0 ) | |||
| { | |||
| return false; | |||
| } | |||
| @@ -493,7 +510,8 @@ public class Zip | |||
| String prefix, String fullpath ) | |||
| throws IOException, TaskException | |||
| { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) | |||
| { | |||
| throw new TaskException( "Both prefix and fullpath attributes may not be set on the same fileset." ); | |||
| } | |||
| @@ -501,7 +519,8 @@ public class Zip | |||
| // directories that matched include patterns | |||
| String[] dirs = scanner.getIncludedDirectories(); | |||
| if( dirs.length > 0 && fullpath.length() > 0 ) { | |||
| if( dirs.length > 0 && fullpath.length() > 0 ) | |||
| { | |||
| throw new TaskException( "fullpath attribute may only be specified for filesets that specify a single file." ); | |||
| } | |||
| for( int i = 0; i < dirs.length; i++ ) | |||
| @@ -520,7 +539,8 @@ public class Zip | |||
| // files that matched include patterns | |||
| String[] files = scanner.getIncludedFiles(); | |||
| if( files.length > 1 && fullpath.length() > 0 ) { | |||
| if( files.length > 1 && fullpath.length() > 0 ) | |||
| { | |||
| throw new TaskException( "fullpath attribute may only be specified for filesets that specify a single file." ); | |||
| } | |||
| for( int i = 0; i < files.length; i++ ) | |||
| @@ -557,7 +577,7 @@ public class Zip | |||
| for( int i = 0; i < filesets.size(); i++ ) | |||
| { | |||
| FileSet fs = (FileSet)filesets.get( i ); | |||
| DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fs ); | |||
| DirectoryScanner ds = getScanner( fs ); | |||
| String prefix = ""; | |||
| String fullpath = ""; | |||
| @@ -649,7 +669,8 @@ public class Zip | |||
| ZipOutputStream zOut, String prefix, String fullpath ) | |||
| throws IOException, TaskException | |||
| { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) { | |||
| if( prefix.length() > 0 && fullpath.length() > 0 ) | |||
| { | |||
| throw new TaskException( "Both prefix and fullpath attributes may not be set on the same fileset." ); | |||
| } | |||
| @@ -941,7 +941,7 @@ public class Javadoc | |||
| } | |||
| FileSet fs = new FileSet(); | |||
| fs.setDefaultexcludes( m_useDefaultExcludes ); | |||
| fs.setDefaultExcludes( m_useDefaultExcludes ); | |||
| Iterator e = packages.iterator(); | |||
| while( e.hasNext() ) | |||
| @@ -48,15 +48,13 @@ public class Chmod | |||
| * @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( boolean useDefaultExcludes ) | |||
| { | |||
| m_defaultSetDefined = true; | |||
| m_defaultSet.setDefaultexcludes( useDefaultExcludes ); | |||
| m_defaultSet.setDefaultExcludes( useDefaultExcludes ); | |||
| } | |||
| public void setDir( File src ) | |||
| throws TaskException | |||
| { | |||
| m_defaultSet.setDir( src ); | |||
| } | |||
| @@ -78,7 +76,6 @@ public class Chmod | |||
| } | |||
| public void setFile( File src ) | |||
| throws TaskException | |||
| { | |||
| final FileSet fileSet = new FileSet(); | |||
| fileSet.setDir( new File( src.getParent() ) ); | |||
| @@ -8,9 +8,6 @@ | |||
| package org.apache.tools.ant.types; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.ant.Project; | |||
| /** | |||
| * A ZipFileSet is a FileSet with extra attributes useful in the context of | |||
| @@ -25,43 +22,23 @@ import org.apache.tools.ant.Project; | |||
| * task, and attributes in the refering ZipFileSet can augment FileSet | |||
| * definition. | |||
| * | |||
| * @author Don Ferguson <a href="mailto:don@bea.com">don@bea.com</a> | |||
| * @author <a href="mailto:don@bea.com">Don Ferguson</a> | |||
| */ | |||
| public class ZipFileSet | |||
| extends FileSet | |||
| { | |||
| private File srcFile = null; | |||
| private String prefix = ""; | |||
| private String fullpath = ""; | |||
| private boolean hasDir = false; | |||
| /** | |||
| * Set the directory for the fileset. Prevents both "dir" and "src" from | |||
| * being specified. | |||
| */ | |||
| public void setDir( final File dir ) | |||
| throws TaskException | |||
| { | |||
| if( srcFile != null ) | |||
| { | |||
| final String message = "Cannot set both dir and src attributes"; | |||
| throw new TaskException( message ); | |||
| } | |||
| else | |||
| { | |||
| super.setDir( dir ); | |||
| hasDir = true; | |||
| } | |||
| } | |||
| private File m_src; | |||
| private String m_prefix = ""; | |||
| private String m_fullpath = ""; | |||
| /** | |||
| * Set the full pathname of the single entry in this fileset. | |||
| * | |||
| * @param fullpath The new Fullpath value | |||
| */ | |||
| public void setFullpath( String fullpath ) | |||
| public void setFullpath( final String fullpath ) | |||
| { | |||
| this.fullpath = fullpath; | |||
| m_fullpath = fullpath; | |||
| } | |||
| /** | |||
| @@ -70,9 +47,9 @@ public class ZipFileSet | |||
| * | |||
| * @param prefix The prefix to prepend to entries in the zip file. | |||
| */ | |||
| public void setPrefix( String prefix ) | |||
| public void setPrefix( final String prefix ) | |||
| { | |||
| this.prefix = prefix; | |||
| m_prefix = prefix; | |||
| } | |||
| /** | |||
| @@ -81,40 +58,9 @@ public class ZipFileSet | |||
| * | |||
| * @param srcFile The zip file from which to extract entries. | |||
| */ | |||
| public void setSrc( File srcFile ) | |||
| throws TaskException | |||
| { | |||
| if( hasDir ) | |||
| { | |||
| throw new TaskException( "Cannot set both dir and src attributes" ); | |||
| } | |||
| this.srcFile = srcFile; | |||
| } | |||
| /** | |||
| * Return the DirectoryScanner associated with this FileSet. If the | |||
| * ZipFileSet defines a source Zip file, then a ZipScanner is returned | |||
| * instead. | |||
| * | |||
| * @param p Description of Parameter | |||
| * @return The DirectoryScanner value | |||
| */ | |||
| public DirectoryScanner getDirectoryScanner( Project p ) | |||
| throws TaskException | |||
| public void setSrc( final File src ) | |||
| { | |||
| if( srcFile != null ) | |||
| { | |||
| final ZipScanner zs = new ZipScanner(); | |||
| zs.setSrc( srcFile ); | |||
| super.setDir( p.getBaseDir() ); | |||
| ScannerUtil.setupDirectoryScanner( this, zs, null ); | |||
| zs.init(); | |||
| return zs; | |||
| } | |||
| else | |||
| { | |||
| return ScannerUtil.getDirectoryScanner( this ); | |||
| } | |||
| m_src = src; | |||
| } | |||
| /** | |||
| @@ -124,7 +70,7 @@ public class ZipFileSet | |||
| */ | |||
| public String getFullpath() | |||
| { | |||
| return fullpath; | |||
| return m_fullpath; | |||
| } | |||
| /** | |||
| @@ -134,7 +80,7 @@ public class ZipFileSet | |||
| */ | |||
| public String getPrefix() | |||
| { | |||
| return prefix; | |||
| return m_prefix; | |||
| } | |||
| /** | |||
| @@ -146,6 +92,6 @@ public class ZipFileSet | |||
| */ | |||
| public File getSrc() | |||
| { | |||
| return srcFile; | |||
| return m_src; | |||
| } | |||
| } | |||