diff --git a/java/images/jboss/s2i/assemble b/java/images/jboss/s2i/assemble index 392c2f59..5f71a2c0 100644 --- a/java/images/jboss/s2i/assemble +++ b/java/images/jboss/s2i/assemble @@ -47,6 +47,7 @@ function get_maven_output_dir() { echo ${dir} } + function get_gradle_output_dir() { local dir="" @@ -64,6 +65,7 @@ function get_gradle_output_dir() { echo ${dir} } + function copy_dir() { local src=$1 local dest=$2 @@ -176,6 +178,7 @@ function build_maven() { cd ${old_dir} } + function build_gradle() { # Where artifacts are created during build local build_dir=$1 @@ -221,6 +224,7 @@ function build_gradle() { cd ${old_dir} } + # ========================================================================= # Main @@ -250,11 +254,13 @@ elif [ -f "${S2I_SOURCE_DIR}/Dockerfile" ]; then echo "Copying binaries from ${binary_dir} to ${DEPLOYMENTS_DIR} ..." copy_dir ${binary_dir} ${DEPLOYMENTS_DIR} check_error "copying ${binary_dir} to ${DEPLOYMENTS_DIR}" $? + elif ls ${S2I_SOURCE_DIR}/*.gradle* &> /dev/null; then echo "S2I source build for Gradle detected, due to presence of a *.gradle* in ${S2I_SOURCE_DIR}" build_dir=$(get_gradle_output_dir) check_error "Cannot get output dir: $build_dir" $? build_gradle ${build_dir} ${DEPLOYMENTS_DIR} + else echo "S2I source build with plain binaries detected" if [ -d "${S2I_SOURCE_DIR}/deployments" ]; then diff --git a/java/images/rhel/s2i/assemble b/java/images/rhel/s2i/assemble index 392c2f59..6cb12128 100644 --- a/java/images/rhel/s2i/assemble +++ b/java/images/rhel/s2i/assemble @@ -47,22 +47,7 @@ function get_maven_output_dir() { echo ${dir} } -function get_gradle_output_dir() { - local dir="" - # If multi module build and no ARTIFACT_DIR is set --> error - if [ x"${ARTIFACT_DIR}" = x ]; then - dir="${S2I_SOURCE_DIR}/build/libs" - else - if [ "${ARTIFACT_DIR:0:1}" = "/" ]; then - echo "ARTIFACT_DIR \"${ARTIFACT_DIR}\" must not be absolute but relative to the source directory" - exit 1 - fi - dir="${S2I_SOURCE_DIR}/${ARTIFACT_DIR}" - fi - - echo ${dir} -} function copy_dir() { local src=$1 @@ -176,50 +161,7 @@ function build_maven() { cd ${old_dir} } -function build_gradle() { - # Where artifacts are created during build - local build_dir=$1 - - # Where to put the artifacts - local app_dir=$2 - - # Default args - local gradle_args=${GRADLE_ARGS:-build -x test} - - # If there is no user provided GRADLE_OPTS, use options from run-java.sh - if [ -f ${RUN_JAVA_DIR}/run-java.sh -a -z "${GRADLE_OPTS}" ]; then - export GRADLE_OPTS=$(${RUN_JAVA_DIR}/run-java.sh options) - fi - - if [ ! -z "${GRADLE_OPTS}" ]; then - echo "Using GRADLE_OPTS '${GRADLE_OPTS}'" - fi - local old_dir=$(pwd) - cd ${S2I_SOURCE_DIR} - check_error "changing directory to ${S2I_SOURCE_DIR}" $? - - # ========= - # Run Gradle - echo "Running './gradlew ${gradle_args} ${GRADLE_ARGS_APPEND}'" - ./gradlew ${gradle_args} ${GRADLE_ARGS_APPEND} - check_error "Gradle build" $? - - # ============== - # Copy artifacts - echo "Copying Gradle artifacts from ${build_dir} to ${app_dir} ..." - copy_artifacts ${build_dir} ${app_dir} - check_error "copying artifacts from ${build_dir} to ${app_dir}" $? - - # ====================== - # Remove repo if desired - if [ "x${GRADLE_CLEAR_REPO}" != "x" ]; then - rm -rf "${S2I_ARTIFACTS_DIR}/gradle" - check_error "Cannot remove local Gradle repository ${S2I_ARTIFACTS_DIR}/gradle" $? - fi - - cd ${old_dir} -} # ========================================================================= # Main @@ -250,11 +192,7 @@ elif [ -f "${S2I_SOURCE_DIR}/Dockerfile" ]; then echo "Copying binaries from ${binary_dir} to ${DEPLOYMENTS_DIR} ..." copy_dir ${binary_dir} ${DEPLOYMENTS_DIR} check_error "copying ${binary_dir} to ${DEPLOYMENTS_DIR}" $? -elif ls ${S2I_SOURCE_DIR}/*.gradle* &> /dev/null; then - echo "S2I source build for Gradle detected, due to presence of a *.gradle* in ${S2I_SOURCE_DIR}" - build_dir=$(get_gradle_output_dir) - check_error "Cannot get output dir: $build_dir" $? - build_gradle ${build_dir} ${DEPLOYMENTS_DIR} + else echo "S2I source build with plain binaries detected" if [ -d "${S2I_SOURCE_DIR}/deployments" ]; then diff --git a/java/templates/s2i/assemble b/java/templates/s2i/assemble index 392c2f59..caf789b1 100755 --- a/java/templates/s2i/assemble +++ b/java/templates/s2i/assemble @@ -47,6 +47,7 @@ function get_maven_output_dir() { echo ${dir} } +{{? fp.param.base != "rhel"}} function get_gradle_output_dir() { local dir="" @@ -63,6 +64,7 @@ function get_gradle_output_dir() { echo ${dir} } +{{?}} function copy_dir() { local src=$1 @@ -176,6 +178,7 @@ function build_maven() { cd ${old_dir} } +{{? fp.param.base != "rhel"}} function build_gradle() { # Where artifacts are created during build local build_dir=$1 @@ -220,6 +223,7 @@ function build_gradle() { cd ${old_dir} } +{{?}} # ========================================================================= # Main @@ -250,11 +254,13 @@ elif [ -f "${S2I_SOURCE_DIR}/Dockerfile" ]; then echo "Copying binaries from ${binary_dir} to ${DEPLOYMENTS_DIR} ..." copy_dir ${binary_dir} ${DEPLOYMENTS_DIR} check_error "copying ${binary_dir} to ${DEPLOYMENTS_DIR}" $? +{{? fp.param.base != "rhel"}} elif ls ${S2I_SOURCE_DIR}/*.gradle* &> /dev/null; then echo "S2I source build for Gradle detected, due to presence of a *.gradle* in ${S2I_SOURCE_DIR}" build_dir=$(get_gradle_output_dir) check_error "Cannot get output dir: $build_dir" $? build_gradle ${build_dir} ${DEPLOYMENTS_DIR} +{{?}} else echo "S2I source build with plain binaries detected" if [ -d "${S2I_SOURCE_DIR}/deployments" ]; then