ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: jakarta-ant/proposal/xdocs build.xml
Date Wed, 05 Feb 2003 08:09:14 GMT
ehatcher    2003/02/05 00:09:12

  Modified:    proposal/xdocs build.xml
  Added:       proposal/xdocs/src/org/apache/tools/ant/xdoclet
                        IndexGen.java
  Log:
  added index generation
  
  Revision  Changes    Path
  1.1                  jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/IndexGen.java
  
  Index: IndexGen.java
  ===================================================================
  package org.apache.tools.ant.xdoclet;
  
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.BuildException;
  
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  
  public class IndexGen extends Task {
      private File destDir;
      private File rootDir;
  
      public void setDestDir(File destDir) {
          this.destDir = destDir;
      }
  
  
      public void setRootDir(File rootDir) {
          this.rootDir = rootDir;
      }
  
  
  
      public void execute() throws BuildException {
          String[] categories = rootDir.list();
  
          StringBuffer sb = new StringBuffer();
          sb.append("<html><head><title>xdocs index</title></head>");
          sb.append("<body>");
  
          for (int i=0; i < categories.length; i++) {
              String category = categories[i];
              File catDir = new File(rootDir, category);
  
              if (!catDir.isDirectory()) {
                  continue;
              }
  
              sb.append("<h2>" + category + "</h2>");
  
              sb.append("<ul>");
  
              String[] tasks = catDir.list();
  
              for (int j=0; j < tasks.length; j++) {
                  String task = tasks[j];
                  sb.append("<li>");
                  sb.append("<a href=\"" + category + "/" + task + "\">" + task + "</a>");
                  sb.append("</li>");
              }
  
              sb.append("</ul>");
  
          }
  
          sb.append("</body></html>");
  
          FileWriter fw = null;
          try {
              fw = new FileWriter(new File(destDir,"index.html"));
              fw.write(sb.toString());
              fw.close();
          } catch (IOException e) {
              throw new BuildException(e);
          }
      }
  }
  
  
  
  1.18      +18 -1     jakarta-ant/proposal/xdocs/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/xdocs/build.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- build.xml	4 Feb 2003 14:15:58 -0000	1.17
  +++ build.xml	5 Feb 2003 08:09:12 -0000	1.18
  @@ -451,7 +451,24 @@
       <ant dir="dvsl"/>
     </target>
   
  -  <target name="docs-from-scratch" depends="clean,gen,docs"/>
  +  <target name="compile" depends="init">
  +    <mkdir dir="${build.dir}/classes"/>
  +    <javac destdir="${build.dir}/classes"
  +           srcdir="src"
  +           debug="true"
  +           includes="**/IndexGen.java"
  +    />
  +  </target>
  +
  +  <target name="indexgen" depends="compile">
  +    <taskdef name="indexgen"
  +             classpath="${build.dir}/classes"
  +             classname="org.apache.tools.ant.xdoclet.IndexGen"
  +    />
  +    <indexgen rootdir="${build.dir}/docs/manual" destdir="${build.dir}/docs/manual"/>
  +  </target>
  +
  +  <target name="docs-from-scratch" depends="clean,gen,docs,indexgen"/>
   
     <target name="default" depends="gen"/>
   
  
  
  

Mime
View raw message