From fc7e3b1fd4127d10b74c77ec3bee2573b287cffd Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 25 Mar 2002 10:14:56 +0000 Subject: [PATCH] revert 's fork attribute to a true boolean and add executable 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-ffa450edef68 --- docs/manual/CoreTasks/javac.html | 13 +++++-- .../org/apache/tools/ant/taskdefs/Javac.java | 38 +++++++++---------- .../apache/tools/ant/taskdefs/JavacTest.java | 19 +++++----- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/docs/manual/CoreTasks/javac.html b/docs/manual/CoreTasks/javac.html index 55f54d5e0..a951f3e31 100644 --- a/docs/manual/CoreTasks/javac.html +++ b/docs/manual/CoreTasks/javac.html @@ -252,10 +252,15 @@ invoking the compiler.

fork Whether to execute javac using the - JDK compiler externally; defaults to no. You can also - give a complete path to the javac executable to use - instead of yes, which would run the compiler of the Java - version that is currently running Ant. + JDK compiler externally; defaults to no. + No + + + executable + Complete path to the javac + executable to use in case of fork="yes". + Defaults to the compiler of the Java version that is currently + running Ant. Ignored if fork="no" No diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index ff9526b90..e2e265732 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -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. + * + *

Ignored unless fork is true or extJavac has been specified + * as the compiler.

+ */ + 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.", diff --git a/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java b/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java index 3736c0c73..70b63b221 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java @@ -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);