[2/2] ant-native: only use classpath tools if no JDK

Submitted by Kyle Russell on Feb. 5, 2019, 3:53 p.m. | Patch ID: 158539

Details

Message ID 20190205155325.7493-3-bkylerussell@gmail.com
State New
Delegated to: Richard Leitner
Headers show

Commit Message

Kyle Russell Feb. 5, 2019, 3:53 p.m.
If ant gets invoked with a $JAVA_HOME that points to a JDK (for example,
from an 'inherit java-native'), use the tools.jar from the JDK instead
of the classpath-initial tools.

Once a native JDK has been bootstrapped, other Java recipes should be
able to use a more featureful set of classes if needed.

Signed-off-by: Kyle Russell <bkylerussell@gmail.com>
---
 recipes-core/ant/ant-native_1.8.1.bb | 2 +-
 recipes-core/ant/files/ant           | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/recipes-core/ant/ant-native_1.8.1.bb b/recipes-core/ant/ant-native_1.8.1.bb
index 7839abd..67cb5fc 100644
--- a/recipes-core/ant/ant-native_1.8.1.bb
+++ b/recipes-core/ant/ant-native_1.8.1.bb
@@ -53,7 +53,7 @@  do_compile() {
   fastjar cf ${JARFILENAME} -C build .
 
   oe_makeclasspath cp -s ecj-bootstrap jsch bsf xalan2 xercesImpl resolver gnumail gnujaf bcel regexp log4j1.2 antlr oro junit jdepend commons-net commons-logging
-  cp=${STAGING_DATADIR_JAVA_NATIVE}/ant.jar:${STAGING_DATADIR}/classpath/tools.zip:$cp
+  sed -i -e"s|@ANT_JAR@|${STAGING_DATADIR_JAVA_NATIVE}/ant.jar|" ${WORKDIR}/ant
   sed -i -e"s|@JAR_FILE@|$cp|" ${WORKDIR}/ant
 }
 
diff --git a/recipes-core/ant/files/ant b/recipes-core/ant/files/ant
index bb282a9..939f3ec 100755
--- a/recipes-core/ant/files/ant
+++ b/recipes-core/ant/files/ant
@@ -1,6 +1,15 @@ 
 #!/bin/sh
 
 export CLASSPATH
+
+CLASSPATH=$CLASSPATH:@ANT_JAR@
+
+if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
+        CLASSPATH="$CLASSPATH:$JAVA_HOME/lib/tools.jar"
+else
+        CLASSPATH="$CLASSPATH:${STAGING_DATADIR}/classpath/tools.zip"
+fi
+
 CLASSPATH=$CLASSPATH:@JAR_FILE@
 
 if [ ! $JAVA ];then