Browse Source

Suppress "ignoring compiler setting" warning in javac if the user

hasn't set the compiler.

PR: 13246


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273402 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
5698e6e909
3 changed files with 27 additions and 2 deletions
  1. +4
    -2
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  2. +10
    -0
      src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
  3. +13
    -0
      src/testcases/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java

+ 4
- 2
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -755,8 +755,10 @@ public class Javac extends MatchingTask {
String compilerImpl = getCompilerVersion(); String compilerImpl = getCompilerVersion();
if (fork) { if (fork) {
if (isJdkCompiler(compilerImpl)) { if (isJdkCompiler(compilerImpl)) {
log("Since fork is true, ignoring compiler setting.",
Project.MSG_WARN);
if (facade.hasBeenSet()) {
log("Since fork is true, ignoring compiler setting.",
Project.MSG_WARN);
}
compilerImpl = "extJavac"; compilerImpl = "extJavac";
} else { } else {
log("Since compiler setting isn't classic or modern," log("Since compiler setting isn't classic or modern,"


+ 10
- 0
src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java View File

@@ -164,4 +164,14 @@ public class FacadeTaskHelper {
tmp.copyInto(res); tmp.copyInto(res);
return res; return res;
} }

/**
* Tests whether the implementation has been chosen by the user
* (either via a magic property or explicitly.
*
* @since Ant 1.5.2
*/
public boolean hasBeenSet() {
return userChoice != null || magicValue != null;
}
} }

+ 13
- 0
src/testcases/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java View File

@@ -84,4 +84,17 @@ public class FacadeTaskHelperTest extends TestCase {
fth.setImplementation("baz"); fth.setImplementation("baz");
assertEquals("baz", fth.getImplementation()); assertEquals("baz", fth.getImplementation());
} }

public void testHasBeenSet() {
FacadeTaskHelper fth = new FacadeTaskHelper("foo");
assertTrue("nothing set", !fth.hasBeenSet());
fth.setMagicValue(null);
assertTrue("magic has not been set", !fth.hasBeenSet());
fth.setMagicValue("foo");
assertTrue("magic has been set", fth.hasBeenSet());
fth.setMagicValue(null);
assertTrue(!fth.hasBeenSet());
fth.setImplementation("baz");
assertTrue("set explicitly", fth.hasBeenSet());
}
} }

Loading…
Cancel
Save