Browse Source

Don't require webxml in <war> or appxml in <ear> if updating an

existing archive.

Submitted by:	Stefano Mancarella <mancarella@opoipi.bancaintesa.it>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270120 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
1e65e7f37f
5 changed files with 21 additions and 24 deletions
  1. +1
    -1
      docs/manual/CoreTasks/ear.html
  2. +1
    -1
      docs/manual/CoreTasks/war.html
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Ear.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/War.java
  5. +17
    -20
      src/main/org/apache/tools/ant/taskdefs/Zip.java

+ 1
- 1
docs/manual/CoreTasks/ear.html View File

@@ -31,7 +31,7 @@ attributes of zipfilesets in a Zip or Jar task.)</p>
<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
- 1
docs/manual/CoreTasks/war.html View File

@@ -33,7 +33,7 @@ attributes of zipfilesets in a Zip or Jar task.)</p>
<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
- 1
src/main/org/apache/tools/ant/taskdefs/Ear.java View File

@@ -111,7 +111,7 @@ public class Ear extends Jar {
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
- 1
src/main/org/apache/tools/ant/taskdefs/War.java View File

@@ -119,7 +119,7 @@ public class War extends Jar {
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);
}


+ 17
- 20
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -76,6 +76,7 @@ import org.apache.tools.ant.types.FileSet;
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;
@@ -165,6 +166,13 @@ public class Zip extends MatchingTask {
doUpdate = c;
}

/**
* Are we updating an existing archive?
*/
public boolean isInUpdateMode() {
return doUpdate;
}

/**
* Adds a set of files (nested fileset attribute).
*/
@@ -228,23 +236,12 @@ public class Zip extends MatchingTask {
// 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 @@ public class Zip extends MatchingTask {
return;
}

String action = reallyDoUpdate ? "Updating " : "Building ";
String action = doUpdate ? "Updating " : "Building ";

log(action + archiveType +": "+ zipFile.getAbsolutePath());

@@ -300,7 +297,7 @@ public class Zip extends MatchingTask {
}
// 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 @@ public class Zip extends MatchingTask {
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 @@ public class Zip extends MatchingTask {
}

// 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);


Loading…
Cancel
Save