You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2001/12/11 15:55:45 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Ear.java War.java Zip.java

bodewig     01/12/11 06:55:45

  Modified:    docs/manual/CoreTasks ear.html war.html
               src/main/org/apache/tools/ant/taskdefs Ear.java War.java
                        Zip.java
  Log:
  Don't require webxml in <war> or appxml in <ear> if updating an
  existing archive.
  
  Submitted by:	Stefano Mancarella <ma...@opoipi.bancaintesa.it>
  
  Revision  Changes    Path
  1.9       +1 -1      jakarta-ant/docs/manual/CoreTasks/ear.html
  
  Index: ear.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/ear.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ear.html	2001/11/08 16:16:08	1.8
  +++ ear.html	2001/12/11 14:55:45	1.9
  @@ -31,7 +31,7 @@
     <tr>
       <td valign="top">appxml</td>
       <td valign="top">The deployment descriptor to use (META-INF/application.xml).</td>
  -    <td valign="top" align="center">Yes</td>
  +    <td valign="top" align="center">Yes, unless update is set to true</td>
     </tr>
     <tr>
       <td valign="top">basedir</td>
  
  
  
  1.10      +1 -1      jakarta-ant/docs/manual/CoreTasks/war.html
  
  Index: war.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/war.html,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- war.html	2001/11/08 16:16:08	1.9
  +++ war.html	2001/12/11 14:55:45	1.10
  @@ -33,7 +33,7 @@
     <tr>
       <td valign="top">webxml</td>
       <td valign="top">The deployment descriptor to use (WEB-INF/web.xml).</td>
  -    <td valign="top" align="center">Yes</td>
  +    <td valign="top" align="center">Yes, unless update is set to true</td>
     </tr>
     <tr>
       <td valign="top">basedir</td>
  
  
  
  1.5       +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ear.java
  
  Index: Ear.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ear.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Ear.java	2001/10/28 21:26:29	1.4
  +++ Ear.java	2001/12/11 14:55:45	1.5
  @@ -111,7 +111,7 @@
           throws IOException, BuildException
       {
           // If no webxml file is specified, it's an error.
  -        if (deploymentDescriptor == null) {
  +        if (deploymentDescriptor == null && !isInUpdateMode()) {
               throw new BuildException("appxml attribute is required", location);
           }
           
  
  
  
  1.15      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/War.java
  
  Index: War.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/War.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- War.java	2001/10/28 21:26:29	1.14
  +++ War.java	2001/12/11 14:55:45	1.15
  @@ -119,7 +119,7 @@
           throws IOException, BuildException
       {
           // If no webxml file is specified, it's an error.
  -        if (deploymentDescriptor == null) {
  +        if (deploymentDescriptor == null && !isInUpdateMode()) {
               throw new BuildException("webxml attribute is required", location);
           }
           
  
  
  
  1.56      +17 -20    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
  
  Index: Zip.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- Zip.java	2001/11/01 19:33:13	1.55
  +++ Zip.java	2001/12/11 14:55:45	1.56
  @@ -76,6 +76,7 @@
   import org.apache.tools.ant.types.EnumeratedAttribute;
   import org.apache.tools.ant.types.ZipFileSet;
   import org.apache.tools.ant.types.ZipScanner;
  +import org.apache.tools.ant.util.FileUtils;
   import org.apache.tools.ant.util.SourceFileScanner;
   import org.apache.tools.ant.util.MergingMapper;
   import org.apache.tools.zip.ZipOutputStream;
  @@ -166,6 +167,13 @@
       }
   
       /**
  +     * Are we updating an existing archive?
  +     */
  +    public boolean isInUpdateMode() {
  +        return doUpdate;
  +    }
  +
  +    /**
        * Adds a set of files (nested fileset attribute).
        */
       public void addFileset(FileSet set) {
  @@ -228,23 +236,12 @@
           // we don't need to update if the original file doesn't exist
   
           addingNewFiles = true;
  -        boolean reallyDoUpdate = false;
  -        if (doUpdate && zipFile.exists())
  +        doUpdate = doUpdate && zipFile.exists();
  +        if (doUpdate)
           {
  -            reallyDoUpdate = true;
  -
  -            int i;
  -            for (i=0; i < 1000; i++)
  -            {
  -                renamedFile = new File(zipFile.getParent(), "tmp."+i);
  -
  -                if (!renamedFile.exists()) {
  -                    break;
  -                }
  -            }
  -            if (i == 1000) {
  -                throw new BuildException("Can't find available temporary filename to which to rename old file.");
  -            }
  +            FileUtils fileUtils = FileUtils.newFileUtils();
  +            renamedFile = fileUtils.createTempFile("zip", ".tmp",
  +                                                   fileUtils.getParentFile(zipFile));
   
               try
               {
  @@ -277,7 +274,7 @@
               return;
           }
   
  -        String action = reallyDoUpdate ? "Updating " : "Building ";
  +        String action = doUpdate ? "Updating " : "Building ";
   
           log(action + archiveType +": "+ zipFile.getAbsolutePath());
   
  @@ -300,7 +297,7 @@
                   }
                   // Add the explicit filesets to the archive.
                   addFiles(filesets, zOut);
  -                if (reallyDoUpdate) {
  +                if (doUpdate) {
                       addingNewFiles = false;
                       ZipFileSet oldFiles = new ZipFileSet();
                       oldFiles.setSrc(renamedFile);
  @@ -345,7 +342,7 @@
                   msg += " (and the archive is probably corrupt but I could not delete it)";
               }
   
  -            if (reallyDoUpdate) {
  +            if (doUpdate) {
                   if (!renamedFile.renameTo(zipFile)) {
                       msg+=" (and I couldn't rename the temporary file "+
                           renamedFile.getName()+" back)";
  @@ -358,7 +355,7 @@
           }
   
           // If we've been successful on an update, delete the temporary file
  -        if (success && reallyDoUpdate) {
  +        if (success && doUpdate) {
               if (!renamedFile.delete()) {
                   log ("Warning: unable to delete temporary file " +
                        renamedFile.getName(), Project.MSG_WARN);
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>