From 5d79a4f5eb355e3058e18c7462b9fdc5b53071b3 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Mon, 7 Jan 2002 06:22:11 +0000 Subject: [PATCH] Addition of destFile(File) attr to the zip/war/ear/jar tasks, fixup of docs, replacement of deprecation methods and appropriate changes to the tests. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270605 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/CoreTasks/ear.html | 6 ++--- docs/manual/CoreTasks/jar.html | 12 ++++----- docs/manual/CoreTasks/war.html | 6 ++--- docs/manual/CoreTasks/zip.html | 14 +++++----- src/etc/testcases/taskdefs/jar.xml | 8 +++--- src/etc/testcases/taskdefs/zip.xml | 21 ++++++++++----- .../org/apache/tools/ant/taskdefs/Ear.java | 20 +++++++++----- .../org/apache/tools/ant/taskdefs/Jar.java | 6 ++--- .../org/apache/tools/ant/taskdefs/War.java | 10 +++++-- .../org/apache/tools/ant/taskdefs/Zip.java | 26 +++++++++++++++---- .../apache/tools/ant/taskdefs/ZipTest.java | 4 +++ 11 files changed, 86 insertions(+), 47 deletions(-) diff --git a/docs/manual/CoreTasks/ear.html b/docs/manual/CoreTasks/ear.html index 9b3b0e912..63897c058 100644 --- a/docs/manual/CoreTasks/ear.html +++ b/docs/manual/CoreTasks/ear.html @@ -24,8 +24,8 @@ attributes of zipfilesets in a Zip or Jar task.)

Required - file - the ear-file to create. + destfile + the EAR file to create. Yes @@ -107,7 +107,7 @@ fileset includes a file named MANIFEST.MF, the file is ignored and you will get a warning.

Example

-    <ear file="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml">
+    <ear destfile="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml">
       <fileset dir="${build.dir}" includes="*.jar,*.war"/>
     </ear>
 
diff --git a/docs/manual/CoreTasks/jar.html b/docs/manual/CoreTasks/jar.html index 0eab3320a..4182d7258 100644 --- a/docs/manual/CoreTasks/jar.html +++ b/docs/manual/CoreTasks/jar.html @@ -58,8 +58,8 @@ being wrapped and continued on the next line. Required - file - the jar-file to create. + destfile + the JAR file to create. Yes @@ -157,14 +157,14 @@ the resulting Jar.
  <jar file="${dist}/lib/app.jar" basedir="${build}/classes"/>

jars all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory.

-
  <jar file="${dist}/lib/app.jar"
+
  <jar destfile="${dist}/lib/app.jar"
        basedir="${build}/classes"
        excludes="**/Test.class"
   />

jars all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory. Files with the name Test.class are excluded.

-
  <jar file="${dist}/lib/app.jar"
+
  <jar destfile="${dist}/lib/app.jar"
        basedir="${build}/classes"
        includes="mypackage/test/**"
        excludes="**/Test.class"
@@ -173,7 +173,7 @@ with the name Test.class are excluded.

called app.jar in the ${dist}/lib directory. Only files under the directory mypackage/test are used, and files with the name Test.class are excluded.

-
  <jar file="${dist}/lib/app.jar">
+
  <jar destfile="${dist}/lib/app.jar">
     <fileset dir="${build}/classes"
              excludes="**/Test.class"
     />
@@ -188,7 +188,7 @@ and ${src}/resources/mypackage/image.gif, they will appear
 in the same directory in the JAR (and thus be considered in the same package
 by Java).

-
  <jar jarfile="test.jar" basedir=".">
+
  <jar destfile="test.jar" basedir=".">
     <include name="build"/>
     <manifest>
       <attribute name="Built-By" value="${user.name}"/>
diff --git a/docs/manual/CoreTasks/war.html b/docs/manual/CoreTasks/war.html
index 1e29b8b64..1c66520cc 100644
--- a/docs/manual/CoreTasks/war.html
+++ b/docs/manual/CoreTasks/war.html
@@ -26,8 +26,8 @@ attributes of zipfilesets in a Zip or Jar task.)

Required - file - the war-file to create. + destfile + the WAR file to create. Yes @@ -135,7 +135,7 @@ src/graphics/images/gifs/large/logo.gif
then the war file myapp.war created with
-<war file="myapp.war" webxml="src/metadata/myapp.xml">
+<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
   <fileset dir="src/html/myapp"/>
   <fileset dir="src/jsp/myapp"/>
   <lib dir="thirdparty/libs">
