Browse Source

bugzilla report 40852: useextenalfile of javadoc now applies to all command line args

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@470134 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
7254e769ce
5 changed files with 101 additions and 1 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +2
    -1
      docs/manual/CoreTasks/javadoc.html
  5. +91
    -0
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java

+ 1
- 0
CONTRIBUTORS View File

@@ -44,6 +44,7 @@ Curtis White
Cyrille Morvan Cyrille Morvan
Dale Anson Dale Anson
Dan Armbrust Dan Armbrust
Daniel Ribagnac
Daniel Spilker Daniel Spilker
Danno Ferrin Danno Ferrin
Davanum Srinivas Davanum Srinivas


+ 3
- 0
WHATSNEW View File

@@ -45,6 +45,9 @@ Other changes:


* Diagnostics catches and logs security exceptions when accessing system properties. * 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 Changes from Ant 1.7.0Beta2 to Ant 1.7.0Beta3
============================================= =============================================


+ 4
- 0
contributors.xml View File

@@ -187,6 +187,10 @@
<first>Dan</first> <first>Dan</first>
<last>Armbrust</last> <last>Armbrust</last>
</name> </name>
<name>
<first>Daniel</first>
<last>Ribagnac</last>
</name>
<name> <name>
<first>Daniel</first> <first>Daniel</first>
<last>Spilker</last> <last>Spilker</last>


+ 2
- 1
docs/manual/CoreTasks/javadoc.html View File

@@ -413,7 +413,8 @@ to ensure that this command supports the attributes you wish to use.</p>
in srcfiles or as nested source elements should be written to a in srcfiles or as nested source elements should be written to a
temporary file to make the command line shorter. Also applies to temporary file to make the command line shorter. Also applies to
the package names specified via the packagenames attribute or 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> (<code>yes</code> | <code>no</code>). Default is no.</td>
<td align="center" valign="top">all</td> <td align="center" valign="top">all</td>
<td valign="top" align="center">No</td> <td valign="top" align="center">No</td>


+ 91
- 0
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -1966,9 +1966,14 @@ public class Javadoc extends Task {
Project.MSG_WARN); Project.MSG_WARN);
} }
} }
// If using an external file, write the command line options to it
if (useExternalFile && javadoc4) {
writeExternalArgs(toExecute);
}


File tmpList = null; File tmpList = null;
PrintWriter srcListWriter = null; PrintWriter srcListWriter = null;

try { try {


/** /**
@@ -2072,6 +2077,92 @@ public class Javadoc extends Task {
} }
} }


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 * Add the files matched by the nested source files to the Vector
* as SourceFile instances. * as SourceFile instances.


Loading…
Cancel
Save