Browse Source

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
master
Steve Loughran 23 years ago
parent
commit
5d79a4f5eb
11 changed files with 86 additions and 47 deletions
  1. +3
    -3
      docs/manual/CoreTasks/ear.html
  2. +6
    -6
      docs/manual/CoreTasks/jar.html
  3. +3
    -3
      docs/manual/CoreTasks/war.html
  4. +7
    -7
      docs/manual/CoreTasks/zip.html
  5. +4
    -4
      src/etc/testcases/taskdefs/jar.xml
  6. +14
    -7
      src/etc/testcases/taskdefs/zip.xml
  7. +13
    -7
      src/main/org/apache/tools/ant/taskdefs/Ear.java
  8. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  9. +8
    -2
      src/main/org/apache/tools/ant/taskdefs/War.java
  10. +21
    -5
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  11. +4
    -0
      src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java

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

@@ -24,8 +24,8 @@ attributes of zipfilesets in a Zip or Jar task.)</p>
<td align="center" valign="top"><b>Required</b></td> <td align="center" valign="top"><b>Required</b></td>
</tr> </tr>
<tr> <tr>
<td valign="top">file</td>
<td valign="top">the ear-file to create.</td>
<td valign="top">destfile</td>
<td valign="top">the EAR file to create.</td>
<td valign="top" align="center">Yes</td> <td valign="top" align="center">Yes</td>
</tr> </tr>
<tr> <tr>
@@ -107,7 +107,7 @@ fileset includes a file named <code>MANIFEST.MF</code>, the file is
ignored and you will get a warning.</p> ignored and you will get a warning.</p>
<h2>Example</h2> <h2>Example</h2>
<pre> <pre>
&lt;ear file=&quot;${build.dir}/myapp.ear&quot; appxml=&quot;${src.dir}/metadata/application.xml&quot;&gt;
&lt;ear destfile=&quot;${build.dir}/myapp.ear&quot; appxml=&quot;${src.dir}/metadata/application.xml&quot;&gt;
&lt;fileset dir=&quot;${build.dir}&quot; includes=&quot;*.jar,*.war&quot;/&gt; &lt;fileset dir=&quot;${build.dir}&quot; includes=&quot;*.jar,*.war&quot;/&gt;
&lt;/ear&gt; &lt;/ear&gt;
</pre> </pre>


+ 6
- 6
docs/manual/CoreTasks/jar.html View File

@@ -58,8 +58,8 @@ being wrapped and continued on the next line.
<td align="center" valign="top"><b>Required</b></td> <td align="center" valign="top"><b>Required</b></td>
</tr> </tr>
<tr> <tr>
<td valign="top">file</td>
<td valign="top">the jar-file to create.</td>
<td valign="top">destfile</td>
<td valign="top">the JAR file to create.</td>
<td valign="top" align="center">Yes</td> <td valign="top" align="center">Yes</td>
</tr> </tr>
<tr> <tr>
@@ -157,14 +157,14 @@ the resulting Jar.
<pre> &lt;jar file=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot;/&gt;</pre> <pre> &lt;jar file=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot;/&gt;</pre>
<p>jars all files in the <code>${build}/classes</code> directory into a file <p>jars all files in the <code>${build}/classes</code> directory into a file
called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p> called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
<pre> &lt;jar file=&quot;${dist}/lib/app.jar&quot;
<pre> &lt;jar destfile=&quot;${dist}/lib/app.jar&quot;
basedir=&quot;${build}/classes&quot; basedir=&quot;${build}/classes&quot;
excludes=&quot;**/Test.class&quot; excludes=&quot;**/Test.class&quot;
/&gt;</pre> /&gt;</pre>
<p>jars all files in the <code>${build}/classes</code> directory into a file <p>jars all files in the <code>${build}/classes</code> directory into a file
called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Files called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Files
with the name <code>Test.class</code> are excluded.</p> with the name <code>Test.class</code> are excluded.</p>
<pre> &lt;jar file=&quot;${dist}/lib/app.jar&quot;
<pre> &lt;jar destfile=&quot;${dist}/lib/app.jar&quot;
basedir=&quot;${build}/classes&quot; basedir=&quot;${build}/classes&quot;
includes=&quot;mypackage/test/**&quot; includes=&quot;mypackage/test/**&quot;
excludes=&quot;**/Test.class&quot; excludes=&quot;**/Test.class&quot;
@@ -173,7 +173,7 @@ with the name <code>Test.class</code> are excluded.</p>
called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Only called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Only
files under the directory <code>mypackage/test</code> are used, and files with files under the directory <code>mypackage/test</code> are used, and files with
the name <code>Test.class</code> are excluded.</p> the name <code>Test.class</code> are excluded.</p>
<pre> &lt;jar file=&quot;${dist}/lib/app.jar&quot;&gt;
<pre> &lt;jar destfile=&quot;${dist}/lib/app.jar&quot;&gt;
&lt;fileset dir=&quot;${build}/classes&quot; &lt;fileset dir=&quot;${build}/classes&quot;
excludes=&quot;**/Test.class&quot; excludes=&quot;**/Test.class&quot;
/&gt; /&gt;
@@ -188,7 +188,7 @@ and <code>${src}/resources/mypackage/image.gif</code>, they will appear
in the same directory in the JAR (and thus be considered in the same package in the same directory in the JAR (and thus be considered in the same package
by Java).</p> by Java).</p>


