Browse Source

enable <javac>'s source switch for fork mode as well.

PR: 3045


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269858 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
f19ae9c773
2 changed files with 40 additions and 10 deletions
  1. +16
    -8
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  2. +24
    -2
      src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java

+ 16
- 8
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -282,25 +282,33 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
}

/**
* Does the command line argument processing common to classic and
* modern and adds the files to compile as well.
* Does the command line argument processing for modern. Doesn't
* add the files to compile.
*/
protected Commandline setupModernJavacCommand() {
Commandline cmd = new Commandline();
protected Commandline setupModernJavacCommandlineSwitches(Commandline cmd) {
setupJavacCommandlineSwitches(cmd);

if (attributes.getSource() != null) {
cmd.createArgument().setValue("-source");
cmd.createArgument().setValue(attributes.getSource());
}
return cmd;
}

/**
* Does the command line argument processing for modern and adds
* the files to compile as well.
*/
protected Commandline setupModernJavacCommand() {
Commandline cmd = new Commandline();
setupModernJavacCommandlineSwitches(cmd);

logAndAddFilesToCompile(cmd);
return cmd;
}

/**
* Does the command line argument processing common to classic and
* modern and adds the files to compile as well.
* Does the command line argument processing for classic and adds
* the files to compile as well.
*/
protected Commandline setupJavacCommand() {
Commandline cmd = new Commandline();


+ 24
- 2
src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java View File

@@ -56,6 +56,7 @@ package org.apache.tools.ant.taskdefs.compilers;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.types.Commandline;

/**
@@ -72,12 +73,33 @@ public class JavacExternal extends DefaultCompilerAdapter {
attributes.log("Using external javac compiler", Project.MSG_VERBOSE);

Commandline cmd = new Commandline();
cmd.setExecutable("javac");
setupJavacCommandlineSwitches(cmd);
cmd.setExecutable(getJavacExecutableName());
setupModernJavacCommandlineSwitches(cmd);
int firstFileName = cmd.size();
logAndAddFilesToCompile(cmd);

return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
}

private String getJavacExecutableName() {
// This is the most common extension case - exe for windows and OS/2,
// nothing for *nix.
String extension = Os.isFamily("dos") ? ".exe" : "";

// Look for java in the java.home/../bin directory. Unfortunately
// on Windows java.home doesn't always refer to the correct location,
// so we need to fall back to assuming java is somewhere on the
// PATH.
java.io.File jExecutable =
new java.io.File(System.getProperty("java.home") +
"/../bin/javac" + extension );

if (jExecutable.exists() && !Os.isFamily("netware")) {
return jExecutable.getAbsolutePath();
} else {
return "javac";
}
}
}


Loading…
Cancel
Save