FileDocCategorySizeDatePackage
JavacExternal.javaAPI DocApache Ant 1.703293Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.compilers

JavacExternal

public class JavacExternal extends DefaultCompilerAdapter
Performs a compile using javac externally.
since
Ant 1.4

Fields Summary
Constructors Summary
Methods Summary
private booleanexecOnVMS(org.apache.tools.ant.types.Commandline cmd, int firstFileName)
helper method to execute our command on VMS.

param
cmd
param
firstFileName
return

        File vmsFile = null;
        try {
            vmsFile = JavaEnvUtils.createVmsJavaOptionFile(cmd.getArguments());
            String[] commandLine = {cmd.getExecutable(),
                                    "-V",
                                    vmsFile.getPath()};
            return 0 == executeExternalCompile(commandLine,
                            firstFileName,
                            true);

        } catch (IOException e) {
            throw new BuildException("Failed to create a temporary file for \"-V\" switch");
        } finally {
            FileUtils.delete(vmsFile);
        }
    
public booleanexecute()
Performs a compile using the Javac externally.

return
true if the compilation succeeded
throws
BuildException on error

        attributes.log("Using external javac compiler", Project.MSG_VERBOSE);

        Commandline cmd = new Commandline();
        cmd.setExecutable(getJavac().getJavacExecutable());
        if (!assumeJava11() && !assumeJava12()) {
            setupModernJavacCommandlineSwitches(cmd);
        } else {
            setupJavacCommandlineSwitches(cmd, true);
        }
        int firstFileName = assumeJava11() ? -1 : cmd.size();
        logAndAddFilesToCompile(cmd);
        //On VMS platform, we need to create a special java options file
        //containing the arguments and classpath for the javac command.
        //The special file is supported by the "-V" switch on the VMS JVM.
        if (Os.isFamily("openvms")) {
            return execOnVMS(cmd, firstFileName);
        }
        return
                executeExternalCompile(cmd.getCommandline(), firstFileName,
                        true)
                == 0;