diff --git a/docs/manual/CoreTasks/zip.html b/docs/manual/CoreTasks/zip.html
index f4e762502..3eb5349ed 100644
--- a/docs/manual/CoreTasks/zip.html
+++ b/docs/manual/CoreTasks/zip.html
@@ -57,7 +57,7 @@ Java.

Required - file + destfile the zip-file to create. Yes @@ -142,12 +142,12 @@ contents will be extracted and included in the archive. As with directories, in for inclusion in the archive.

Examples

-
  <zip file="${dist}/manual.zip"
+
  <zip destfile="${dist}/manual.zip"
        basedir="htdocs/manual"
   />

zips all files in the htdocs/manual directory into a file called manual.zip in the ${dist} directory.

-
  <zip file="${dist}/manual.zip"
+
  <zip destfile="${dist}/manual.zip"
        basedir="htdocs/manual"
        update="true"
   />
@@ -155,27 +155,27 @@ in the ${dist} directory.

in the ${dist} directory. If manual.zip doesn't exist, it is created; otherwise it is updated with the new/changed files.

-
  <zip file="${dist}/manual.zip"
+
  <zip destfile="${dist}/manual.zip"
        basedir="htdocs/manual"
        excludes="mydocs/**, **/todo.html"
   />

zips all files in the htdocs/manual directory. Files in the directory mydocs, or files with the name todo.html are excluded.

-
  <zip file="${dist}/manual.zip"
+
  <zip destfile="${dist}/manual.zip"
        basedir="htdocs/manual"
        includes="api/**/*.html"
        excludes="**/todo.html"
   />

zips all files in the htdocs/manual directory. Only html files under the directory api are zipped, and files with the name todo.html are excluded.

-
  <zip file="${dist}/manual.zip">
+
  <zip destfile="${dist}/manual.zip">
     <fileset dir="htdocs/manual"/>
     <fileset dir="." includes="ChangeLog.txt"/>
   </zip>

zips all files in the htdocs/manual directory, and also adds the file ChangeLog.txt in the current directory. ChangeLog.txt will be added to the top of the ZIP file, just as if it had been located at htdocs/manual/ChangeLog.txt.

-
  <zip file="${dist}/manual.zip">
+
  <zip destfile="${dist}/manual.zip">
     <zipfileset dir="htdocs/manual" prefix="docs/user-guide"/>
     <zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/>
     <zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/>
diff --git a/src/etc/testcases/taskdefs/jar.xml b/src/etc/testcases/taskdefs/jar.xml
index 064c1fe97..81679a558 100644
--- a/src/etc/testcases/taskdefs/jar.xml
+++ b/src/etc/testcases/taskdefs/jar.xml
@@ -15,7 +15,7 @@
 
   
     
   
@@ -24,7 +24,7 @@
    
    
    
@@ -33,10 +33,10 @@
   
   
     
   
 
-
\ No newline at end of file
+
diff --git a/src/etc/testcases/taskdefs/zip.xml b/src/etc/testcases/taskdefs/zip.xml
index 66bd77e71..ec48043d5 100644
--- a/src/etc/testcases/taskdefs/zip.xml
+++ b/src/etc/testcases/taskdefs/zip.xml
@@ -7,21 +7,21 @@
   
 
   
-    
+    
   
 
   
   
     
-    
   
 
   
   
-     
   
 
@@ -32,28 +32,35 @@
   
 
   
-    
+    
       
       
     
   
 
   
-    
+    
       
     
-    
+    
       
       
     
   
 
   
-    
   
 
+  
+  
+    
+      
+    
+  
+  
   
     
     
diff --git a/src/main/org/apache/tools/ant/taskdefs/Ear.java b/src/main/org/apache/tools/ant/taskdefs/Ear.java
index bff4f0ab5..3e385332d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Ear.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Ear.java
@@ -79,11 +79,17 @@ public class Ear extends Jar {
         emptyBehavior = "create";
     }
 
+    /**
+     * @deprecated Use setDestFile(destfile) instead
+     */ 
     public void setEarfile(File earFile) {
-        log("DEPRECATED - The earfile attribute is deprecated. Use file attribute instead.");
-        setFile(earFile);
+        log("DEPRECATED - The earfile attribute is deprecated. Use destfile attribute instead.");
+        setDestFile(earFile);
     }
     
