Author: peterreilly
Date: Wed Nov 1 15:19:33 2006
New Revision: 470134
URL: http://svn.apache.org/viewvc?view=rev&rev=470134
Log:
bugzilla report 40852: useextenalfile of javadoc now applies to all command
line args
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/contributors.xml
ant/core/trunk/docs/manual/CoreTasks/javadoc.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
Modified: ant/core/trunk/CONTRIBUTORS
URL:
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?view=diff&rev=470134&r1=470133&r2=470134
==============================================================================
Binary files - no diff available.
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=470134&r1=470133&r2=470134
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Nov 1 15:19:33 2006
@@ -45,6 +45,9 @@
* Diagnostics catches and logs security exceptions when accessing system
properties.
+* <javadoc> useexternalfile now applies to all command line arguments
+ of javadoc. Bugzilla report 40852.
+
Changes from Ant 1.7.0Beta2 to Ant 1.7.0Beta3
=============================================
Modified: ant/core/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?view=diff&rev=470134&r1=470133&r2=470134
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Wed Nov 1 15:19:33 2006
@@ -189,6 +189,10 @@
</name>
<name>
<first>Daniel</first>
+ <last>Ribagnac</last>
+ </name>
+ <name>
+ <first>Daniel</first>
<last>Spilker</last>
</name>
<name>
Modified: ant/core/trunk/docs/manual/CoreTasks/javadoc.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/javadoc.html?view=diff&rev=470134&r1=470133&r2=470134
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/javadoc.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/javadoc.html Wed Nov 1 15:19:33 2006
@@ -413,7 +413,8 @@
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.
+ nested package elements.<em>Since Ant 1.7.0</em>, also applies
+ to all the other command line options.
(<code>yes</code> | <code>no</code>). Default is no.</td>
<td align="center" valign="top">all</td>
<td valign="top" align="center">No</td>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java?view=diff&rev=470134&r1=470133&r2=470134
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Wed Nov
1 15:19:33 2006
@@ -1966,9 +1966,14 @@
Project.MSG_WARN);
}
}
+ // If using an external file, write the command line options to it
+ if (useExternalFile && javadoc4) {
+ writeExternalArgs(toExecute);
+ }
File tmpList = null;
PrintWriter srcListWriter = null;
+
try {
/**
@@ -2072,6 +2077,92 @@
}
}
+ private void writeExternalArgs(Commandline toExecute) {
+ // If using an external file, write the command line options to it
+ File optionsTmpFile = null;
+ PrintWriter optionsListWriter = null;
+ try {
+ optionsTmpFile = FILE_UTILS.createTempFile(
+ "javadocOptions", "", null);
+ optionsTmpFile.deleteOnExit();
+ String[] listOpt = toExecute.getArguments();
+ toExecute.clearArgs();
+ toExecute.createArgument().setValue(
+ "@" + optionsTmpFile.getAbsolutePath());
+ optionsListWriter = new PrintWriter(
+ new FileWriter(optionsTmpFile.getAbsolutePath(), true));
+ for (int i = 0; i < listOpt.length; i++) {
+ String string = listOpt[i];
+ if (string.startsWith("-J-")) {
+ toExecute.createArgument().setValue(string);
+ } else {
+ if (string.startsWith("-")) {
+ optionsListWriter.print(string);
+ optionsListWriter.print(" ");
+ } else {
+ optionsListWriter.println(quoteString(string));
+ }
+ }
+ }
+ optionsListWriter.close();
+ } catch (IOException ex) {
+ if (optionsTmpFile != null) {
+ optionsTmpFile.delete();
+ }
+ throw new BuildException(
+ "Error creating or writing temporary file for javadoc options",
+ ex, getLocation());
+ } finally {
+ FILE_UTILS.close(optionsListWriter);
+ }
+ }
+
+ /**
+ * Quote a string to place in a @ file.
+ * @param str the string to quote
+ * @return the quoted string, if there is no need to quote the string,
+ * return the original string.
+ */
+ private String quoteString(String str) {
+ if (str.indexOf(' ') == -1
+ && str.indexOf('\'') == -1
+ && str.indexOf('"') == -1) {
+ return str;
+ }
+ if (str.indexOf('\'') == -1) {
+ return quoteString(str, '\'');
+ } else {
+ return quoteString(str, '"');
+ }
+ }
+
+ private String quoteString(String str, char delim) {
+ StringBuffer buf = new StringBuffer(str.length() * 2);
+ buf.append(delim);
+ if (str.indexOf('\\') != -1) {
+ str = replace(str, '\\', "\\\\");
+ }
+ if (str.indexOf(delim) != -1) {
+ str = replace(str, delim, "\\" + delim);
+ }
+ buf.append(str);
+ buf.append(delim);
+ return buf.toString();
+ }
+
+ private String replace(String str, char fromChar, String toString) {
+ StringBuffer buf = new StringBuffer(str.length() * 2);
+ for (int i = 0; i < str.length(); ++i) {
+ char ch = str.charAt(i);
+ if (ch == fromChar) {
+ buf.append(toString);
+ } else {
+ buf.append(ch);
+ }
+ }
+ return buf.toString();
+ }
+
/**
* Add the files matched by the nested source files to the Vector
* as SourceFile instances.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]