From f0c61ad2f516641eca642c99ca35fe2ac7c58746 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 15 May 2003 12:44:01 +0000 Subject: [PATCH] 's executable attribute can now also be used to specify the executable for jikes, jvc, sj or gcj. PR: 13814 has a new attribute tempdir that can control the placement of temporary files. PR: 19765 A new magic property build.compiler.jvc.extensions has been added that can be used to turn of Microsoft extensions while using the jvc compiler. PR: 19826 Submitted by: Joseph Walton git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274584 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 10 +++++ docs/manual/CoreTasks/javac.html | 17 ++++++++- .../org/apache/tools/ant/taskdefs/Javac.java | 37 ++++++++++++++++++- .../compilers/DefaultCompilerAdapter.java | 14 ++++++- .../tools/ant/taskdefs/compilers/Gcj.java | 5 ++- .../tools/ant/taskdefs/compilers/Jikes.java | 3 +- .../tools/ant/taskdefs/compilers/Jvc.java | 20 +++++++--- .../tools/ant/taskdefs/compilers/Sj.java | 5 ++- 8 files changed, 97 insertions(+), 14 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index a446214e7..04a413545 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -331,6 +331,16 @@ Other changes: * now supports the -noqualifier switch. Bugzilla Report 19288. +* 's executable attribute can now also be used to specify the + executable for jikes, jvc, sj or gcj. Bugzilla Report 13814. + +* has a new attribute tempdir that can control the placement + of temporary files. Bugzilla Report 19765. + +* A new magic property build.compiler.jvc.extensions has been added + that can be used to turn of Microsoft extensions while using the jvc + compiler. Bugzilla Report 19826. + Changes from Ant 1.5.2 to Ant 1.5.3 =================================== diff --git a/docs/manual/CoreTasks/javac.html b/docs/manual/CoreTasks/javac.html index 371834110..4fc9284bd 100644 --- a/docs/manual/CoreTasks/javac.html +++ b/docs/manual/CoreTasks/javac.html @@ -276,7 +276,9 @@ invoking the compiler.

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" + running Ant. Ignored if fork="no".
+ Since Ant 1.6 this attribute can also be used to specify the + path to the executable when using jikes, jvc, gcj or sj. No @@ -334,6 +336,13 @@ invoking the compiler.

be listed; defaults to no. No + + tempdir + Where Ant should place temporary files. + Since Ant 1.6. + No; default is the current working + directory. +

Parameters specified as nested elements

@@ -563,6 +572,12 @@ while all others are false.

+

Jvc Notes

+ +

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;