ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Javadoc.java
Date Wed, 23 May 2001 16:44:18 GMT
bodewig     01/05/23 09:44:17

  Modified:    .        WHATSNEW build.xml
               docs/manual/CoreTasks javadoc.html
               src/main/org/apache/tools/ant Main.java
               src/main/org/apache/tools/ant/taskdefs Javadoc.java
  Log:
  Added useexternalfile attribute to <javadoc> - this makes javadoc use
  a temporary file for source file and package names (via javadoc's
  @file parameter) to defeat command line length limitations.
  
  Inspired by:	Frederic Lavigne <fred@castify.net>
  
  Revision  Changes    Path
  1.110     +4 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- WHATSNEW	2001/05/22 09:58:26	1.109
  +++ WHATSNEW	2001/05/23 16:43:45	1.110
  @@ -68,6 +68,10 @@
   
   * <execon> and <apply> can now optionally skip empty filesets.
   
  +* <javadoc> has a new useexternalfile attribute that makes it use a
  +  temporary file for sourcefile and package names - helps to defeat
  +  command line length limitations.
  +
   Fixed bugs:
   -----------
   
  
  
  
  1.153     +1 -0      jakarta-ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/build.xml,v
  retrieving revision 1.152
  retrieving revision 1.153
  diff -u -r1.152 -r1.153
  --- build.xml	2001/05/11 06:22:41	1.152
  +++ build.xml	2001/05/23 16:43:47	1.153
  @@ -553,6 +553,7 @@
             description="--> creates the API documentation">
       <mkdir dir="${build.javadocs}"/>
       <javadoc packagenames="org.apache.*"
  +             useexternalfile="yes"
                sourcepath="${java.dir}"
                destdir="${build.javadocs}"
                author="true"
  
  
  
  1.9       +11 -0     jakarta-ant/docs/manual/CoreTasks/javadoc.html
  
  Index: javadoc.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/javadoc.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- javadoc.html	2001/05/22 10:03:24	1.8
  +++ javadoc.html	2001/05/23 16:43:58	1.9
  @@ -375,6 +375,17 @@
       <td align="center" valign="top">all</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">useexternalfile</td>
  +    <td valign="top">indicates whether the sourcefile name specified
  +      in srcfiles or as nested source elements should be written to a
  +      temporary file to make the command line shorter. Also applies to
  +      the package names specified via the packagenames attribute or
  +      nested package elements.
  +      (<code>yes</code> | <code>no</code>). Default is no.</td>
  +    <td align="center" valign="top">all</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
   </table>
   
   <h4><a name="groupattribute">Format of the group attribute</a></h4>
  
  
  
  1.35      +9 -6      jakarta-ant/src/main/org/apache/tools/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Main.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Main.java	2001/05/10 15:22:41	1.34
  +++ Main.java	2001/05/23 16:44:04	1.35
  @@ -509,7 +509,11 @@
           System.out.println(msg.toString());
       }
   
  -    private static void printVersion() {
  +    private static void printVersion() throws BuildException {
  +        System.out.println(getAntVersion());
  +    }
  +
  +    public static String getAntVersion() throws BuildException {
           try {
               Properties props = new Properties();
               InputStream in =
  @@ -523,13 +527,12 @@
               msg.append(props.getProperty("VERSION"));
               msg.append(" compiled on ");
               msg.append(props.getProperty("DATE"));
  -            msg.append(lSep);
  -            System.out.println(msg.toString());
  +            return msg.toString();
           } catch (IOException ioe) {
  -            System.err.println("Could not load the version information.");
  -            System.err.println(ioe.getMessage());
  +            throw new BuildException("Could not load the version information:"
  +                                     + ioe.getMessage());
           } catch (NullPointerException npe) {
  -            System.err.println("Could not load the version information.");
  +            throw new BuildException("Could not load the version information.");
           }
       }
   
  
  
  
  1.50      +103 -26   jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  
  Index: Javadoc.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- Javadoc.java	2001/05/17 09:56:22	1.49
  +++ Javadoc.java	2001/05/23 16:44:11	1.50
  @@ -264,8 +264,18 @@
       private Html header = null;
       private Html footer = null;
       private Html bottom = null;
  +    private boolean useExternalFile = false;
  +    private File tmpList = null;
   
       /**
  +     * Work around command line length limit by using an external file
  +     * for the sourcefiles.
  +     */
  +    public void setUseExternalFile(boolean b) {
  +        useExternalFile = b;
  +    }
  +
  +    /**
        * Sets whether default exclusions should be used or not.
        *
        * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions 
  @@ -498,6 +508,7 @@
               header = text;
           }
       }
  +
       public void setFooter(String src) {
           Html h = new Html();
           h.addText(src);
  @@ -508,6 +519,7 @@
               footer = text;
           }
       }
  +
       public void setBottom(String src) {
           Html h = new Html();
           h.addText(src);
  @@ -518,6 +530,7 @@
               bottom = text;
           }
       }
  +
       public void setLinkoffline(String src) {
           if (!javadoc1) {
               LinkArgument le = createLink();
  @@ -854,6 +867,7 @@
   
           }
   
  +        tmpList = null;
           if (packageNames.size() > 0) {
               Vector packages = new Vector();
               Enumeration enum = packageNames.elements();
  @@ -881,10 +895,39 @@
           }
   
           if (sourceFiles.size() > 0) {
  -            Enumeration enum = sourceFiles.elements();
  -            while (enum.hasMoreElements()) {
  -                SourceFile sf = (SourceFile) enum.nextElement();
  -                toExecute.createArgument().setValue(sf.getFile().getAbsolutePath());
  +            PrintWriter srcListWriter = null;
  +            try {
  +
  +                /**
  +                 * Write sourcefiles to a temporary file if requested.
  +                 */
  +                if (useExternalFile) {
  +                    if (tmpList == null) {
  +                        tmpList = createTempFile();
  +                        toExecute.createArgument().setValue("@" + tmpList.getAbsolutePath());
  +                    }
  +                    srcListWriter = new PrintWriter(new FileWriter(tmpList.getAbsolutePath(),

  +                                                                   true));
  +                }
  +            
  +                Enumeration enum = sourceFiles.elements();
  +                while (enum.hasMoreElements()) {
  +                    SourceFile sf = (SourceFile) enum.nextElement();
  +                    String sourceFileName = sf.getFile().getAbsolutePath();
  +                    if (useExternalFile) {
  +                        srcListWriter.println(sourceFileName);
  +                    } else {
  +                        toExecute.createArgument().setValue(sourceFileName);
  +                    }
  +                }
  +
  +            } catch (IOException e) {
  +                throw new BuildException("Error creating temporary file", 
  +                                         e, location);
  +            } finally {
  +                if (srcListWriter != null) {
  +                    srcListWriter.close();
  +                }
               }
           }
   
  @@ -909,6 +952,12 @@
           } catch (IOException e) {
               throw new BuildException("Javadoc failed: " + e, e, location);
           } finally {
  +
  +            if (tmpList != null) {
  +                tmpList.delete();
  +                tmpList = null;
  +            }
  +            
               out.logFlush();
               err.logFlush();
               try {
  @@ -975,32 +1024,53 @@
               fs.createExclude().setName(pkg);
           }
           
  -        for (int j=0; j<list.length; j++) {
  -            File source = project.resolveFile(list[j]);
  -            fs.setDir(source);
  -
  -            DirectoryScanner ds = fs.getDirectoryScanner(project);
  -            String[] packageDirs = ds.getIncludedDirectories();
  -
  -            for (int i=0; i<packageDirs.length; i++) {
  -                File pd = new File(source, packageDirs[i]);
  -                String[] files = pd.list(new FilenameFilter () {
  -                    public boolean accept(File dir1, String name) {
  -                        if (name.endsWith(".java")) {
  -                            return true;
  -                        }
  -                        return false;	// ignore dirs
  -                    }
  -                });
  +        PrintWriter packageListWriter = null;
  +        try {
  +            if (useExternalFile) {
  +                tmpList = createTempFile();
  +                toExecute.createArgument().setValue("@" + tmpList.getAbsolutePath());
  +                packageListWriter = new PrintWriter(new FileWriter(tmpList));
  +            }
   
  -                if (files.length > 0) {
  -                    String pkgDir = packageDirs[i].replace('/','.').replace('\\','.');
  -                    if (!addedPackages.contains(pkgDir)) {
  -                        toExecute.createArgument().setValue(pkgDir);
  -                        addedPackages.addElement(pkgDir);
  +
  +            for (int j=0; j<list.length; j++) {
  +                File source = project.resolveFile(list[j]);
  +                fs.setDir(source);
  +                
  +                DirectoryScanner ds = fs.getDirectoryScanner(project);
  +                String[] packageDirs = ds.getIncludedDirectories();
  +                
  +                for (int i=0; i<packageDirs.length; i++) {
  +                    File pd = new File(source, packageDirs[i]);
  +                    String[] files = pd.list(new FilenameFilter () {
  +                            public boolean accept(File dir1, String name) {
  +                                if (name.endsWith(".java")) {
  +                                    return true;
  +                                }
  +                                return false;	// ignore dirs
  +                            }
  +                        });
  +                    
  +                    if (files.length > 0) {
  +                        String pkgDir = packageDirs[i].replace('/','.').replace('\\','.');
  +                        if (!addedPackages.contains(pkgDir)) {
  +                            if (useExternalFile) {
  +                                packageListWriter.println(pkgDir);
  +                            } else {
  +                                toExecute.createArgument().setValue(pkgDir);
  +                            }
  +                            addedPackages.addElement(pkgDir);
  +                        }
                       }
                   }
               }
  +        } catch (IOException ioex) {
  +            throw new BuildException("Error creating temporary file", 
  +                                     ioex, location);
  +        } finally {
  +            if (packageListWriter != null) {
  +                packageListWriter.close();
  +            }
           }
       }
   
  @@ -1050,4 +1120,11 @@
                                                  project.getProperties());
       }
   
  +    /**
  +     * Creates a temporary file.
  +     */
  +    private File createTempFile() {
  +        return new File("javadoc" + (new Random(System.currentTimeMillis())).nextLong());
  +    }
  +    
   }
  
  
  

Mime
View raw message