<pre> &lt;jar jarfile=&quot;test.jar&quot; basedir=&quot;.&quot;&gt;
<pre> &lt;jar destfile=&quot;test.jar&quot; basedir=&quot;.&quot;&gt;
&lt;include name=&quot;build&quot;/&gt; &lt;include name=&quot;build&quot;/&gt;
&lt;manifest&gt; &lt;manifest&gt;
&lt;attribute name=&quot;Built-By&quot; value=&quot;${user.name}&quot;/&gt; &lt;attribute name=&quot;Built-By&quot; value=&quot;${user.name}&quot;/&gt;


+ 3
- 3
docs/manual/CoreTasks/war.html View File

@@ -26,8 +26,8 @@ attributes of zipfilesets in a Zip or Jar task.)</p>
<td align="center" valign="top"><b>Required</b></td> <td align="center" valign="top"><b>Required</b></td>
</tr> </tr>
<tr> <tr>
<td valign="top">file</td>
<td valign="top">the war-file to create.</td>
<td valign="top">destfile</td>
<td valign="top">the WAR file to create.</td>
<td valign="top" align="center">Yes</td> <td valign="top" align="center">Yes</td>
</tr> </tr>
<tr> <tr>
@@ -135,7 +135,7 @@ src/graphics/images/gifs/large/logo.gif
</pre> </pre>
then the war file <code>myapp.war</code> created with then the war file <code>myapp.war</code> created with
<pre> <pre>
&lt;war file=&quot;myapp.war&quot; webxml=&quot;src/metadata/myapp.xml&quot;&gt;
&lt;war destfile=&quot;myapp.war&quot; webxml=&quot;src/metadata/myapp.xml&quot;&gt;
&lt;fileset dir=&quot;src/html/myapp&quot;/&gt; &lt;fileset dir=&quot;src/html/myapp&quot;/&gt;
&lt;fileset dir=&quot;src/jsp/myapp&quot;/&gt; &lt;fileset dir=&quot;src/jsp/myapp&quot;/&gt;
&lt;lib dir=&quot;thirdparty/libs&quot;&gt; &lt;lib dir=&quot;thirdparty/libs&quot;&gt;


+ 7
- 7
docs/manual/CoreTasks/zip.html View File

@@ -57,7 +57,7 @@ Java.</p>
<td valign="top" align="center"><b>Required</b></td> <td valign="top" align="center"><b>Required</b></td>
</tr> </tr>
<tr> <tr>
<td valign="top">file</td>
<td valign="top">destfile</td>
<td valign="top">the zip-file to create.</td> <td valign="top">the zip-file to create.</td>
<td align="center" valign="top">Yes</td> <td align="center" valign="top">Yes</td>
</tr> </tr>
@@ -142,12 +142,12 @@ contents will be extracted and included in the archive. As with directories, in
for inclusion in the archive.</p> for inclusion in the archive.</p>


