1 19 20 package org.netbeans.nbbuild; 21 22 import java.io.File ; 23 import java.util.*; 24 import java.util.ArrayList ; 25 import java.util.ArrayList ; 26 27 import org.apache.tools.ant.BuildException; 28 import org.apache.tools.ant.Task; 29 import org.apache.tools.ant.taskdefs.*; 30 import org.apache.tools.ant.types.*; 31 32 36 public class GenerateJavadoc extends Task 37 { 38 private File dest; 39 private List <String > modules = new ArrayList <String >(); 40 private String packageNames = null; 41 private List <File > topdirs = new ArrayList <File >(); 42 43 44 public void setDestdir(File f) { 45 dest = f; 46 } 47 48 49 public void setModules (String s) { 50 StringTokenizer tok = new StringTokenizer (s, ","); 51 modules = new ArrayList <String >(); 52 while (tok.hasMoreTokens ()) 53 modules.add(tok.nextToken ()); 54 } 55 56 57 public void setPackageNames (String s) { 58 packageNames = s; 59 } 60 61 64 public void setTopdir (File t) { 65 topdirs.add (t); 66 } 67 68 69 public class Topdir { 70 71 public void setPath (File t) { 72 topdirs.add (t); 73 } 74 } 75 76 82 public Topdir createTopdir () { 83 return new Topdir (); 84 } 85 86 public void execute () throws BuildException { 87 88 if (topdirs.isEmpty ()) { 89 throw new BuildException("You must set at least one topdir attribute", getLocation()); 90 } 91 92 98 Path path = new Path(getProject()); 99 for (File topdir : topdirs) { 100 for (String module : modules) { 101 File sources = new File (new File (topdir, module), "javadoc-temp/"); 102 if (! sources.exists ()) { sources = new File (new File (topdir, module), "src/"); 104 if (sources.exists ()) 105 path.append(new Path(getProject(), sources.getPath())); 106 sources = new File (new File (topdir, module), "libsrc/"); 107 if (sources.exists ()) 108 path.append(new Path(getProject(), sources.getPath())); 109 } 110 else { 111 path.append(new Path(getProject(), sources.getPath())); 112 } 113 } 114 } 115 Javadoc javaDoc = (Javadoc) getProject().createTask("javadoc"); 116 javaDoc.setSourcepath( path ); 117 118 javaDoc.setDestdir( dest ); 119 if (packageNames != null) 120 javaDoc.setPackagenames(packageNames); 121 else javaDoc.setPackagenames("org.netbeans.*,com.sun.*"); 122 javaDoc.setUse(true); 123 javaDoc.setMaxmemory("256M"); 124 javaDoc.execute(); 125 126 } 127 } 128 | Popular Tags |