2323# ----------------------------------------------------------------------------
2424AEM_JAVA_ENABLED=${AEM_JAVA_ENABLED:- true}
2525if [ " ${AEM_JAVA_ENABLED} " = true ]; then
26- AEM_JAVA_HOME=" $( sh aemw vendor list -V javaHome 2> /dev/null || true) "
27-
28- if [ -z " $AEM_JAVA_HOME " ] || [ ! -d " $AEM_JAVA_HOME " ] || [ ! -x " $AEM_JAVA_HOME /bin/java" ]; then
26+ SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
27+ is_java_valid () {
28+ [ -n " $1 " ] && [ -d " $1 " ] && [ -x " $1 /bin/java" ]
29+ }
30+ get_java_home () {
31+ (cd " ${SCRIPT_DIR} " && sh aemw vendor list -V javaHome 2> /dev/null) || true
32+ }
33+ prepare_java () {
34+ (cd " ${SCRIPT_DIR} " && sh aemw vendor prepare)
35+ }
36+ show_prep_error () {
37+ if [ -n " $1 " ]; then
38+ echo " AEM Compose - Vendor tools cannot be prepared (exit $1 ). Cannot continue!"
39+ else
40+ echo " AEM Compose - Vendor tools cannot be prepared. Cannot continue!"
41+ fi
42+ echo " Run command 'sh aemw vendor prepare' from the main project directory and inspect the error."
43+ }
44+ AEM_JAVA_HOME=" $( get_java_home) "
45+ if ! is_java_valid " $AEM_JAVA_HOME " ; then
2946 echo " AEM Compose - Vendor tools not prepared (Java). Preparing now..."
30- if ! sh aemw vendor prepare ; then
47+ if ! prepare_java ; then
3148 rc=$?
32- echo " AEM Compose - Vendor tools cannot be prepared (exit $rc ). Cannot continue!"
33- echo " Run command 'sh aemw vendor prepare' and inspect the error."
49+ show_prep_error $rc
3450 exit $rc
3551 fi
36-
37- AEM_JAVA_HOME=" $( sh aemw vendor list -V javaHome 2> /dev/null || true) "
38- if [ -z " $AEM_JAVA_HOME " ] || [ ! -d " $AEM_JAVA_HOME " ] || [ ! -x " $AEM_JAVA_HOME /bin/java" ]; then
39- echo " AEM Compose - Vendor tools cannot be prepared. Cannot continue!"
40- echo " Run command 'sh aemw vendor prepare' and inspect the error."
52+ AEM_JAVA_HOME=" $( get_java_home) "
53+ if ! is_java_valid " $AEM_JAVA_HOME " ; then
54+ show_prep_error
4155 exit 1
4256 fi
43-
4457 echo " AEM Compose - Vendor tools prepared. Java available at '${AEM_JAVA_HOME} '"
4558 fi
4659
@@ -336,4 +349,4 @@ exec "$JAVACMD" \
336349 $MAVEN_DEBUG_OPTS \
337350 -classpath " $MAVEN_PROJECTBASEDIR /.mvn/wrapper/maven-wrapper.jar" \
338351 " -Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR} " \
339- ${WRAPPER_LAUNCHER} $MAVEN_CONFIG " $@ "
352+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG " $@ "
0 commit comments