<h3>Examples</h3> <h3>Examples</h3>
<pre> &lt;zip file=&quot;${dist}/manual.zip&quot;
<pre> &lt;zip destfile=&quot;${dist}/manual.zip&quot;
basedir=&quot;htdocs/manual&quot; basedir=&quot;htdocs/manual&quot;
/&gt;</pre> /&gt;</pre>
<p>zips all files in the <code>htdocs/manual</code> directory into a file called <code>manual.zip</code> <p>zips all files in the <code>htdocs/manual</code> directory into a file called <code>manual.zip</code>
in the <code>${dist}</code> directory.</p> in the <code>${dist}</code> directory.</p>
<pre> &lt;zip file=&quot;${dist}/manual.zip&quot;
<pre> &lt;zip destfile=&quot;${dist}/manual.zip&quot;
basedir=&quot;htdocs/manual&quot; basedir=&quot;htdocs/manual&quot;
update=&quot;true&quot; update=&quot;true&quot;
/&gt;</pre> /&gt;</pre>
@@ -155,27 +155,27 @@ in the <code>${dist}</code> directory.</p>
in the <code>${dist}</code> directory. If <code>manual.zip</code> in the <code>${dist}</code> directory. If <code>manual.zip</code>
doesn't exist, it is created; otherwise it is updated with the doesn't exist, it is created; otherwise it is updated with the
new/changed files.</p> new/changed files.</p>
<pre> &lt;zip file=&quot;${dist}/manual.zip&quot;
<pre> &lt;zip destfile=&quot;${dist}/manual.zip&quot;
basedir=&quot;htdocs/manual&quot; basedir=&quot;htdocs/manual&quot;
excludes=&quot;mydocs/**, **/todo.html&quot; excludes=&quot;mydocs/**, **/todo.html&quot;
/&gt;</pre> /&gt;</pre>
<p>zips all files in the <code>htdocs/manual</code> directory. Files in the directory <code>mydocs</code>, <p>zips all files in the <code>htdocs/manual</code> directory. Files in the directory <code>mydocs</code>,
or files with the name <code>todo.html</code> are excluded.</p> or files with the name <code>todo.html</code> are excluded.</p>
<pre> &lt;zip file=&quot;${dist}/manual.zip&quot;
<pre> &lt;zip destfile=&quot;${dist}/manual.zip&quot;
basedir=&quot;htdocs/manual&quot; basedir=&quot;htdocs/manual&quot;
includes=&quot;api/**/*.html&quot; includes=&quot;api/**/*.html&quot;
excludes=&quot;**/todo.html&quot; excludes=&quot;**/todo.html&quot;
/&gt;</pre> /&gt;</pre>
<p>zips all files in the <code>htdocs/manual</code> directory. Only html files under the directory <code>api</code> <p>zips all files in the <code>htdocs/manual</code> directory. Only html files under the directory <code>api</code>
are zipped, and files with the name <code>todo.html</code> are excluded.</p> are zipped, and files with the name <code>todo.html</code> are excluded.</p>
<pre> &lt;zip file=&quot;${dist}/manual.zip&quot;&gt;
<pre> &lt;zip destfile=&quot;${dist}/manual.zip&quot;&gt;
&lt;fileset dir=&quot;htdocs/manual&quot;/&gt; &lt;fileset dir=&quot;htdocs/manual&quot;/&gt;
&lt;fileset dir=&quot;.&quot; includes=&quot;ChangeLog.txt&quot;/&gt; &lt;fileset dir=&quot;.&quot; includes=&quot;ChangeLog.txt&quot;/&gt;
&lt;/zip&gt;</pre> &lt;/zip&gt;</pre>
<p>zips all files in the <code>htdocs/manual</code> directory, and also adds the file <code>ChangeLog.txt</code> in the <p>zips all files in the <code>htdocs/manual</code> directory, and also adds the file <code>ChangeLog.txt</code> in the
current directory. <code>ChangeLog.txt</code> will be added to the top of the ZIP file, just as if current directory. <code>ChangeLog.txt</code> will be added to the top of the ZIP file, just as if
it had been located at <code>htdocs/manual/ChangeLog.txt</code>.</p> it had been located at <code>htdocs/manual/ChangeLog.txt</code>.</p>
<pre> &lt;zip file=&quot;${dist}/manual.zip&quot;&gt;
<pre> &lt;zip destfile=&quot;${dist}/manual.zip&quot;&gt;
&lt;zipfileset dir=&quot;htdocs/manual&quot; prefix=&quot;docs/user-guide&quot;/&gt; &lt;zipfileset dir=&quot;htdocs/manual&quot; prefix=&quot;docs/user-guide&quot;/&gt;
&lt;zipfileset dir=&quot;.&quot; includes=&quot;ChangeLog27.txt&quot; fullpath=&quot;docs/ChangeLog.txt&quot;/&gt; &lt;zipfileset dir=&quot;.&quot; includes=&quot;ChangeLog27.txt&quot; fullpath=&quot;docs/ChangeLog.txt&quot;/&gt;
&lt;zipfileset src=&quot;examples.zip&quot; includes=&quot;**/*.html&quot; prefix=&quot;docs/examples&quot;/&gt; &lt;zipfileset src=&quot;examples.zip&quot; includes=&quot;**/*.html&quot; prefix=&quot;docs/examples&quot;/&gt;


