Skip to content

Commit 81ceab9

Browse files
committed
Sample Project
0 parents  commit 81ceab9

File tree

7 files changed

+155
-0
lines changed

7 files changed

+155
-0
lines changed

.sti/scripts/assemble.ignore

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# restore maven dependencies downloaded in a previous build,
4+
# so they do not have to be downloaded again.
5+
# /tmp/artifacts will only be present in the incremental build scenario
6+
# in which the target image name is an existing docker image which contains
7+
# dependencies from a prior build execution.
8+
function restore_saved_artifacts() {
9+
if [ -f /tmp/artifacts/maven.tar.gz ]; then
10+
pushd / &> /dev/null
11+
echo -n "Restoring saved artifacts from prior build..."
12+
tar zxf /tmp/artifacts/maven.tar.gz
13+
echo "...done"
14+
popd &> /dev/null
15+
fi
16+
}
17+
18+
# Source code provided to STI will be bind-mounted at /tmp/src
19+
# and then copied into /opt/wildfly/source for building.
20+
local_source_dir=/opt/wildfly/source
21+
mkdir -p $local_source_dir
22+
23+
# Resulting WAR files will be deployed to /wildfly/standalone/deployments
24+
deploy_dir=/wildfly/standalone/deployments
25+
mkdir -p $deploy_dir
26+
27+
# Copy the source from the bind mount in preparation for compilation
28+
cp -ad /tmp/src/* $local_source_dir
29+
30+
# If a pom.xml is present, this is a normal build scenario
31+
# so run maven.
32+
if [ -f "$local_source_dir/pom.xml" ]; then
33+
# restore any maven dependencies which will be present if this is an
34+
# incremental build
35+
restore_saved_artifacts
36+
37+
pushd $local_source_dir &> /dev/null
38+
JAVA_HOME=/etc/alternatives/java_sdk_1.7.0
39+
mvn clean package -Popenshift -DskipTests
40+
err=$?
41+
if [ $err -ne 0 ]; then
42+
echo "Aborting due to error code $err from mvn package"
43+
exit $err
44+
fi
45+
46+
echo "Copying built war files into $deploy_dir for later deployment..."
47+
if [ -d $local_source_dir/target ]; then
48+
cp $local_source_dir/target/*.war $deploy_dir >& /dev/null
49+
fi
50+
if [ -d $local_source_dir/deployments ]; then
51+
cp $local_source_dir/deployments/*.war $deploy_dir >& /dev/null
52+
fi
53+
54+
if [ -d $local_source_dir/cfg ]; then
55+
echo "Copying config files from project..."
56+
cp cfg/* /wildfly/standalone/configuration
57+
fi
58+
59+
if [ -d $local_source_dir/modules ]; then
60+
echo "Copying modules from project..."
61+
mkdir /wildfly/provided_modules
62+
cp -r modules/* /wildfly/provided_modules
63+
fi
64+
65+
echo "...done"
66+
67+
popd &> /dev/null
68+
else
69+
echo "Copying binaries in source directory into $deploy_dir for later deployment..."
70+
if [ -d $local_source_dir/target ]; then
71+
cp $local_source_dir/target/*.war $deploy_dir >& /dev/null
72+
fi
73+
if [ -d $local_source_dir/deployments ]; then
74+
cp $local_source_dir/deployments/*.war $deploy_dir >& /dev/null
75+
fi
76+
if [ -d $local_source_dir/cfg ]; then
77+
echo "Copying config files from project..."
78+
cp cfg/* /wildfly/standalone/configuration
79+
fi
80+
81+
if [ -d $local_source_dir/modules ]; then
82+
echo "Copying modules from project..."
83+
mkdir /wildfly/provided_modules
84+
cp -r modules/* /wildfly/provided_modules
85+
fi
86+
echo "...done"
87+
fi

.sti/scripts/run.ignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
echo hello world
3+
exec /wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Getting Started with Java on OpenShift Sample Application
2+
====================
3+
4+
This is a sample application for the book, Getting Started with Java on OpenShift

pom.xml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>SampleApp</groupId>
6+
<artifactId>SampleApp</artifactId>
7+
<packaging>war</packaging>
8+
<version>1.0</version>
9+
<name>SampleApp</name>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<maven.compiler.source>1.7</maven.compiler.source>
14+
<maven.compiler.target>1.7</maven.compiler.target>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>javax</groupId>
20+
<artifactId>javaee-api</artifactId>
21+
<version>7.0</version>
22+
<scope>provided</scope>
23+
</dependency>
24+
</dependencies>
25+
26+
<profiles>
27+
<profile>
28+
<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
29+
<!-- Use this profile for any OpenShift specific customization your app will need. -->
30+
<!-- By default that is to put the resulting archive into the 'deployments' folder. -->
31+
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
32+
<id>openshift</id>
33+
<build>
34+
<finalName>SampleApp</finalName>
35+
<plugins>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-war-plugin</artifactId>
39+
<version>2.3</version>
40+
<configuration>
41+
<failOnMissingWebXml>false</failOnMissingWebXml>
42+
<outputDirectory>target</outputDirectory>
43+
<warName>ROOT</warName>
44+
</configuration>
45+
</plugin>
46+
</plugins>
47+
</build>
48+
</profile>
49+
</profiles>
50+
</project>

src/main/java/.gitkeep

Whitespace-only changes.

src/main/resources/.gitkeep

Whitespace-only changes.

src/main/webapp/index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6+
<title>Welcome to OpenShift</title>
7+
</head>
8+
<body>
9+
<h1>Welcome to Getting Started with Java on OpenShift!</h1>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)