Browse Source

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.).


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269351 13f79535-47bb-0310-9956-ffa450edef68
master
glennm 24 years ago
parent
commit
cbef49e344
1 changed files with 27 additions and 2 deletions
  1. +27
    -2
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java

+ 27
- 2
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -734,8 +734,7 @@ public class Javadoc extends Task {
}

Commandline toExecute = (Commandline)cmd.clone();
toExecute.setExecutable(System.getProperty("java.home") +
"/../bin/javadoc");
toExecute.setExecutable( getJavadocExecutableName() );

// ------------------------------------------------ general javadoc arguments
if (classpath == null)
@@ -1143,5 +1142,31 @@ public class Javadoc extends Task {
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";
}
}
}

Loading…
Cancel
Save