+ 4
- 4
src/etc/testcases/taskdefs/jar.xml View File

@@ -15,7 +15,7 @@


<target name="test3"> <target name="test3">
<jar <jar
jarfile="jar.tmp"
destfile="jar.tmp"
whenempty="format C: /y" whenempty="format C: /y"
/> />
</target> </target>
@@ -24,7 +24,7 @@
<!-- delete the tmp.jar or the next test will fail --> <!-- delete the tmp.jar or the next test will fail -->
<delete file="tmp.jar"/> <delete file="tmp.jar"/>
<jar <jar
jarfile="tmp.jar"
destfile="tmp.jar"
basedir="." basedir="."
includes="jar.xml" includes="jar.xml"
/> />
@@ -33,10 +33,10 @@
<!-- This test is to make sure upToDate is working --> <!-- This test is to make sure upToDate is working -->
<target name="test5"> <target name="test5">
<jar <jar
jarfile="tmp.jar"
destfile="tmp.jar"
basedir="." basedir="."
includes="jar.xml" includes="jar.xml"
/> />
</target> </target>


</project>
</project>

+ 14
- 7
src/etc/testcases/taskdefs/zip.xml View File

@@ -7,21 +7,21 @@
</target> </target>


<target name="test2"> <target name="test2">
<zip zipfile="zip.tmp"/>
<zip destFile="zip.tmp"/>
</target> </target>


<!-- Test when the zip file includes itself <!-- Test when the zip file includes itself
when target file exists before the zip task is run --> when target file exists before the zip task is run -->
<target name="test3"> <target name="test3">
<touch file="test3.zip"/> <touch file="test3.zip"/>
<zip zipfile="test3.zip"
<zip destFile="test3.zip"
basedir="."/> basedir="."/>
</target> </target>


<!-- Test when the zip file includes itself <!-- Test when the zip file includes itself
when target file does not exist before the zip task is run --> when target file does not exist before the zip task is run -->
<target name="test4"> <target name="test4">
<zip zipfile="test4.zip"
<zip destFile="test4.zip"
basedir="."/> basedir="."/>
</target> </target>


@@ -32,28 +32,35 @@
</target> </target>


<target name="test6"> <target name="test6">
<zip zipfile="test6.zip" basedir=".">
<zip destFile="test6.zip" basedir=".">
<include name="*.xml" /> <include name="*.xml" />
<exclude name="zip.*" /> <exclude name="zip.*" />
</zip> </zip>
</target> </target>


