00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 package org.doxygen.tools;
00059
00060 import org.apache.tools.ant.BuildException;
00061 import org.apache.tools.ant.Task;
00062 import org.apache.tools.ant.taskdefs.PumpStreamHandler;
00063 import org.apache.tools.ant.taskdefs.Execute;
00064
00065 import java.util.ArrayList;
00066 import java.util.Enumeration;
00067 import java.util.Iterator;
00068 import java.util.List;
00069 import java.util.Map;
00070 import java.util.Properties;
00071 import java.util.Set;
00072 import java.util.TreeMap;
00073 import java.util.Vector;
00074
00075 import java.io.BufferedReader;
00076 import java.io.File;
00077 import java.io.FileInputStream;
00078 import java.io.FileOutputStream;
00079 import java.io.IOException;
00080 import java.io.InputStreamReader;
00081 import java.io.PrintStream;
00082
00110 public class DoxygenTask extends Task {
00111
00116 public static final String CONFIG_FILE =
00117 System.getProperty("user.home") + File.separator + ".doxytmp";
00118
00123 private DoxygenConfig conf;
00124
00129 private DoxygenProcess proc;
00130
00131
00135 private boolean verbose = false;
00136
00137
00142 private String versionCompatible = null;
00143
00149 private String configFilename = null;
00150
00151
00155 public DoxygenTask() {
00156 proc = new DoxygenProcess();
00157 conf = new DoxygenConfig();
00158 }
00159
00160
00161
00168 public final void execute() throws BuildException {
00169 proc.checkVersion(versionCompatible);
00170 System.out.println("Version check complete");
00171 if (configFilename == null ) {
00172 configFilename = CONFIG_FILE;
00173 proc.createConfig(configFilename);
00174 }
00175 conf.writeDoxygenConfig(configFilename);
00176 System.out.println("Created Config file");
00177 proc.executeDoxygenConfig(configFilename);
00178
00179
00180
00181 }
00182
00183
00188 public final void setVersionCompatible(String newVersion) {
00189 versionCompatible = newVersion;
00190 }
00191
00192
00197 public final String getVersionCompatible() {
00198 return versionCompatible;
00199 }
00200
00201
00202
00203
00204
00205
00217 public final void setVerbose(final boolean attr) { verbose = attr; }
00218
00219
00220
00238 public final void setConfigFilename(final String attr) {
00239 configFilename = attr;
00240 }
00241
00242
00243
00255 public final void setDoxygenPath(final String attr) {
00256 proc.setDoxygenPath(attr);
00257 }
00258
00259
00260
00272 public final Property createProperty() {
00273 Property p = new Property();
00274 conf.addNestedAttribute(p);
00275 return p;
00276 }
00277
00278
00283 public final void setConfig(String name, String value) {
00284 Property p = new Property();
00285 p.setName(name);
00286 p.setValue(value);
00287 conf.addNestedAttribute(p);
00288 }
00289
00290
00295 public Map getTaskAttributes() {
00296 return conf.getTaskAttributes();
00297 }
00298
00312 public final void activityLog(final boolean terseMessage,
00313 final String theMessage) {
00314 if (theMessage != null) {
00315 if (terseMessage || verbose) {
00316 System.out.println(theMessage);
00317 }
00318 }
00319 }
00320
00321
00327 public static class Property {
00328
00330 private String key;
00331
00333 private String val;
00334
00335
00342 public final String getName() { return key; }
00343
00344
00345
00353 public final String getValue() { return val; }
00354
00355
00356
00364 public final void setName(final String theNewName) { key = theNewName; }
00365
00366
00367
00376 public final void setValue(final String theNewValue) {
00377 if (theNewValue.toLowerCase().equals("true")) {
00378 val = "YES";
00379 } else if (theNewValue.toLowerCase().equals("false")) {
00380 val = "NO";
00381 } else { val = theNewValue; }
00382 }
00383
00384
00385
00393 public final String toString() {
00394 return "Property=["
00395 + "key={" + key + "},"
00396 + "value={" + val + "},"
00397 + "]";
00398 }
00399 }
00400 }