+    /**
+     * set the application XML file
+     */
     public void setAppxml(File descr) {
         deploymentDescriptor = descr; 
         if (!deploymentDescriptor.exists())
@@ -121,11 +127,11 @@ public class Ear extends Jar {
     protected void zipFile(File file, ZipOutputStream zOut, String vPath)
         throws IOException
     {
-        // If the file being added is WEB-INF/web.xml, we warn if it's not the
-        // one specified in the "webxml" attribute - or if it's being added twice, 
-        // meaning the same file is specified by the "webxml" attribute and in
+        // If the file being added is META-INF/application.xml, we warn if it's not the
+        // one specified in the "appxml" attribute - or if it's being added twice, 
+        // meaning the same file is specified by the "appxml" attribute and in
         // a  element.
-        if (vPath.equalsIgnoreCase("META-INF/aplication.xml"))  {
+        if (vPath.equalsIgnoreCase("META-INF/application.xml"))  {
             if (deploymentDescriptor == null || !deploymentDescriptor.equals(file) || descriptorAdded) {
                 log("Warning: selected "+archiveType+" files include a META-INF/application.xml which will be ignored " +
                     "(please use appxml attribute to "+archiveType+" task)", Project.MSG_WARN);
@@ -139,7 +145,7 @@ public class Ear extends Jar {
     }
 
     /**
-     * Make sure we don't think we already have a web.xml next time this task
+     * Make sure we don't think we already have a application.xml next time this task
      * gets executed.
      */
     protected void cleanUp() {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java
index ae40a674a..67eb15b82 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Jar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java
@@ -97,11 +97,11 @@ public class Jar extends Zip {
     }
 
     /**
-     * @deprecated use setFile(File) instead.
+     * @deprecated Use setDestFile(File) instead
      */
     public void setJarfile(File jarFile) {
-        log("DEPRECATED - The jarfile attribute is deprecated. Use file attribute instead.");
-        setFile(jarFile);
+        log("DEPRECATED - The jarfile attribute is deprecated. Use destfile attribute instead.");
+        setDestFile(jarFile);
     }
 
     /**
diff --git a/src/main/org/apache/tools/ant/taskdefs/War.java b/src/main/org/apache/tools/ant/taskdefs/War.java
index 918b36f40..333116a0c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/War.java
+++ b/src/main/org/apache/tools/ant/taskdefs/War.java
@@ -79,11 +79,17 @@ public class War extends Jar {
         emptyBehavior = "create";
     }
 
+    /**
+     * @deprecated Use setDestFile(File) instead
+     */    
     public void setWarfile(File warFile) {
-        log("DEPRECATED - The warfile attribute is deprecated. Use file attribute instead.");
-        setFile(warFile);
+        log("DEPRECATED - The warfile attribute is deprecated. Use destfile attribute instead.");
+        setDestFile(warFile);
     }
     
+    /**
+     * set the web app descriptor for this WAR file
+     */
     public void setWebxml(File descr) {
         deploymentDescriptor = descr; 
         if (!deploymentDescriptor.exists())
diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java
index 050663a33..1c2adc183 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Zip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java
@@ -120,22 +120,38 @@ public class Zip extends MatchingTask {
      * This is the name/location of where to
      * create the .zip file.
      *
-     * @deprecated Use setFile() instead
+     * @deprecated Use setDestFile(File) instead
      */
     public void setZipfile(File zipFile) {
-        log("DEPRECATED - The zipfile attribute is deprecated. Use file attribute instead.");
-        setFile( zipFile );
+        log("DEPRECATED - The zipfile attribute is deprecated. Use destfile attribute instead.");
+        setDestFile(zipFile);
     }
 
     /**
      * This is the name/location of where to
      * create the .zip file.
-     *
+     * @since 1.5alpha
+     * @todo pull this before shipping 1.5
+     * @deprecated Use setDestFile(File) instead
      */
     public void setFile(File file) {
-        this.zipFile = file;
+        log("DEPRECATED - The file attribute has been renamed destfile."
+            +" This attribute will be unsupported before Ant1.5 is released",
+            Project.MSG_ERR);
+        setDestFile(file);
+    }
+
+
+    /**
+     * Sets the destfile attribute.
+     * @since 1.5
+     * @param destFile The new destination File
+     */
+    public void setDestFile(File destFile) {
+       this.zipFile = destFile;
     }
 
+        
     /**
      * This is the base directory to look in for
      * things to zip.
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
index 9cd471c48..e85a91de4 100644
--- a/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
+++ b/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
@@ -101,4 +101,8 @@ public class ZipTest extends BuildFileTest {
     public void test7() { 
         executeTarget("test7");
     }
+
+    public void test8() { 
+        executeTarget("test8");
+    }    
 }