bodewig 02/03/25 02:14:57
Modified: docs/manual/CoreTasks javac.html
src/main/org/apache/tools/ant/taskdefs Javac.java
src/testcases/org/apache/tools/ant/taskdefs JavacTest.java
Log:
revert <javac>'s fork attribute to a true boolean and add executable
attribute to set the path to the compiler.
Revision Changes Path
1.31 +9 -4 jakarta-ant/docs/manual/CoreTasks/javac.html
Index: javac.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/javac.html,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- javac.html 21 Mar 2002 09:17:01 -0000 1.30
+++ javac.html 25 Mar 2002 10:14:56 -0000 1.31
@@ -252,10 +252,15 @@
<tr>
<td valign="top">fork</td>
<td valign="top">Whether to execute <code>javac</code> using the
- JDK compiler externally; defaults to <code>no</code>. You can also
- give a complete path to the <code>javac</code> executable to use
- instead of <code>yes</code>, which would run the compiler of the Java
- version that is currently running Ant.</td>
+ JDK compiler externally; defaults to <code>no</code>.</td>
+ <td align="center" valign="top">No</td>
+ </tr>
+ <tr>
+ <td valign="top">executable</td>
+ <td valign="top">Complete path to the <code>javac</code>
+ executable to use in case of <code>fork="yes"</code>.
+ Defaults to the compiler of the Java version that is currently
+ running Ant. Ignored if <code>fork="no"</code></td>
<td align="center" valign="top">No</td>
</tr>
<tr>
1.91 +17 -21
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java
Index: Javac.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- Javac.java 21 Mar 2002 08:19:07 -0000 1.90
+++ Javac.java 25 Mar 2002 10:14:56 -0000 1.91
@@ -103,7 +103,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
* @author <a href="mailto:[EMAIL PROTECTED]">J D Glanville</a>
*
- * @version $Revision: 1.90 $
+ * @version $Revision: 1.91 $
*
* @ant.task category="java"
*/
@@ -128,7 +128,7 @@
private Path extdirs;
private boolean includeAntRuntime = true;
private boolean includeJavaRuntime = false;
- private String fork = "false";
+ private boolean fork = false;
private String forkedExecutable = null;
private boolean nowarn = false;
private String memoryInitialSize;
@@ -547,31 +547,27 @@
/**
* Sets whether to fork the javac compiler.
*
- * @param f "true|false|on|off|yes|no" or the name of the javac
- * executable.
+ * @param f "true|false|on|off|yes|no"
*/
- public void setFork(String f) {
- if (f.equalsIgnoreCase("on")
- || f.equalsIgnoreCase("true")
- || f.equalsIgnoreCase("yes")) {
- fork = "true";
- forkedExecutable = getSystemJavac();
- } else if (f.equalsIgnoreCase("off")
- || f.equalsIgnoreCase("false")
- || f.equalsIgnoreCase("no")) {
- fork = "false";
- forkedExecutable = null;
- } else {
- fork = "true";
- forkedExecutable = f;
- }
+ public void setFork(boolean f) {
+ fork = f;
+ }
+
+ /**
+ * Sets the the name of the javac executable.
+ *
+ * <p>Ignored unless fork is true or extJavac has been specified
+ * as the compiler.</p>
+ */
+ public void setExecutable(String forkExec) {
+ forkedExecutable = forkExec;
}
/**
* Is this a forked invocation of JDK's javac?
*/
public boolean isForkedJavac() {
- return !"false".equals(fork) || "extJavac".equals(getCompiler());
+ return fork || "extJavac".equals(getCompiler());
}
/**
@@ -753,7 +749,7 @@
this.compiler != null ? this.compiler
: project.getProperty("build.compiler");
- if (!"false".equals(fork)) {
+ if (fork) {
if (compilerImpl != null) {
if (isJdkCompiler(compilerImpl)) {
log("Since fork is true, ignoring compiler setting.",
1.4 +11 -10
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java
Index: JavacTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JavacTest.java 15 Feb 2002 13:42:53 -0000 1.3
+++ JavacTest.java 25 Mar 2002 10:14:56 -0000 1.4
@@ -62,7 +62,7 @@
* Testcase for <javac>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
- * @version $Revision: 1.3 $ $Date: 2002/02/15 13:42:53 $
+ * @version $Revision: 1.4 $ $Date: 2002/03/25 10:14:56 $
*/
public class JavacTest extends TestCase {
@@ -89,13 +89,13 @@
project.setProperty("build.compiler", "modern");
assertNull("no fork means no executable",
javac.getJavacExecutable());
- javac.setFork("true");
+ javac.setFork(true);
assertNotNull("normal fork", javac.getJavacExecutable());
assertTrue("name should contain \"javac\"",
javac.getJavacExecutable().indexOf("javac") > -1);
project.setProperty("build.compiler", "extJavac");
- javac.setFork("false");
+ javac.setFork(false);
assertNotNull("fork via property", javac.getJavacExecutable());
assertTrue("name should contain \"javac\"",
javac.getJavacExecutable().indexOf("javac") > -1);
@@ -105,7 +105,8 @@
javac.getJavacExecutable());
String myJavac = "Slartibartfast";
- javac.setFork(myJavac);
+ javac.setFork(true);
+ javac.setExecutable(myJavac);
assertEquals(myJavac, javac.getJavacExecutable());
}
@@ -161,7 +162,7 @@
String testArg = ford + " " + prefect;
arg.setValue(testArg);
arg.setImplementation("extJavac");
- javac.setFork("true");
+ javac.setFork(true);
String[] args = javac.getCurrentCompilerArgs();
assertEquals("both are forked javac", 1, args.length);
assertEquals(testArg, args[0]);
@@ -177,31 +178,31 @@
assertTrue("default value",
"modern".equals(compiler) || "classic".equals(compiler));
- javac.setFork("true");
+ javac.setFork(true);
compiler = javac.getCompiler();
assertNotNull(compiler);
assertEquals("extJavac", compiler);
// check build.compiler provides defaults
- javac.setFork("false");
+ javac.setFork(false);
project.setNewProperty("build.compiler", "jikes");
compiler = javac.getCompiler();
assertNotNull(compiler);
assertEquals("jikes", compiler);
- javac.setFork("true");
+ javac.setFork(true);
compiler = javac.getCompiler();
assertNotNull(compiler);
assertEquals("jikes", compiler);
// check attribute overrides build.compiler
- javac.setFork("false");
+ javac.setFork(false);
javac.setCompiler("jvc");
compiler = javac.getCompiler();
assertNotNull(compiler);
assertEquals("jvc", compiler);
- javac.setFork("true");
+ javac.setFork(true);
compiler = javac.getCompiler();
assertNotNull(compiler);
assertEquals("jvc", compiler);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>