Submitted by: Roger Vaughn <rvaughn@seaconinc.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267883 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -83,7 +83,6 @@ | |||
| <exclude name="**/EjbJar.java" unless="jdk1.2+" /> | |||
| <exclude name="**/*DeploymentTool.java" unless="jdk1.2+" /> | |||
| <exclude name="**/junit/*" unless="junit.present" /> | |||
| <exclude name="**/Cab.java" unless="jdk1.2+" /> | |||
| </javac> | |||
| <copydir src="${src.dir}" dest="${build.classes}"> | |||
| @@ -3356,11 +3356,68 @@ directory.</p> | |||
| the cabarc tool. should not normally be necessary.</td> | |||
| <td valign="top" align="center">No</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">includes</td> | |||
| <td valign="top">comma separated list of patterns of files that | |||
| must be included. All files are included when omitted.</td> | |||
| <td valign="top" align="center">No</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">includesfile</td> | |||
| <td valign="top">the name of a file. Each line of this file is | |||
| taken to be an include pattern</td> | |||
| <td valign="top" align="center">No</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">excludes</td> | |||
| <td valign="top">comma separated list of patterns of files that | |||
| must be excluded. No files (except default excludes) are excluded | |||
| when omitted.</td> | |||
| <td valign="top" align="center">No</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">excludesfile</td> | |||
| <td valign="top">the name of a file. Each line of this file is | |||
| taken to be an exclude pattern</td> | |||
| <td valign="top" align="center">No</td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">defaultexcludes</td> | |||
| <td valign="top">indicates whether default excludes should be used | |||
| or not ("yes"/"no"). Default excludes are used when omitted.</td> | |||
| <td valign="top" align="center">No</td> | |||
| </tr> | |||
| </table> | |||
| <h3>Examples</h3> | |||
| <blockquote> | |||
| <p>None yet available</p> | |||
| </blockquote> | |||
| <blockquote><pre> | |||
| <cab cabfile="${dist}/manual.cab" | |||
| basedir="htdocs/manual" | |||
| /> | |||
| </pre></blockquote> | |||
| <p>cabs all files in the htdocs/manual directory in a file called | |||
| manual.cab in the ${dist} directory.</p> | |||
| <blockquote><pre> | |||
| <cab cabfile="${dist}/manual.cab" | |||
| basedir="htdocs/manual" | |||
| excludes="mydocs/**, **/todo.html" | |||
| /> | |||
| </pre></blockquote> | |||
| <p>cabs all files in the htdocs/manual directory in a file called | |||
| manual.cab in the ${dist} directory. Files in the directory mydocs, | |||
| or files with the name todo.html are excluded.</p> | |||
| <blockquote><pre> | |||
| <cab cabfile="${dist}/manual.cab" | |||
| basedir="htdocs/manual" | |||
| includes="api/**/*.html" | |||
| excludes="**/todo.html" | |||
| verbose="yes" | |||
| /> | |||
| </pre></blockquote> | |||
| <p>cab all files in the htdocs/manual directory in a file called | |||
| manual.cab in the ${dist} directory. Only html files under the | |||
| directory api are archived, and files with the name todo.html are | |||
| excluded. Output from the cabarc tool is displayed in the build | |||
| output.</p> | |||
| <hr> | |||
| <h2><a name="netrexxc">NetRexxC</a></h2> | |||
| <h3><b>Description:</b></h3> | |||
| @@ -62,6 +62,8 @@ import java.io.*; | |||
| import java.util.Enumeration; | |||
| import java.util.StringTokenizer; | |||
| import java.util.Vector; | |||
| import java.util.Random; | |||
| import java.text.DecimalFormat; | |||
| /** | |||
| * Create a CAB archive. | |||
| @@ -93,7 +95,7 @@ public class Cab extends MatchingTask { | |||
| * create the .cab file. | |||
| */ | |||
| public void setCabfile(File cabFile) { | |||
| cabFile = cabFile; | |||
| this.cabFile = cabFile; | |||
| } | |||
| /** | |||
| @@ -215,6 +217,27 @@ public class Cab extends MatchingTask { | |||
| return command; | |||
| } | |||
| private static int counter = new Random().nextInt() % 100000; | |||
| protected File createTempFile(String prefix, String suffix) | |||
| { | |||
| if (suffix == null) | |||
| { | |||
| suffix = ".tmp"; | |||
| } | |||
| String name = prefix + | |||
| new DecimalFormat("#####").format(new Integer(counter++)) + | |||
| suffix; | |||
| String tmpdir = System.getProperty("java.io.tmpdir"); | |||
| // java.io.tmpdir is not present in 1.1 | |||
| if (tmpdir == null) | |||
| return new File(name); | |||
| else | |||
| return new File(tmpdir, name); | |||
| } | |||
| /** | |||
| * Creates a list file. This temporary file contains a list of all files | |||
| * to be included in the cab, one file per line. | |||
| @@ -222,8 +245,8 @@ public class Cab extends MatchingTask { | |||
| protected File createListFile(Vector files) | |||
| throws IOException | |||
| { | |||
| File listFile = File.createTempFile("ant", null); | |||
| listFile.deleteOnExit(); | |||
| File listFile = createTempFile("ant", null); | |||
| PrintWriter writer = new PrintWriter(new FileOutputStream(listFile)); | |||
| for (int i = 0; i < files.size(); i++) | |||
| @@ -327,6 +350,7 @@ public class Cab extends MatchingTask { | |||
| try { | |||
| File listFile = createListFile(files); | |||
| ExecTask exec = createExec(); | |||
| File outFile = null; | |||
| // die if cabarc fails | |||
| exec.setFailonerror(true); | |||
| @@ -334,13 +358,19 @@ public class Cab extends MatchingTask { | |||
| if (!doVerbose) | |||
| { | |||
| File outFile = File.createTempFile("ant", null); | |||
| outFile.deleteOnExit(); | |||
| outFile = createTempFile("ant", null); | |||
| exec.setOutput(outFile); | |||
| } | |||
| exec.setCommand(createCommand(listFile)); | |||
| exec.execute(); | |||
| if (outFile != null) | |||
| { | |||
| outFile.delete(); | |||
| } | |||
| listFile.delete(); | |||
| } catch (IOException ioe) { | |||
| String msg = "Problem creating " + cabFile + " " + ioe.getMessage(); | |||
| throw new BuildException(msg); | |||