Skip to content

Commit

Permalink
chore: Add binary flag for Gradle support
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed May 15, 2018
1 parent a0121b6 commit c0c1cfa
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 42 deletions.
2 changes: 2 additions & 0 deletions java/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fish-pepper:
config:
base:
jboss:
withGradle: true
from: "jboss/base-jdk:8"
user: "jboss"
home: "/opt/jboss"
Expand All @@ -18,6 +19,7 @@ config:
jolokia: "1.5.0"
jmxexporter: "0.1.0"
rhel:
withGradle: false
from: "jboss/openjdk18-rhel7:1.1-7"
user: "jboss"
home: "/home/jboss"
Expand Down
40 changes: 21 additions & 19 deletions java/images/jboss/s2i/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,6 @@ 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
local dest=$2
Expand Down Expand Up @@ -179,6 +160,26 @@ function build_maven() {
}


# =========================================================================
# Gradle support

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 build_gradle() {
# Where artifacts are created during build
local build_dir=$1
Expand Down Expand Up @@ -225,6 +226,7 @@ function build_gradle() {
}



# =========================================================================
# Main

Expand Down
3 changes: 1 addition & 2 deletions java/images/rhel/s2i/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ function get_maven_output_dir() {
echo ${dir}
}



function copy_dir() {
local src=$1
local dest=$2
Expand Down Expand Up @@ -163,6 +161,7 @@ function build_maven() {




# =========================================================================
# Main

Expand Down
44 changes: 23 additions & 21 deletions java/templates/s2i/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,6 @@ function get_maven_output_dir() {
echo ${dir}
}

{{? fp.param.base != "rhel"}}
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
local dest=$2
Expand Down Expand Up @@ -178,7 +159,27 @@ function build_maven() {
cd ${old_dir}
}

{{? fp.param.base != "rhel"}}
{{? fp.config.base.withGradle }}
# =========================================================================
# Gradle support

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 build_gradle() {
# Where artifacts are created during build
local build_dir=$1
Expand Down Expand Up @@ -225,6 +226,7 @@ function build_gradle() {
}
{{?}}


# =========================================================================
# Main

Expand Down Expand Up @@ -254,7 +256,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}" $?
{{? fp.param.base != "rhel"}}
{{? fp.config.base.withGradle }}
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)
Expand Down

0 comments on commit c0c1cfa

Please sign in to comment.