Skip to content

Commit

Permalink
Gradle support + configurable ARTIFACT_DIR (jorgemoralespou#2)
Browse files Browse the repository at this point in the history
* Add gradle support

* Make ARTIFACT_DIR configurable
  • Loading branch information
philhug authored and jorgemoralespou committed Sep 22, 2016
1 parent 797a3d3 commit 56e4620
Showing 1 changed file with 51 additions and 7 deletions.
58 changes: 51 additions & 7 deletions sti/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ mkdir -p $LOCAL_SOURCE_DIR
# Resulting artifact files will be deployed to /opt/openshift
DEPLOY_DIR=/opt/openshift

# the subdirectory within LOCAL_SOURCE_DIR from where we should copy build
# artifacts (*.war, *.jar)
ARTIFACT_DIR=${ARTIFACT_DIR:-target}

# Copy the source for compilation
# TODO: Remove. Why do we need to move the source???
if compgen -G "/tmp/src/*" >/dev/null; then
Expand Down Expand Up @@ -43,6 +39,10 @@ manage_incremental_build
# If a pom.xml is present, this is a normal build scenario
# so run maven.
if [ -f "$LOCAL_SOURCE_DIR/pom.xml" ]; then
# the subdirectory within LOCAL_SOURCE_DIR from where we should copy build
# artifacts (*.war, *.jar)
ARTIFACT_DIR=${ARTIFACT_DIR:-target}

pushd $LOCAL_SOURCE_DIR &> /dev/null

MAVEN_ARGS=${MAVEN_ARGS--e -Popenshift -DskipTests -Dcom.redhat.xpaas.repo.redhatga package}
Expand All @@ -66,17 +66,61 @@ if [ -f "$LOCAL_SOURCE_DIR/pom.xml" ]; then

# Copy built artifacts (if any!) from the target/ directory
# (or $ARTIFACT_DIR if specified)
# to the $JBOSS_HOME/standalone/deployments/ directory for
# later deployment
# to the $DEPLOY_DIR directory for later deployment
copy_artifacts "$ARTIFACT_DIR" war ear rar jar

# optionally clear the local maven repository after the build
clear_maven_repository

popd &> /dev/null
elif [ -f "$LOCAL_SOURCE_DIR/build.gradle" ]; then
# the subdirectory within LOCAL_SOURCE_DIR from where we should copy build
# artifacts (*.war, *.jar)
ARTIFACT_DIR=${ARTIFACT_DIR:-build/libs}

echo "Building with gradle. $LOCAL_SOURCE_DIR/build.gradle found."

pushd $LOCAL_SOURCE_DIR &> /dev/null

if [ -z "$BUILDER_ARGS" ]; then
export BUILDER_ARGS="build -x test"
# TODO: Specify setting file with -c sss
fi

echo "Found gradle.build ... attempting to build with 'gradle -s ${BUILDER_ARGS}'"

echo "Gradle version:"
gradle --version

# Execute the actual build
gradle -s $BUILDER_ARGS

ERR=$?
if [ $ERR -ne 0 ]; then
echo "Aborting due to error code $ERR from Gradle build"
exit $ERR
fi

# Copy built artifacts (if any!) from the target/ directory
# (or $ARTIFACT_DIR if specified)
# to the $DEPLOY_DIR directory for later deployment
copy_artifacts "$ARTIFACT_DIR" war ear rar jar


# clean up after maven
gradle clean
# if [ -d "$HOME/.m2/repository" ]; then
# rm -r "$HOME/.m2/repository"
# fi

popd &> /dev/null
else
# For binary builds
copy_artifacts "." war ear rar jar
# the subdirectory within LOCAL_SOURCE_DIR from where we should copy build
# artifacts (*.war, *.jar)
ARTIFACT_DIR=${ARTIFACT_DIR:-.}

copy_artifacts "$ARTIFACT_DIR" war ear rar jar
fi

# As Microservices you should only have 1 fat jar
Expand Down

0 comments on commit 56e4620

Please sign in to comment.