ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional Cab.java
Date Fri, 04 Aug 2000 06:53:13 GMT
bodewig     00/08/03 23:53:13

  Modified:    .        build.xml
               docs     index.html
               src/main/org/apache/tools/ant/taskdefs/optional Cab.java
  Log:
  Removed JDK 1.2+ dependency from <cab> task.
  Submitted by:	Roger Vaughn <rvaughn@seaconinc.com>
  
  Revision  Changes    Path
  1.56      +0 -1      jakarta-ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/build.xml,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- build.xml	2000/08/03 11:25:11	1.55
  +++ build.xml	2000/08/04 06:53:12	1.56
  @@ -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}">
  
  
  
  1.66      +60 -3     jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- index.html	2000/08/03 10:12:07	1.65
  +++ index.html	2000/08/04 06:53:12	1.66
  @@ -3356,11 +3356,68 @@
         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>
  +&lt;cab cabfile="${dist}/manual.cab"
  +     basedir="htdocs/manual" 
  +  /&gt;
  +</pre></blockquote>
  +<p>cabs all files in the htdocs/manual directory in a file called
  +manual.cab in the ${dist} directory.</p>
  +<blockquote><pre>
  +&lt;cab cabfile="${dist}/manual.cab"
  +     basedir="htdocs/manual"
  +     excludes="mydocs/**, **/todo.html"
  +  /&gt;
  +</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>
  +&lt;cab cabfile="${dist}/manual.cab"
  +     basedir="htdocs/manual"
  +     includes="api/**/*.html"
  +     excludes="**/todo.html"
  +     verbose="yes"
  +  /&gt;
  +</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>
  
  
  
  1.3       +35 -5     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  
  Index: Cab.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Cab.java	2000/08/03 11:25:12	1.2
  +++ Cab.java	2000/08/04 06:53:13	1.3
  @@ -62,6 +62,8 @@
   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 @@
        * create the .cab file.
        */
       public void setCabfile(File cabFile) {
  -        cabFile = cabFile;
  +        this.cabFile = cabFile;
       }
       
       /**
  @@ -215,6 +217,27 @@
           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 @@
       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 @@
           try {
               File listFile = createListFile(files);
               ExecTask exec = createExec();
  +            File outFile = null;
               
               // die if cabarc fails
               exec.setFailonerror(true);
  @@ -334,13 +358,19 @@
               
               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);
  
  
  

Mime
View raw message