From 81ceab98f05f1d247441c65808f2771d6153f195 Mon Sep 17 00:00:00 2001 From: Grant Shipley Date: Thu, 25 Feb 2016 11:38:01 -0500 Subject: [PATCH] Sample Project --- .sti/scripts/assemble.ignore | 87 ++++++++++++++++++++++++++++++++++++ .sti/scripts/run.ignore | 3 ++ README.md | 4 ++ pom.xml | 50 +++++++++++++++++++++ src/main/java/.gitkeep | 0 src/main/resources/.gitkeep | 0 src/main/webapp/index.html | 11 +++++ 7 files changed, 155 insertions(+) create mode 100755 .sti/scripts/assemble.ignore create mode 100755 .sti/scripts/run.ignore create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/.gitkeep create mode 100644 src/main/resources/.gitkeep create mode 100644 src/main/webapp/index.html diff --git a/.sti/scripts/assemble.ignore b/.sti/scripts/assemble.ignore new file mode 100755 index 0000000..09e3d5f --- /dev/null +++ b/.sti/scripts/assemble.ignore @@ -0,0 +1,87 @@ +#!/bin/bash + +# restore maven dependencies downloaded in a previous build, +# so they do not have to be downloaded again. +# /tmp/artifacts will only be present in the incremental build scenario +# in which the target image name is an existing docker image which contains +# dependencies from a prior build execution. +function restore_saved_artifacts() { + if [ -f /tmp/artifacts/maven.tar.gz ]; then + pushd / &> /dev/null + echo -n "Restoring saved artifacts from prior build..." + tar zxf /tmp/artifacts/maven.tar.gz + echo "...done" + popd &> /dev/null + fi +} + +# Source code provided to STI will be bind-mounted at /tmp/src +# and then copied into /opt/wildfly/source for building. +local_source_dir=/opt/wildfly/source +mkdir -p $local_source_dir + +# Resulting WAR files will be deployed to /wildfly/standalone/deployments +deploy_dir=/wildfly/standalone/deployments +mkdir -p $deploy_dir + +# Copy the source from the bind mount in preparation for compilation +cp -ad /tmp/src/* $local_source_dir + +# If a pom.xml is present, this is a normal build scenario +# so run maven. +if [ -f "$local_source_dir/pom.xml" ]; then + # restore any maven dependencies which will be present if this is an + # incremental build + restore_saved_artifacts + + pushd $local_source_dir &> /dev/null + JAVA_HOME=/etc/alternatives/java_sdk_1.7.0 + mvn clean package -Popenshift -DskipTests + err=$? + if [ $err -ne 0 ]; then + echo "Aborting due to error code $err from mvn package" + exit $err + fi + + echo "Copying built war files into $deploy_dir for later deployment..." + if [ -d $local_source_dir/target ]; then + cp $local_source_dir/target/*.war $deploy_dir >& /dev/null + fi + if [ -d $local_source_dir/deployments ]; then + cp $local_source_dir/deployments/*.war $deploy_dir >& /dev/null + fi + + if [ -d $local_source_dir/cfg ]; then + echo "Copying config files from project..." + cp cfg/* /wildfly/standalone/configuration + fi + + if [ -d $local_source_dir/modules ]; then + echo "Copying modules from project..." + mkdir /wildfly/provided_modules + cp -r modules/* /wildfly/provided_modules + fi + + echo "...done" + + popd &> /dev/null +else + echo "Copying binaries in source directory into $deploy_dir for later deployment..." + if [ -d $local_source_dir/target ]; then + cp $local_source_dir/target/*.war $deploy_dir >& /dev/null + fi + if [ -d $local_source_dir/deployments ]; then + cp $local_source_dir/deployments/*.war $deploy_dir >& /dev/null + fi + if [ -d $local_source_dir/cfg ]; then + echo "Copying config files from project..." + cp cfg/* /wildfly/standalone/configuration + fi + + if [ -d $local_source_dir/modules ]; then + echo "Copying modules from project..." + mkdir /wildfly/provided_modules + cp -r modules/* /wildfly/provided_modules + fi + echo "...done" +fi diff --git a/.sti/scripts/run.ignore b/.sti/scripts/run.ignore new file mode 100755 index 0000000..ddc9e81 --- /dev/null +++ b/.sti/scripts/run.ignore @@ -0,0 +1,3 @@ +#!/bin/bash +echo hello world +exec /wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 diff --git a/README.md b/README.md new file mode 100644 index 0000000..cca2e50 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Getting Started with Java on OpenShift Sample Application +==================== + +This is a sample application for the book, Getting Started with Java on OpenShift diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..edc8646 --- /dev/null +++ b/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + SampleApp + SampleApp + war + 1.0 + SampleApp + + + UTF-8 + 1.7 + 1.7 + + + + + javax + javaee-api + 7.0 + provided + + + + + + + + + + openshift + + SampleApp + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + target + ROOT + + + + + + + diff --git a/src/main/java/.gitkeep b/src/main/java/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/.gitkeep b/src/main/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html new file mode 100644 index 0000000..c9ee556 --- /dev/null +++ b/src/main/webapp/index.html @@ -0,0 +1,11 @@ + + + + + + Welcome to OpenShift + + +

Welcome to Getting Started with Java on OpenShift!

+ +