Browse Source

Added verbose and depend attributes to <javac> along with yet another

undocumented magic property (YAUMP?) build.compiler.fulldepend that
triggers Jikes' +F option.
Submitted by:	Sean Brandt <sean@fuzzymagic.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268011 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
d36ee0d77c
2 changed files with 57 additions and 13 deletions
  1. +10
    -0
      docs/index.html
  2. +47
    -13
      src/main/org/apache/tools/ant/taskdefs/Javac.java

+ 10
- 0
docs/index.html View File

@@ -2496,6 +2496,16 @@ inclusion/exclusion of files works, and how to write patterns.</p>
&quot;1.1&quot; or &quot;1.2&quot;.</td> &quot;1.1&quot; or &quot;1.2&quot;.</td>
<td align="center" valign="top">No</td> <td align="center" valign="top">No</td>
</tr> </tr>
<tr>
<td valign="top">verbose</td>
<td valign="top">asks the compiler for verbose output.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">depend</td> <td valign="top">enables dependency
tracking for compilers that support this (jikes and modern)</td>
<td align="center" valign="top">No</td>
</tr>
</table> </table>


<h3>Parameters specified as nested elements</h3> <h3>Parameters specified as nested elements</h3>


+ 47
- 13
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -77,6 +77,8 @@ import java.util.*;
* <li>debug * <li>debug
* <li>encoding * <li>encoding
* <li>target * <li>target
* <li>depend
* <li>vebose
* </ul> * </ul>
* Of these arguments, the <b>sourcedir</b> and <b>destdir</b> are required. * Of these arguments, the <b>sourcedir</b> and <b>destdir</b> are required.
* <p> * <p>
@@ -105,6 +107,8 @@ public class Javac extends MatchingTask {
private boolean debug = false; private boolean debug = false;
private boolean optimize = false; private boolean optimize = false;
private boolean deprecation = false; private boolean deprecation = false;
private boolean depend = false;
private boolean verbose = false;
private String target; private String target;
private Path bootclasspath; private Path bootclasspath;
private Path extdirs; private Path extdirs;
@@ -251,6 +255,20 @@ public class Javac extends MatchingTask {
this.optimize = optimize; this.optimize = optimize;
} }


/**
* Set the depend flag.
*/
public void setDepend(boolean depend) {
this.depend = depend;
}

/**
* Set the verbose flag.
*/
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}

/** /**
* Sets the target VM that the classes will be compiled for. Valid * Sets the target VM that the classes will be compiled for. Valid
* strings are "1.1", "1.2", and "1.3". * strings are "1.1", "1.2", and "1.3".
@@ -522,6 +540,21 @@ public class Javac extends MatchingTask {
cmd.createArgument().setPath(extdirs); cmd.createArgument().setPath(extdirs);
} }


if (depend) {
if (Project.getJavaVersion().startsWith("1.1")) {
cmd.createArgument().setValue("-depend");
} else if (Project.getJavaVersion().startsWith("1.2")) {
cmd.createArgument().setValue("-Xdepend");
} else {
log("depend attribute is not supported by the modern compiler",
Project.MSG_WARN);
}
}

if (verbose) {
cmd.createArgument().setValue("-verbose");
}

logAndAddFilesToCompile(cmd); logAndAddFilesToCompile(cmd);
return cmd; return cmd;
} }
@@ -608,7 +641,17 @@ public class Javac extends MatchingTask {
if (optimize) { if (optimize) {
cmd.createArgument().setValue("-O"); cmd.createArgument().setValue("-O");
} }

if (verbose) {
cmd.createArgument().setValue("-verbose");
}
if (depend) {
cmd.createArgument().setValue("-depend");
String fullDependProperty = project.getProperty("build.compiler.fulldepend");
if (fullDependProperty != null
&& Project.toBoolean(fullDependProperty)) {
cmd.createArgument().setValue("+F");
}
}
/** /**
* XXX * XXX
* Perhaps we shouldn't use properties for these * Perhaps we shouldn't use properties for these
@@ -623,10 +666,7 @@ public class Javac extends MatchingTask {
* to the place, where the error occured. * to the place, where the error occured.
*/ */
String emacsProperty = project.getProperty("build.compiler.emacs"); String emacsProperty = project.getProperty("build.compiler.emacs");
if (emacsProperty != null &&
(emacsProperty.equalsIgnoreCase("on") ||
emacsProperty.equalsIgnoreCase("true"))
) {
if (emacsProperty != null && Project.toBoolean(emacsProperty)) {
cmd.createArgument().setValue("+E"); cmd.createArgument().setValue("+E");
} }


@@ -637,10 +677,7 @@ public class Javac extends MatchingTask {
* warning can be pretty annoying. * warning can be pretty annoying.
*/ */
String warningsProperty = project.getProperty("build.compiler.warnings"); String warningsProperty = project.getProperty("build.compiler.warnings");
if (warningsProperty != null &&
(warningsProperty.equalsIgnoreCase("off") ||
warningsProperty.equalsIgnoreCase("false"))
) {
if (warningsProperty != null && !Project.toBoolean(warningsProperty)) {
cmd.createArgument().setValue("-nowarn"); cmd.createArgument().setValue("-nowarn");
} }


@@ -648,10 +685,7 @@ public class Javac extends MatchingTask {
* Jikes can issue pedantic warnings. * Jikes can issue pedantic warnings.
*/ */
String pedanticProperty = project.getProperty("build.compiler.pedantic"); String pedanticProperty = project.getProperty("build.compiler.pedantic");
if (pedanticProperty != null &&
(pedanticProperty.equalsIgnoreCase("on") ||
pedanticProperty.equalsIgnoreCase("true"))
) {
if (pedanticProperty != null && Project.toBoolean(pedanticProperty)) {
cmd.createArgument().setValue("+P"); cmd.createArgument().setValue("+P");
} }


Loading…
Cancel
Save