Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle support + configurable ARTIFACT_DIR #2

Merged
merged 2 commits into from
Sep 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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