1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package org.apache.tools.ant.taskdefs.compilers;
  18. import org.apache.tools.ant.BuildException;
  19. import org.apache.tools.ant.Project;
  20. import org.apache.tools.ant.types.Commandline;
  21. /**
  22. * Performs a compile using javac externally.
  23. *
  24. * @since Ant 1.4
  25. */
  26. public class JavacExternal extends DefaultCompilerAdapter {
  27. /**
  28. * Performs a compile using the Javac externally.
  29. */
  30. public boolean execute() throws BuildException {
  31. attributes.log("Using external javac compiler", Project.MSG_VERBOSE);
  32. Commandline cmd = new Commandline();
  33. cmd.setExecutable(getJavac().getJavacExecutable());
  34. setupModernJavacCommandlineSwitches(cmd);
  35. int firstFileName = assumeJava11() ? -1 : cmd.size();
  36. logAndAddFilesToCompile(cmd);
  37. return
  38. executeExternalCompile(cmd.getCommandline(), firstFileName,
  39. true)
  40. == 0;
  41. }
  42. }