ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Tar.java Taskdef.java Typedef.java
Date Fri, 12 Apr 2002 13:32:27 GMT
bodewig     02/04/12 06:32:27

  Modified:    src/main/org/apache/tools/ant/taskdefs Tar.java Taskdef.java
                        Typedef.java
  Log:
  Make sure <tar> resets its state.
  
  Revision  Changes    Path
  1.27      +90 -74    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tar.java
  
  Index: Tar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tar.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Tar.java	3 Mar 2002 01:46:20 -0000	1.26
  +++ Tar.java	12 Apr 2002 13:32:27 -0000	1.27
  @@ -78,6 +78,8 @@
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
    *
  + * @since Ant 1.1
  + *
    * @ant.task category="packaging"
    */
   
  @@ -140,11 +142,11 @@
   
       /**
        * Sets the destfile attribute.
  -     * @since 1.22 ant 1.5
  +     * @since Ant 1.5
        * @param destFile The output of the tar
        */
       public void setDestFile(File destFile) {
  -       this.tarFile = destFile;
  +        this.tarFile = destFile;
       }
   
       /**
  @@ -205,89 +207,101 @@
                                        location);
           }
   
  -        if (baseDir != null) {
  -            if (!baseDir.exists()) {
  -                throw new BuildException("basedir does not exist!", location);
  -            }
  -
  -            // add the main fileset to the list of filesets to process.
  -            TarFileSet mainFileSet = new TarFileSet(fileset);
  -            mainFileSet.setDir(baseDir);
  -            filesets.addElement(mainFileSet);
  -        }
  +        Vector savedFileSets = (Vector) filesets.clone();
  +        try {
  +            if (baseDir != null) {
  +                if (!baseDir.exists()) {
  +                    throw new BuildException("basedir does not exist!", 
  +                                             location);
  +                }
   
  -        if (filesets.size() == 0) {
  -            throw new BuildException("You must supply either a basdir attribute or some
nested filesets.",
  -                                     location);
  -        }
  +                // add the main fileset to the list of filesets to process.
  +                TarFileSet mainFileSet = new TarFileSet(fileset);
  +                mainFileSet.setDir(baseDir);
  +                filesets.addElement(mainFileSet);
  +            }
   
  -        // check if tr is out of date with respect to each
  -        // fileset
  -        boolean upToDate = true;
  -        for (Enumeration e = filesets.elements(); e.hasMoreElements();) {
  -            TarFileSet fs = (TarFileSet)e.nextElement();
  -            String[] files = fs.getFiles(project);
  +            if (filesets.size() == 0) {
  +                throw new BuildException("You must supply either a basedir "
  +                                         + "attribute or some nested filesets.",
  +                                         location);
  +            }
  +            
  +            // check if tar is out of date with respect to each
  +            // fileset
  +            boolean upToDate = true;
  +            for (Enumeration e = filesets.elements(); e.hasMoreElements();) {
  +                TarFileSet fs = (TarFileSet)e.nextElement();
  +                String[] files = fs.getFiles(project);
   
  -            if (!archiveIsUpToDate(files)) {
  -                upToDate = false;
  -            }
  +                if (!archiveIsUpToDate(files)) {
  +                    upToDate = false;
  +                }
   
  -            for (int i = 0; i < files.length; ++i) {
  -                if (tarFile.equals(new File(fs.getDir(project), files[i]))) {
  -                    throw new BuildException("A tar file cannot include itself", location);
  +                for (int i = 0; i < files.length; ++i) {
  +                    if (tarFile.equals(new File(fs.getDir(project), 
  +                                                files[i]))) {
  +                        throw new BuildException("A tar file cannot include "
  +                                                 + "itself", location);
  +                    }
                   }
               }
  -        }
   
  -        if (upToDate) {
  -            log("Nothing to do: "+tarFile.getAbsolutePath()+" is up to date.",
  -                Project.MSG_INFO);
  -            return;
  -        }
  +            if (upToDate) {
  +                log("Nothing to do: "+tarFile.getAbsolutePath()
  +                    +" is up to date.", Project.MSG_INFO);
  +                return;
  +            }
   
  -        log("Building tar: "+ tarFile.getAbsolutePath(), Project.MSG_INFO);
  +            log("Building tar: "+ tarFile.getAbsolutePath(), Project.MSG_INFO);
   
  -        TarOutputStream tOut = null;
  -        try {
  -            tOut = new TarOutputStream(new FileOutputStream(tarFile));
  -            tOut.setDebug(true);
  -            if (longFileMode.isTruncateMode()) {
  -                tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
  -            }
  -            else if (longFileMode.isFailMode() ||
  -                     longFileMode.isOmitMode()) {
  -                tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
  -            }
  -            else {
  -                // warn or GNU
  -                tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
  -            }
  +            TarOutputStream tOut = null;
  +            try {
  +                tOut = new TarOutputStream(new FileOutputStream(tarFile));
  +                tOut.setDebug(true);
  +                if (longFileMode.isTruncateMode()) {
  +                    tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
  +                }
  +                else if (longFileMode.isFailMode() ||
  +                         longFileMode.isOmitMode()) {
  +                    tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
  +                }
  +                else {
  +                    // warn or GNU
  +                    tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
  +                }
   
  -            longWarningGiven = false;
  -            for (Enumeration e = filesets.elements(); e.hasMoreElements();) {
  -                TarFileSet fs = (TarFileSet)e.nextElement();
  -                String[] files = fs.getFiles(project);
  -                if (files.length > 1 && fs.getFullpath().length() > 0) {
  -                    throw new BuildException("fullpath attribute may only be specified
for " +
  -                                             "filesets that specify a single file.");
  +                longWarningGiven = false;
  +                for (Enumeration e = filesets.elements(); 
  +                     e.hasMoreElements();) {
  +                    TarFileSet fs = (TarFileSet)e.nextElement();
  +                    String[] files = fs.getFiles(project);
  +                    if (files.length > 1 && fs.getFullpath().length() > 0)
{
  +                        throw new BuildException("fullpath attribute may only "
  +                                                 + "be specified for " 
  +                                                 + "filesets that specify a "
  +                                                 + "single file.");
  +                    }
  +                    for (int i = 0; i < files.length; i++) {
  +                        File f = new File(fs.getDir(project), files[i]);
  +                        String name = files[i].replace(File.separatorChar,'/');
  +                        tarFile(f, tOut, name, fs);
  +                    }
                   }
  -                for (int i = 0; i < files.length; i++) {
  -                    File f = new File(fs.getDir(project), files[i]);
  -                    String name = files[i].replace(File.separatorChar,'/');
  -                    tarFile(f, tOut, name, fs);
  +            } catch (IOException ioe) {
  +                String msg = "Problem creating TAR: " + ioe.getMessage();
  +                throw new BuildException(msg, ioe, location);
  +            } finally {
  +                if (tOut != null) {
  +                    try {
  +                        // close up
  +                        tOut.close();
  +                    }
  +                    catch (IOException e) {}
                   }
               }
  -        } catch (IOException ioe) {
  -            String msg = "Problem creating TAR: " + ioe.getMessage();
  -            throw new BuildException(msg, ioe, location);
           } finally {
  -            if (tOut != null) {
  -                try {
  -                    // close up
  -                    tOut.close();
  -                }
  -                catch (IOException e) {}
  -            }
  +            filesets = savedFileSets;
           }
       }
   
  @@ -334,10 +348,12 @@
                       return;
                   } else if (longFileMode.isWarnMode()) {
                       log("Entry: "+ vPath + " longer than " +
  -                        TarConstants.NAMELEN + " characters.", Project.MSG_WARN);
  +                        TarConstants.NAMELEN + " characters.", 
  +                        Project.MSG_WARN);
                       if (!longWarningGiven) {
  -                        log("Resulting tar file can only be processed successfully"
  -                            + " by GNU compatible tar commands", Project.MSG_WARN);
  +                        log("Resulting tar file can only be processed "
  +                            + "successfully by GNU compatible tar commands", 
  +                            Project.MSG_WARN);
                           longWarningGiven = true;
                       }
                   } else if (longFileMode.isFailMode()) {
  
  
  
  1.22      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Taskdef.java
  
  Index: Taskdef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Taskdef.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Taskdef.java	12 Apr 2002 13:26:50 -0000	1.21
  +++ Taskdef.java	12 Apr 2002 13:32:27 -0000	1.22
  @@ -60,7 +60,7 @@
    * Define a new task.
    *
    * @author <a href="stefan.bodewig@epost.de">Stefan Bodewig</a>
  - *
  + * @since Ant 1.1
    * @ant.task category="internal"
    */
   public class Taskdef extends Definer {
  
  
  
  1.7       +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Typedef.java
  
  Index: Typedef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Typedef.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Typedef.java	12 Apr 2002 13:26:50 -0000	1.6
  +++ Typedef.java	12 Apr 2002 13:32:27 -0000	1.7
  @@ -60,7 +60,7 @@
    * Define a new data type.
    *
    * @author <a href="stefan.bodewig@epost.de">Stefan Bodewig</a>
  - *
  + * @since Ant 1.4
    * @ant.task category="internal"
    */
   public class Typedef extends Definer {
  
  
  

--
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