diff --git a/WHATSNEW b/WHATSNEW
index a446214e7..04a413545 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -331,6 +331,16 @@ Other changes:
*
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"
fork="no"
.no
.
false
.
+Jvc will enable Microsoft extensions unless you set the property
+build.compiler.jvc.extensions
to false before invoking
+<javac>
.
Copyright © 2000-2003 Apache Software Foundation. All rights Reserved.
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 19996ee17..572e4f4fc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -141,6 +141,7 @@ public class Javac extends MatchingTask { private String source; private String debugLevel; + private File tmpDir; /** * Javac task for compilation of Java files. @@ -595,6 +596,15 @@ public class Javac extends MatchingTask { forkedExecutable = forkExec; } + /** + * The value of the executable attribute, if any. + * + * @since Ant 1.6 + */ + public String getExecutable() { + return forkedExecutable; + } + /** * Is this a forked invocation of JDK's javac? */ @@ -604,6 +614,14 @@ public class Javac extends MatchingTask { /** * The name of the javac executable to use in fork-mode. + * + *This is either the name specified with the executable + * attribute or the full path of the javac compiler of the VM Ant + * is currently running in - guessed by Ant.
+ * + *You should not invoke this method if you + * want to get the value of the executable command - use {@link + * #getExecutable getExecutable} for this.
*/ public String getJavacExecutable() { if (forkedExecutable == null && isForkedJavac()) { @@ -653,6 +671,23 @@ public class Javac extends MatchingTask { } } + /** + * Where Ant should place temporary files. + * + * @since Ant 1.6 + */ + public void setTempdir(File tmpDir) { + this.tmpDir = tmpDir; + } + + /** + * Where Ant should place temporary files. + * + * @since Ant 1.6 + */ + public File getTempdir() { + return tmpDir; + } /** * Executes the task. diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index fe5daec1d..b4c2442a3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -152,6 +152,13 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { return attributes; } + /** + * @since Ant 1.6 + */ + protected Project getProject() { + return project; + } + /** * Builds the compilation classpath. * @@ -432,8 +439,11 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { && firstFileName >= 0) { PrintWriter out = null; try { - String userDirName = System.getProperty("user.dir"); - File userDir = new File(userDirName); + File userDir = getJavac().getTempdir(); + if (userDir == null) { + String userDirName = System.getProperty("user.dir"); + userDir = new File(userDirName); + } tmpFile = fileUtils.createTempFile("files", "", userDir); out = new PrintWriter(new FileWriter(tmpFile)); for (int i = firstFileName; i < args.length; i++) { diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java index d54c92af4..cad1e1d0a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -112,7 +112,8 @@ public class Gcj extends DefaultCompilerAdapter { classpath.append(src); } - cmd.setExecutable("gcj"); + String exec = getJavac().getExecutable(); + cmd.setExecutable(exec == null ? "gcj" : exec); if (destDir != null) { cmd.createArgument().setValue("-d"); diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java index db5e3c373..18c06848d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java @@ -124,7 +124,8 @@ public class Jikes extends DefaultCompilerAdapter { } Commandline cmd = new Commandline(); - cmd.setExecutable("jikes"); + String exec = getJavac().getExecutable(); + cmd.setExecutable(exec == null ? "jikes" : exec); if (deprecation == true) { cmd.createArgument().setValue("-deprecation"); diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java index 96f5e4893..e5cbf4bb2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java @@ -104,7 +104,8 @@ public class Jvc extends DefaultCompilerAdapter { } Commandline cmd = new Commandline(); - cmd.setExecutable("jvc"); + String exec = getJavac().getExecutable(); + cmd.setExecutable(exec == null ? "jvc" : exec); if (destDir != null) { cmd.createArgument().setValue("/d"); @@ -115,10 +116,19 @@ public class Jvc extends DefaultCompilerAdapter { cmd.createArgument().setValue("/cp:p"); cmd.createArgument().setPath(classpath); - // Enable MS-Extensions and ... - cmd.createArgument().setValue("/x-"); - // ... do not display a Message about this. - cmd.createArgument().setValue("/nomessage"); + boolean msExtensions = true; + String mse = getProject().getProperty("build.compiler.jvc.extensions"); + if (mse != null) { + msExtensions = Project.toBoolean(mse); + } + + if (msExtensions) { + // Enable MS-Extensions and ... + cmd.createArgument().setValue("/x-"); + // ... do not display a Message about this. + cmd.createArgument().setValue("/nomessage"); + } + // Do not display Logo cmd.createArgument().setValue("/nologo"); diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java index 257eeeb83..bc41434a5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,7 +74,8 @@ public class Sj extends DefaultCompilerAdapter { attributes.log("Using symantec java compiler", Project.MSG_VERBOSE); Commandline cmd = setupJavacCommand(); - cmd.setExecutable("sj"); + String exec = getJavac().getExecutable(); + cmd.setExecutable(exec == null ? "sj" : exec); int firstFileName = cmd.size() - compileList.length;