Run the compilation.
attributes.log("Using classic compiler", Project.MSG_VERBOSE);
Commandline cmd = setupJavacCommand(true);
OutputStream logstr = new LogOutputStream(attributes, Project.MSG_WARN);
try {
// Create an instance of the compiler, redirecting output to
// the project log
Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME);
Constructor cons =
c.getConstructor(new Class[] {OutputStream.class,
String.class});
Object compiler
= cons.newInstance(new Object[] {logstr, "javac"});
// Call the compile() method
Method compile = c.getMethod("compile",
new Class [] {String[].class});
Boolean ok =
(Boolean) compile.invoke(compiler,
new Object[] {cmd.getArguments()});
return ok.booleanValue();
} catch (ClassNotFoundException ex) {
throw new BuildException("Cannot use classic compiler , as it is "
+ "not available. \n"
+ " A common solution is "
+ "to set the environment variable"
+ " JAVA_HOME to your jdk directory.\n"
+ "It is currently set to \""
+ JavaEnvUtils.getJavaHome()
+ "\"",
location);
} catch (Exception ex) {
if (ex instanceof BuildException) {
throw (BuildException) ex;
} else {
throw new BuildException("Error starting classic compiler: ",
ex, location);
}
} finally {
FileUtils.close(logstr);
}