|
|
@@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
* Copyright 2001-2004 The Apache Software Foundation |
|
|
|
* Copyright 2001-2005 The Apache Software Foundation |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@@ -17,9 +17,9 @@ |
|
|
|
|
|
|
|
package org.apache.tools.ant.taskdefs.compilers; |
|
|
|
|
|
|
|
import java.lang.reflect.Method; |
|
|
|
import org.apache.tools.ant.BuildException; |
|
|
|
import org.apache.tools.ant.Project; |
|
|
|
import org.apache.tools.ant.taskdefs.ExecuteJava; |
|
|
|
import org.apache.tools.ant.types.Commandline; |
|
|
|
import org.apache.tools.ant.types.Path; |
|
|
|
|
|
|
@@ -40,31 +40,10 @@ public class Kjc extends DefaultCompilerAdapter { |
|
|
|
public boolean execute() throws BuildException { |
|
|
|
attributes.log("Using kjc compiler", Project.MSG_VERBOSE); |
|
|
|
Commandline cmd = setupKjcCommand(); |
|
|
|
|
|
|
|
try { |
|
|
|
Class c = Class.forName("at.dms.kjc.Main"); |
|
|
|
|
|
|
|
// Call the compile() method |
|
|
|
Method compile = c.getMethod("compile", |
|
|
|
new Class [] {String [].class}); |
|
|
|
Boolean ok = |
|
|
|
(Boolean) compile.invoke(null, |
|
|
|
new Object[] {cmd.getArguments()}); |
|
|
|
return ok.booleanValue(); |
|
|
|
} catch (ClassNotFoundException ex) { |
|
|
|
throw new BuildException("Cannot use kjc compiler, as it is not " |
|
|
|
+ "available. A common solution is to " |
|
|
|
+ "set the environment variable CLASSPATH " |
|
|
|
+ "to your kjc archive (kjc.jar).", |
|
|
|
location); |
|
|
|
} catch (Exception ex) { |
|
|
|
if (ex instanceof BuildException) { |
|
|
|
throw (BuildException) ex; |
|
|
|
} else { |
|
|
|
throw new BuildException("Error starting kjc compiler: ", |
|
|
|
ex, location); |
|
|
|
} |
|
|
|
} |
|
|
|
cmd.setExecutable("at.dms.kjc.Main"); |
|
|
|
ExecuteJava ej = new ExecuteJava(); |
|
|
|
ej.setJavaCommand(cmd); |
|
|
|
return ej.fork(getJavac()) == 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|