diff --git a/WHATSNEW b/WHATSNEW
index 83dd833f3..39abdbd7b 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -68,6 +68,10 @@ Other changes:
* and can now optionally skip empty filesets.
+* has a new useexternalfile attribute that makes it use a
+ temporary file for sourcefile and package names - helps to defeat
+ command line length limitations.
+
Fixed bugs:
-----------
diff --git a/build.xml b/build.xml
index 47721d6c3..2484f01ea 100644
--- a/build.xml
+++ b/build.xml
@@ -553,6 +553,7 @@
description="--> creates the API documentation">
all |
No |
+
+ useexternalfile |
+ indicates whether the sourcefile name specified
+ in srcfiles or as nested source elements should be written to a
+ temporary file to make the command line shorter. Also applies to
+ the package names specified via the packagenames attribute or
+ nested package elements.
+ (yes | no ). Default is no. |
+ all |
+ No |
+
diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java
index b481ea9c4..7018bfe0a 100644
--- a/src/main/org/apache/tools/ant/Main.java
+++ b/src/main/org/apache/tools/ant/Main.java
@@ -509,7 +509,11 @@ public class Main {
System.out.println(msg.toString());
}
- private static void printVersion() {
+ private static void printVersion() throws BuildException {
+ System.out.println(getAntVersion());
+ }
+
+ public static String getAntVersion() throws BuildException {
try {
Properties props = new Properties();
InputStream in =
@@ -523,13 +527,12 @@ public class Main {
msg.append(props.getProperty("VERSION"));
msg.append(" compiled on ");
msg.append(props.getProperty("DATE"));
- msg.append(lSep);
- System.out.println(msg.toString());
+ return msg.toString();
} catch (IOException ioe) {
- System.err.println("Could not load the version information.");
- System.err.println(ioe.getMessage());
+ throw new BuildException("Could not load the version information:"
+ + ioe.getMessage());
} catch (NullPointerException npe) {
- System.err.println("Could not load the version information.");
+ throw new BuildException("Could not load the version information.");
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
index 088e9479d..1b35c4249 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
@@ -264,6 +264,16 @@ public class Javadoc extends Task {
private Html header = null;
private Html footer = null;
private Html bottom = null;
+ private boolean useExternalFile = false;
+ private File tmpList = null;
+
+ /**
+ * Work around command line length limit by using an external file
+ * for the sourcefiles.
+ */
+ public void setUseExternalFile(boolean b) {
+ useExternalFile = b;
+ }
/**
* Sets whether default exclusions should be used or not.
@@ -498,6 +508,7 @@ public class Javadoc extends Task {
header = text;
}
}
+
public void setFooter(String src) {
Html h = new Html();
h.addText(src);
@@ -508,6 +519,7 @@ public class Javadoc extends Task {
footer = text;
}
}
+
public void setBottom(String src) {
Html h = new Html();
h.addText(src);
@@ -518,6 +530,7 @@ public class Javadoc extends Task {
bottom = text;
}
}
+
public void setLinkoffline(String src) {
if (!javadoc1) {
LinkArgument le = createLink();
@@ -854,6 +867,7 @@ public class Javadoc extends Task {
}
+ tmpList = null;
if (packageNames.size() > 0) {
Vector packages = new Vector();
Enumeration enum = packageNames.elements();
@@ -881,10 +895,39 @@ public class Javadoc extends Task {
}
if (sourceFiles.size() > 0) {
- Enumeration enum = sourceFiles.elements();
- while (enum.hasMoreElements()) {
- SourceFile sf = (SourceFile) enum.nextElement();
- toExecute.createArgument().setValue(sf.getFile().getAbsolutePath());
+ PrintWriter srcListWriter = null;
+ try {
+
+ /**
+ * Write sourcefiles to a temporary file if requested.
+ */
+ if (useExternalFile) {
+ if (tmpList == null) {
+ tmpList = createTempFile();
+ toExecute.createArgument().setValue("@" + tmpList.getAbsolutePath());
+ }
+ srcListWriter = new PrintWriter(new FileWriter(tmpList.getAbsolutePath(),
+ true));
+ }
+
+ Enumeration enum = sourceFiles.elements();
+ while (enum.hasMoreElements()) {
+ SourceFile sf = (SourceFile) enum.nextElement();
+ String sourceFileName = sf.getFile().getAbsolutePath();
+ if (useExternalFile) {
+ srcListWriter.println(sourceFileName);
+ } else {
+ toExecute.createArgument().setValue(sourceFileName);
+ }
+ }
+
+ } catch (IOException e) {
+ throw new BuildException("Error creating temporary file",
+ e, location);
+ } finally {
+ if (srcListWriter != null) {
+ srcListWriter.close();
+ }
}
}
@@ -909,6 +952,12 @@ public class Javadoc extends Task {
} catch (IOException e) {
throw new BuildException("Javadoc failed: " + e, e, location);
} finally {
+
+ if (tmpList != null) {
+ tmpList.delete();
+ tmpList = null;
+ }
+
out.logFlush();
err.logFlush();
try {
@@ -975,32 +1024,53 @@ public class Javadoc extends Task {
fs.createExclude().setName(pkg);
}
- for (int j=0; j 0) {
- String pkgDir = packageDirs[i].replace('/','.').replace('\\','.');
- if (!addedPackages.contains(pkgDir)) {
- toExecute.createArgument().setValue(pkgDir);
- addedPackages.addElement(pkgDir);
+
+ for (int j=0; j 0) {
+ String pkgDir = packageDirs[i].replace('/','.').replace('\\','.');
+ if (!addedPackages.contains(pkgDir)) {
+ if (useExternalFile) {
+ packageListWriter.println(pkgDir);
+ } else {
+ toExecute.createArgument().setValue(pkgDir);
+ }
+ addedPackages.addElement(pkgDir);
+ }
}
}
}
+ } catch (IOException ioex) {
+ throw new BuildException("Error creating temporary file",
+ ioex, location);
+ } finally {
+ if (packageListWriter != null) {
+ packageListWriter.close();
+ }
}
}
@@ -1050,4 +1120,11 @@ public class Javadoc extends Task {
project.getProperties());
}
+ /**
+ * Creates a temporary file.
+ */
+ private File createTempFile() {
+ return new File("javadoc" + (new Random(System.currentTimeMillis())).nextLong());
+ }
+
}