You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2005/02/02 14:01:52 UTC
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/rmic KaffeRmic.java
bodewig 2005/02/02 05:01:52
Modified: src/main/org/apache/tools/ant/taskdefs/compilers Kjc.java
src/main/org/apache/tools/ant/taskdefs/rmic KaffeRmic.java
Log:
Use GPL-save command line invokation
Revision Changes Path
1.20 +6 -27 ant/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
Index: Kjc.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Kjc.java 21 Dec 2004 15:49:39 -0000 1.19
+++ Kjc.java 2 Feb 2005 13:01:52 -0000 1.20
@@ -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 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;
}
/**
1.24 +6 -20 ant/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java
Index: KaffeRmic.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- KaffeRmic.java 28 Jan 2005 16:11:00 -0000 1.23
+++ KaffeRmic.java 2 Feb 2005 13:01:52 -0000 1.24
@@ -17,10 +17,9 @@
package org.apache.tools.ant.taskdefs.rmic;
-import java.lang.reflect.Constructor;
-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;
/**
@@ -57,27 +56,14 @@
getRmic().getLocation());
}
+ cmd.setExecutable(c.getName());
if (c.getName().equals(RMIC_CLASSNAME)) {
cmd.createArgument().setValue("-verbose");
+ getRmic().log(Commandline.describeCommand(cmd));
}
- getRmic().log("Using: " + c.getName());
- getRmic().log(Commandline.describeCommand(cmd));
-
- try {
- Constructor cons = c.getConstructor(new Class[] {String[].class});
- Object rmic = cons.newInstance(new Object[] {cmd.getArguments()});
- Method doRmic = c.getMethod("run", (Class[]) null);
- Boolean ok = (Boolean) doRmic.invoke(rmic, (Object[]) null);
-
- return ok.booleanValue();
- } catch (BuildException ex) {
- //rethrow
- throw ex;
- } catch (Exception ex) {
- //wrap
- throw new BuildException("Error starting Kaffe rmic: ",
- ex, getRmic().getLocation());
- }
+ ExecuteJava ej = new ExecuteJava();
+ ej.setJavaCommand(cmd);
+ return ej.fork(getRmic()) == 0;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org