bodewig 2005/03/10 00:31:54 Modified: src/main/org/apache/tools/ant/taskdefs/optional/native2ascii KaffeNative2Ascii.java Log: Kaffe keeps moving things, adapt Revision Changes Path 1.2 +31 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java Index: KaffeNative2Ascii.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- KaffeNative2Ascii.java 31 Jan 2005 11:48:25 -0000 1.1 +++ KaffeNative2Ascii.java 10 Mar 2005 08:31:54 -0000 1.2 @@ -29,6 +29,13 @@ */ public final class KaffeNative2Ascii extends DefaultNative2Ascii { + // sorted by newest Kaffe version first + private static final String[] N2A_CLASSNAMES = new String[] { + "gnu.classpath.tools.native2ascii.Native2Ascii", + // pre Kaffe 1.1.5 + "kaffe.tools.native2ascii.Native2Ascii", + }; + /** * Identifies this adapter. */ @@ -45,10 +52,33 @@ protected boolean run(Commandline cmd, ProjectComponent log) throws BuildException { ExecuteJava ej = new ExecuteJava(); - cmd.setExecutable("kaffe.tools.native2ascii.Native2Ascii"); + Class c = getN2aClass(); + if (c == null) { + throw new BuildException("Couldn't load Kaffe's Native2Ascii" + + " class"); + } + + cmd.setExecutable(c.getName()); ej.setJavaCommand(cmd); ej.execute(log.getProject()); // otherwise ExecuteJava has thrown an exception return true; } + + /** + * tries to load Kaffe Native2Ascii and falls back to the older + * class name if necessary. + * + * @return null if neither class can get loaded. + */ + private static Class getN2aClass() { + for (int i = 0; i < N2A_CLASSNAMES.length; i++) { + try { + return Class.forName(N2A_CLASSNAMES[i]); + } catch (ClassNotFoundException cnfe) { + } + } + return null; + } + } \ No newline at end of file
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]