attribute to set the path to the compiler. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272016 13f79535-47bb-0310-9956-ffa450edef68master
@@ -252,10 +252,15 @@ invoking the compiler.</p> | |||
<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> | |||
@@ -128,7 +128,7 @@ public class Javac extends MatchingTask { | |||
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 @@ public class Javac extends MatchingTask { | |||
/** | |||
* Sets whether to fork the javac compiler. | |||
* | |||
* @param f "true|false|on|off|yes|no" or the name of the javac | |||
* executable. | |||
*/ | |||
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; | |||
} | |||
* @param f "true|false|on|off|yes|no" | |||
*/ | |||
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 @@ public class Javac extends MatchingTask { | |||
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.", | |||
@@ -89,13 +89,13 @@ public class JavacTest extends TestCase { | |||
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 @@ public class JavacTest extends TestCase { | |||
javac.getJavacExecutable()); | |||
String myJavac = "Slartibartfast"; | |||
javac.setFork(myJavac); | |||
javac.setFork(true); | |||
javac.setExecutable(myJavac); | |||
assertEquals(myJavac, javac.getJavacExecutable()); | |||
} | |||
@@ -161,7 +162,7 @@ public class JavacTest extends TestCase { | |||
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 @@ public class JavacTest extends TestCase { | |||
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); | |||