executable for jikes, jvc, sj or gcj. PR: 13814 <javac> 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 <joe at kafsemo dot org> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274584 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -331,6 +331,16 @@ Other changes: | |||||
| * <javadoc> now supports the -noqualifier switch. Bugzilla Report 19288. | * <javadoc> now supports the -noqualifier switch. Bugzilla Report 19288. | ||||
| * <javac>'s executable attribute can now also be used to specify the | |||||
| executable for jikes, jvc, sj or gcj. Bugzilla Report 13814. | |||||
| * <javac> 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 | Changes from Ant 1.5.2 to Ant 1.5.3 | ||||
| =================================== | =================================== | ||||
| @@ -276,7 +276,9 @@ invoking the compiler.</p> | |||||
| <td valign="top">Complete path to the <code>javac</code> | <td valign="top">Complete path to the <code>javac</code> | ||||
| executable to use in case of <code>fork="yes"</code>. | executable to use in case of <code>fork="yes"</code>. | ||||
| Defaults to the compiler of the Java version that is currently | Defaults to the compiler of the Java version that is currently | ||||
| running Ant. Ignored if <code>fork="no"</code></td> | |||||
| running Ant. Ignored if <code>fork="no"</code>.<br> | |||||
| Since Ant 1.6 this attribute can also be used to specify the | |||||
| path to the executable when using jikes, jvc, gcj or sj.</td> | |||||
| <td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| @@ -334,6 +336,13 @@ invoking the compiler.</p> | |||||
| be listed; defaults to <code>no</code>.</td> | be listed; defaults to <code>no</code>.</td> | ||||
| <td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td valign="top">tempdir</td> | |||||
| <td valign="top">Where Ant should place temporary files. | |||||
| <em>Since Ant 1.6</em>.</td> | |||||
| <td align="center" valign="top">No; default is the current working | |||||
| directory.</td> | |||||
| </tr> | |||||
| </table> | </table> | ||||
| <h3>Parameters specified as nested elements</h3> | <h3>Parameters specified as nested elements</h3> | ||||
| @@ -563,6 +572,12 @@ while all others are <code>false</code>.</p> | |||||
| </tr> | </tr> | ||||
| </table> | </table> | ||||
| <h3>Jvc Notes</h3> | |||||
| <p>Jvc will enable Microsoft extensions unless you set the property | |||||
| <code>build.compiler.jvc.extensions</code> to false before invoking | |||||
| <code><javac></code>.</p> | |||||
| <hr> | <hr> | ||||
| <p align="center">Copyright © 2000-2003 Apache Software Foundation. | <p align="center">Copyright © 2000-2003 Apache Software Foundation. | ||||
| All rights Reserved.</p> | All rights Reserved.</p> | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * 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. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * 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 source; | ||||
| private String debugLevel; | private String debugLevel; | ||||
| private File tmpDir; | |||||
| /** | /** | ||||
| * Javac task for compilation of Java files. | * Javac task for compilation of Java files. | ||||
| @@ -595,6 +596,15 @@ public class Javac extends MatchingTask { | |||||
| forkedExecutable = forkExec; | 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? | * 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. | * The name of the javac executable to use in fork-mode. | ||||
| * | |||||
| * <p>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.</p> | |||||
| * | |||||
| * <p>You should <strong>not</strong> invoke this method if you | |||||
| * want to get the value of the executable command - use {@link | |||||
| * #getExecutable getExecutable} for this.</p> | |||||
| */ | */ | ||||
| public String getJavacExecutable() { | public String getJavacExecutable() { | ||||
| if (forkedExecutable == null && isForkedJavac()) { | 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. | * Executes the task. | ||||
| @@ -152,6 +152,13 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| return attributes; | return attributes; | ||||
| } | } | ||||
| /** | |||||
| * @since Ant 1.6 | |||||
| */ | |||||
| protected Project getProject() { | |||||
| return project; | |||||
| } | |||||
| /** | /** | ||||
| * Builds the compilation classpath. | * Builds the compilation classpath. | ||||
| * | * | ||||
| @@ -432,8 +439,11 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| && firstFileName >= 0) { | && firstFileName >= 0) { | ||||
| PrintWriter out = null; | PrintWriter out = null; | ||||
| try { | 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); | tmpFile = fileUtils.createTempFile("files", "", userDir); | ||||
| out = new PrintWriter(new FileWriter(tmpFile)); | out = new PrintWriter(new FileWriter(tmpFile)); | ||||
| for (int i = firstFileName; i < args.length; i++) { | for (int i = firstFileName; i < args.length; i++) { | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * 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. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -112,7 +112,8 @@ public class Gcj extends DefaultCompilerAdapter { | |||||
| classpath.append(src); | classpath.append(src); | ||||
| } | } | ||||
| cmd.setExecutable("gcj"); | |||||
| String exec = getJavac().getExecutable(); | |||||
| cmd.setExecutable(exec == null ? "gcj" : exec); | |||||
| if (destDir != null) { | if (destDir != null) { | ||||
| cmd.createArgument().setValue("-d"); | cmd.createArgument().setValue("-d"); | ||||
| @@ -124,7 +124,8 @@ public class Jikes extends DefaultCompilerAdapter { | |||||
| } | } | ||||
| Commandline cmd = new Commandline(); | Commandline cmd = new Commandline(); | ||||
| cmd.setExecutable("jikes"); | |||||
| String exec = getJavac().getExecutable(); | |||||
| cmd.setExecutable(exec == null ? "jikes" : exec); | |||||
| if (deprecation == true) { | if (deprecation == true) { | ||||
| cmd.createArgument().setValue("-deprecation"); | cmd.createArgument().setValue("-deprecation"); | ||||
| @@ -104,7 +104,8 @@ public class Jvc extends DefaultCompilerAdapter { | |||||
| } | } | ||||
| Commandline cmd = new Commandline(); | Commandline cmd = new Commandline(); | ||||
| cmd.setExecutable("jvc"); | |||||
| String exec = getJavac().getExecutable(); | |||||
| cmd.setExecutable(exec == null ? "jvc" : exec); | |||||
| if (destDir != null) { | if (destDir != null) { | ||||
| cmd.createArgument().setValue("/d"); | cmd.createArgument().setValue("/d"); | ||||
| @@ -115,10 +116,19 @@ public class Jvc extends DefaultCompilerAdapter { | |||||
| cmd.createArgument().setValue("/cp:p"); | cmd.createArgument().setValue("/cp:p"); | ||||
| cmd.createArgument().setPath(classpath); | 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 | // Do not display Logo | ||||
| cmd.createArgument().setValue("/nologo"); | cmd.createArgument().setValue("/nologo"); | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * 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. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * 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); | attributes.log("Using symantec java compiler", Project.MSG_VERBOSE); | ||||
| Commandline cmd = setupJavacCommand(); | Commandline cmd = setupJavacCommand(); | ||||
| cmd.setExecutable("sj"); | |||||
| String exec = getJavac().getExecutable(); | |||||
| cmd.setExecutable(exec == null ? "sj" : exec); | |||||
| int firstFileName = cmd.size() - compileList.length; | int firstFileName = cmd.size() - compileList.length; | ||||