Blob Blame Raw
From 24a1fb2f2f38bb8fdb883e91f34b3f2ca26765a7 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Thu, 30 Oct 2014 15:20:20 +0100
Subject: [PATCH 2/6] Use wrapper script to inject extra JVM arguments

---
 install                   |  1 +
 java-utils/java-functions | 14 ++++++++++++--
 java-utils/java-wrapper   |  8 ++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 java-utils/java-wrapper

diff --git a/install b/install
index 16216a7..023136b 100755
--- a/install
+++ b/install
@@ -122,6 +122,7 @@ inst_config etc/font.properties "${javaconfdir}"
 inst_config target/java.conf "${javaconfdir}"
 
 inst_data target/java-functions "${javadir}-utils"
+inst_exec java-utils/java-wrapper "${javadir}-utils"
 inst_data java-utils/maven_depmap.py "${javadir}-utils"
 inst_data java-utils/pom_editor.py "${javadir}-utils"
 
diff --git a/java-utils/java-functions b/java-utils/java-functions
index fcadb1c..c57640f 100644
--- a/java-utils/java-functions
+++ b/java-utils/java-functions
@@ -228,7 +228,12 @@ set_javacmd()
 	JAVACMD="${JAVA_HOME}/${cmd}"
 	if [ -x "${JAVACMD}" ]; then
 	    _log "Using configured JAVACMD: $JAVACMD"
-	    JAVACMD="${JAVACMD}${JAVACMD_OPTS:+ }${JAVACMD_OPTS}"
+	    if [ -n "${JAVACMD_OPTS}" ]; then
+		_log "Using java-wrapper with extra options: ${JAVACMD_OPTS}"
+		export _JP_JAVACMD="${JAVACMD}"
+		export _JP_JAVACMD_OPTS="${JAVACMD_OPTS}"
+		JAVACMD="%{javadir}-utils/java-wrapper"
+	    fi
 	    return 0
 	fi
     done
@@ -236,7 +241,12 @@ set_javacmd()
     JAVACMD=$(which java 2>/dev/null || :)
     if [ -x "${JAVACMD}" ]; then
 	_log "Using JAVACMD from PATH: $JAVACMD"
-	JAVACMD="${JAVACMD}${JAVACMD_OPTS:+ }${JAVACMD_OPTS}"
+	if [ -n "${JAVACMD_OPTS}" ]; then
+	    _log "Using java-wrapper with extra options: ${JAVACMD_OPTS}"
+	    export _JP_JAVACMD="${JAVACMD}"
+	    export _JP_JAVACMD_OPTS="${JAVACMD_OPTS}"
+	    JAVACMD="%{javadir}-utils/java-wrapper"
+	fi
 	return 0
     fi
 
diff --git a/java-utils/java-wrapper b/java-utils/java-wrapper
new file mode 100644
index 0000000..29b3143
--- /dev/null
+++ b/java-utils/java-wrapper
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+JAVACMD="${_JP_JAVACMD}"
+JAVACMD_OPTS="${_JP_JAVACMD_OPTS}"
+unset _JP_JAVACMD
+unset _JP_JAVACMD_OPTS
+
+exec "${JAVACMD}" ${JAVACMD_OPTS} "${@}"
-- 
1.9.3