ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix Chmod.java
Date Sun, 27 Jan 2002 09:42:39 GMT
donaldp     02/01/27 01:42:39

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/types
                        ZipFileSet.java
               proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs
                        Zip.java MatchingTask.java
               proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix
                        Chmod.java
  Log:
  Update classes for recent changes in fileset/scanner separation
  
  Revision  Changes    Path
  1.8       +13 -67    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java
  
  Index: ZipFileSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ZipFileSet.java	26 Jan 2002 02:07:36 -0000	1.7
  +++ ZipFileSet.java	27 Jan 2002 09:42:39 -0000	1.8
  @@ -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 @@
    * 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 @@
        *
        * @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 @@
        *
        * @param srcFile The zip file from which to extract entries.
        */
  -    public void setSrc( File srcFile )
  -        throws TaskException
  +    public void setSrc( final File src )
       {
  -        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
  -    {
  -        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 String getFullpath()
       {
  -        return fullpath;
  +        return m_fullpath;
       }
   
       /**
  @@ -134,7 +80,7 @@
        */
       public String getPrefix()
       {
  -        return prefix;
  +        return m_prefix;
       }
   
       /**
  @@ -146,6 +92,6 @@
        */
       public File getSrc()
       {
  -        return srcFile;
  +        return m_src;
       }
   }
  
  
  
  1.20      +34 -13    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java
  
  Index: Zip.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Zip.java	26 Jan 2002 02:08:10 -0000	1.19
  +++ Zip.java	27 Jan 2002 09:42:39 -0000	1.20
  @@ -20,17 +20,17 @@
   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 @@
           }
           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 @@
                       // 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 @@
           }
       }
   
  +    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 @@
                   }
               }
   
  -            if( !zipFile.exists() ) {
  +            if( !zipFile.exists() )
  +            {
                   return false;
               }
   
  @@ -468,7 +485,7 @@
               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 @@
                                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 @@
   
           // 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 @@
   
           // 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 @@
           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 @@
                                     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." );
           }
   
  
  
  
  1.16      +6 -11     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
  
  Index: MatchingTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- MatchingTask.java	26 Jan 2002 02:08:10 -0000	1.15
  +++ MatchingTask.java	27 Jan 2002 09:42:39 -0000	1.16
  @@ -10,27 +10,25 @@
   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 void setDefaultexcludes( final boolean useDefaultExcludes )
       {
  -        m_useDefaultExcludes = useDefaultExcludes;
  +        m_fileset.setDefaultExcludes( useDefaultExcludes );
       }
   
       /**
  @@ -48,7 +46,6 @@
        * @param excludes the string containing the exclude patterns
        */
       public void setExcludes( final String excludes )
  -        throws TaskException
       {
           m_fileset.setExcludes( excludes );
       }
  @@ -60,7 +57,6 @@
        * @param includes the string containing the include patterns
        */
       public void setIncludes( final String includes )
  -        throws TaskException
       {
           m_fileset.setIncludes( includes );
       }
  @@ -100,7 +96,6 @@
           throws TaskException
       {
           m_fileset.setDir( baseDir );
  -        m_fileset.setDefaultexcludes( m_useDefaultExcludes );
           return ScannerUtil.getDirectoryScanner( m_fileset );
       }
   }
  
  
  
  1.14      +2 -5      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java
  
  Index: Chmod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Chmod.java	26 Jan 2002 02:08:11 -0000	1.13
  +++ Chmod.java	27 Jan 2002 09:42:39 -0000	1.14
  @@ -48,15 +48,13 @@
        * @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 void setFile( File src )
  -        throws TaskException
       {
           final FileSet fileSet = new FileSet();
           fileSet.setDir( new File( src.getParent() ) );
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message