以防万一其他人仍然感兴趣 - Antjavadoc
任务可以很容易地通过选项outputFile
将生成的消息存储到文件中进行改进:
public class MyJavaDoc extends org.apache.tools.ant.taskdefs.Javadoc{
private File _outFile;
private Writer _writer;
/**
* The file to write error output to.
*/
public void setOutputFile(File outFile) {
_outFile = outFile;
}
@Override
public void execute() throws BuildException {
if (_outFile == null) {
throw new BuildException("Missing 'outputFile' parameter.");
}
try (OutputStream out = new FileOutputStream(_outFile)) {
_writer = new OutputStreamWriter(out);
try {
super.execute();
} finally {
_writer.close();
}
} catch (IOException ex) {
throw new BuildException("Cannot write error output: " + ex.getMessage(), ex);
}
}
@Override
public void log(String msg, int msgLevel) {
if (msgLevel <= Project.MSG_WARN) {
try {
_writer.write(msg);
_writer.write("\n");
} catch (IOException ex) {
throw new IOError(ex);
}
}
super.log(msg, msgLevel);
}
}