[fedora-java] Ant launcher script

Andrew Hughes ahughes at redhat.com
Tue Mar 20 11:05:15 UTC 2012


Hi,

We've had IcedTea8 failing for some time on our Fedora build machine:

JAVA_HOME=/notnfs/nighttester/icedtea8-target-testing/bootstrap/jdk1.6.0 ANT_OPTS=-Djava.io.tmpdir='/notnfs/nighttester/icedtea8-target-testing/openjdk.build/langtools/build/ant-tmp' /usr/bin/ant -diagnostics > /notnfs/nighttester/icedtea8-target-testing/openjdk.build/langtools/build/ant-diagnostics.log ; \
  JAVA_HOME=/notnfs/nighttester/icedtea8-target-testing/bootstrap/jdk1.6.0 ANT_OPTS=-Djava.io.tmpdir='/notnfs/nighttester/icedtea8-target-testing/openjdk.build/langtools/build/ant-tmp' /usr/bin/ant -version >> /notnfs/nighttester/icedtea8-target-testing/openjdk.build/langtools/build/ant-diagnostics.log
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
make[3]: *** [/notnfs/nighttester/icedtea8-target-testing/openjdk.build/langtools/build/ant-diagnostics.log] Error 1


while it succeeds fine for me locally.  I've finally managed to have a quick look at
why this is, motivated by the fact that the 6 builds also broke when we upgraded to F16
(though for a different reason).

It seems the Ant script calls /usr/bin/build-classpath by default which in turn runs
/usr/share/java-utils/java-functions.  It is set_jvm_dirs in this which fails as it
can't find /usr/share/java-1.8.0:

$ JAVA_HOME=/notnfs/nighttester/icedtea8-target-testing/bootstrap/jdk1.6.0 ANT_OPTS=-Djava.io.tmpdir='/notnfs/nighttester/icedtea8-target-testing/openjdk.build/langtools/build/ant-tmp' /usr/bin/ant --execdebug -diagnostics
exec "/notnfs/nighttester/icedtea8-target-testing/bootstrap/jdk1.6.0/bin/java" -Djava.io.tmpdir=/notnfs/nighttester/icedtea8-target-testing/openjdk.build/langtools/build/ant-tmp -classpath "/usr/bin/build-classpath: error: JAVAVER_LIBDIR /usr/share/java-1.8.0 does not exist or is not a directory:/notnfs/nighttester/icedtea8-target-testing/bootstrap/jdk1.6.0/lib/tools.jar" -Dant.home="/usr/share/ant" -Dant.library.dir="/usr/share/ant/lib" org.apache.tools.ant.launch.Launcher -cp "" "-diagnostics"
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher

Obviously this doesn't yet exist as there is no system 1.8 install.  I don't see
why this is worth causing an error and dropping out of the script.  Indeed, if
the following lines are commented out:

#    elif [ ! -d "$JAVAVER_LIBDIR" ]; then                                                                                      
#        echo "$0: error: JAVAVER_LIBDIR $JAVAVER_LIBDIR does not exist or is not a directory"                                  
#        return 1                                                                                                               
#    elif [ ! -d "$JAVAVER_JNIDIR" ]; then                                                                                      
#        echo "$0: error: JAVAVER_JNIDIR $JAVAVER_JNIDIR does not exist or is not a directory"                                  
#        return 1                                                                                                               

the script works fine and produces the same classpath as for 1.6 or 1.7:

JAVA_HOME=/notnfs/nighttester/icedtea8-target-testing/bootstrap/jdk1.6.0 build-classpath ant ant-launcher jaxp_parser_impl xml-commons-apis
/usr/share/java/ant.jar:/usr/share/java/ant-launcher.jar:/usr/share/java/jaxp_parser_impl.jar:/usr/share/java/xml-commons-apis.jar

So /usr/share/java-${ver} isn't used anyway.  java-1.5.0, java-1.6.0 and java-1.7.0 all exist
but are empty.

Given the script will allow the user to set JAVA_HOME, and this can be to a version < 1.5 or > 1.7,
I see no reason why it shouldn't just silently ignore the path if it doesn't exist, rather than
erroring out.

It's possible to workaround this by passing --noconfig to /usr/bin/ant and setting ANT_HOME, but
I don't know what effect this will have on the numerous other ant scripts on other distributions,
not to mention how we work out what to set ANT_HOME to in the first place.  Fixing this script
on the problem distro (Fedora) seems like a much simpler solution.

Would this be possible?
-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

PGP Key: 248BDC07 (https://keys.indymedia.org/)
Fingerprint = EC5A 1F5E C0AD 1D15 8F1F  8F91 3B96 A578 248B DC07



More information about the java-devel mailing list