Browse Source

Use GPL-save command line invokation

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277572 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
6cfcccdb38
2 changed files with 12 additions and 47 deletions
  1. +6
    -27
      src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
  2. +6
    -20
      src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java

+ 6
- 27
src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java View File

@@ -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;
}

/**


+ 6
- 20
src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java View File

@@ -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 @@ public class KaffeRmic extends DefaultRmicAdapter {
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;
}

/**


Loading…
Cancel
Save