/** * Performs a compile using the Javac externally. * @return true if the compilation succeeded * @throws BuildException on error */ @Override public boolean execute() throws BuildException { 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; }
/** * helper method to execute our command on VMS. * @param cmd Commandline * @param firstFileName int * @return boolean */ private boolean execOnVMS(Commandline cmd, int firstFileName) { 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); } }
return new JavacExternal();