You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2001/11/02 16:18:47 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers DefaultCompilerAdapter.java JavacExternal.java

bodewig     01/11/02 07:18:47

  Modified:    src/main/org/apache/tools/ant/taskdefs/compilers
                        DefaultCompilerAdapter.java JavacExternal.java
  Log:
  enable <javac>'s source switch for fork mode as well.
  
  PR: 3045
  
  Revision  Changes    Path
  1.13      +16 -8     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  
  Index: DefaultCompilerAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultCompilerAdapter.java	2001/10/31 11:50:35	1.12
  +++ DefaultCompilerAdapter.java	2001/11/02 15:18:47	1.13
  @@ -282,25 +282,33 @@
       }
   
       /**
  -     * 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();
  
  
  
  1.4       +24 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java
  
  Index: JavacExternal.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JavacExternal.java	2001/10/28 21:27:51	1.3
  +++ JavacExternal.java	2001/11/02 15:18:47	1.4
  @@ -56,6 +56,7 @@
   
   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 @@
           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";
  +	}
  +    }
  +    
   }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>