<target name="test7"> <target name="test7">
<zip zipfile="inner7.zip" basedir="." >
<zip destFile="inner7.zip" basedir="." >
<exclude name="inner7.zip" /> <exclude name="inner7.zip" />
</zip> </zip>
<zip zipfile="test7.zip" basedir=".">
<zip destFile="test7.zip" basedir=".">
<exclude name="**/*.*" /> <exclude name="**/*.*" />
<zipfileset src="inner7.zip" /> <zipfileset src="inner7.zip" />
</zip> </zip>
</target> </target>


<target name="feather"> <target name="feather">
<zip zipfile="asf-logo.gif.zip"
<zip destFile="asf-logo.gif.zip"
basedir=".." basedir=".."
includes="asf-logo.gif" /> includes="asf-logo.gif" />
</target> </target>


<!-- legacy attribute support -->
<target name="test8">
<zip zipfile="test8.zip" basedir="." >
<exclude name="test8.zip" />
</zip>
</target>
<target name="cleanup"> <target name="cleanup">
<delete file="test3.zip"/> <delete file="test3.zip"/>
<delete file="test4.zip"/> <delete file="test4.zip"/>


+ 13
- 7
src/main/org/apache/tools/ant/taskdefs/Ear.java View File

@@ -79,11 +79,17 @@ public class Ear extends Jar {
emptyBehavior = "create"; emptyBehavior = "create";
} }


/**
* @deprecated Use setDestFile(destfile) instead
*/
public void setEarfile(File earFile) { 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) { public void setAppxml(File descr) {
deploymentDescriptor = descr; deploymentDescriptor = descr;
if (!deploymentDescriptor.exists()) if (!deploymentDescriptor.exists())
@@ -121,11 +127,11 @@ public class Ear extends Jar {
protected void zipFile(File file, ZipOutputStream zOut, String vPath) protected void zipFile(File file, ZipOutputStream zOut, String vPath)
throws IOException 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 <fileset> element. // a <fileset> element.
if (vPath.equalsIgnoreCase("META-INF/aplication.xml")) {
if (vPath.equalsIgnoreCase("META-INF/application.xml")) {
if (deploymentDescriptor == null || !deploymentDescriptor.equals(file) || descriptorAdded) { if (deploymentDescriptor == null || !deploymentDescriptor.equals(file) || descriptorAdded) {
log("Warning: selected "+archiveType+" files include a META-INF/application.xml which will be ignored " + 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); "(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. * gets executed.
*/ */
protected void cleanUp() { protected void cleanUp() {


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -97,11 +97,11 @@ public class Jar extends Zip {
} }


/** /**
* @deprecated use setFile(File) instead.
* @deprecated Use setDestFile(File) instead
*/ */
public void setJarfile(File jarFile) { 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);
} }


/** /**


+ 8
- 2
src/main/org/apache/tools/ant/taskdefs/War.java View File

@@ -79,11 +79,17 @@ public class War extends Jar {
emptyBehavior = "create"; emptyBehavior = "create";
} }


/**
* @deprecated Use setDestFile(File) instead
*/
public void setWarfile(File warFile) { 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) { public void setWebxml(File descr) {
deploymentDescriptor = descr; deploymentDescriptor = descr;
if (!deploymentDescriptor.exists()) if (!deploymentDescriptor.exists())


+ 21
- 5
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -120,22 +120,38 @@ public class Zip extends MatchingTask {
* This is the name/location of where to * This is the name/location of where to
* create the .zip file. * create the .zip file.
* *
* @deprecated Use setFile() instead
* @deprecated Use setDestFile(File) instead
*/ */
public void setZipfile(File zipFile) { 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 * This is the name/location of where to
* create the .zip file. * create the .zip file.
*
* @since 1.5alpha
* @todo pull this before shipping 1.5
* @deprecated Use setDestFile(File) instead
*/ */
public void setFile(File file) { 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 * This is the base directory to look in for
* things to zip. * things to zip.


+ 4
- 0
src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java View File

@@ -101,4 +101,8 @@ public class ZipTest extends BuildFileTest {
public void test7() { public void test7() {
executeTarget("test7"); executeTarget("test7");
} }

public void test8() {
executeTarget("test8");
}
} }

Loading…
Cancel
Save