glennm 01/07/17 07:54:20
Modified: src/main/org/apache/tools/ant/taskdefs Javadoc.java
Log:
Look for java.home/../bin/javadoc(.exe) before falling
back on plain old javadoc. Just looking in the java.home
directory tree isn't sufficient, as it may give incorrect
results on Windows (thanks to Connor for the info.).
Revision Changes Path
1.56 +27 -2
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.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- Javadoc.java 2001/07/15 14:25:28 1.55
+++ Javadoc.java 2001/07/17 14:54:13 1.56
@@ -734,8 +734,7 @@
}
Commandline toExecute = (Commandline)cmd.clone();
- toExecute.setExecutable(System.getProperty("java.home") +
- "/../bin/javadoc");
+ toExecute.setExecutable( getJavadocExecutableName() );
// ------------------------------------------------ general javadoc arguments
if (classpath == null)
@@ -1142,6 +1141,32 @@
*/
private File createTempFile() {
return new File("javadoc" + (new
Random(System.currentTimeMillis())).nextLong());
+ }
+
+ private String getJavadocExecutableName()
+ {
+ // This is the most common extension case - exe for windows, nothing
+ // for *nix.
+ String extension =
(System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0) ?
+ ".exe" : "";
+
+ // Look for javadoc in the java.home/../bin directory. Unfortunately
+ // on Windows java.home doesn't always refer to the correct location,
+ // so we need to fall back to assuming javadoc is somewhere on the
+ // PATH.
+ File jdocExecutable = new File( System.getProperty("java.home") +
+ "/../bin/javadoc" + extension );
+
+ if (jdocExecutable.exists())
+ {
+ return jdocExecutable.getAbsolutePath();
+ }
+ else
+ {
+ log( "Unable to locate " + jdocExecutable.getAbsolutePath() +
+ ". Using \"javadoc\" instead.", Project.MSG_VERBOSE );
+ return "javadoc";
+ }
}
}