6 min read

Basic project template to kickoff a new Java EE web application will be available on OpenShift platform in 2021, a powerful year for Java programming language and SDK.

Let's start!

To begin with our project, we need a Maven project with XML file that is called pom.xml as shown below:

<?xml version="1.0" encoding="UTF-8"?>
<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">
	<modelVersion>4.0.0</modelVersion>
	<prerequisites>
		<maven>3.0.0</maven>
	</prerequisites>

	<groupId>org.example.kickoff</groupId>
	<artifactId>java-ee-kickoff-app</artifactId>
	<version>1.0.0-SNAPSHOT</version>
	<packaging>war</packaging>

	<name>Java EE kickoff app</name>
	<url>https://github.com/orestispantazos/java-ee-kickoff-app</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<test.wildfly.version>14.0.1.Final</test.wildfly.version>
	</properties>

	<dependencies>
		<!-- Server specific dependencies (we target WildFly 14.0.1 with Mojarra 2.3.5 as of now). -->
		<!-- For correct API sources in Eclipse debugger, those need to be declared BEFORE javaee-api! -->
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.faces</artifactId>
			<version>2.3.5</version> <!-- Use the exact version as provided by target server! -->
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>5.3.6.Final</version> <!-- Use the exact version as provided by target server! -->
			<scope>provided</scope>
			<exclusions>
				<exclusion> <!-- Conflicts with graphene-webdriver. -->
					<groupId>dom4j</groupId>
					<artifactId>dom4j</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<!-- Target Java EE 8 server. -->
		<dependency>
			<groupId>javax</groupId>
			<artifactId>javaee-api</artifactId>
			<version>8.0</version>
			<scope>provided</scope>
		</dependency>

		<!-- Runtime dependencies. -->
		<dependency>
			<groupId>org.omnifaces</groupId>
			<artifactId>omnifaces</artifactId>
			<version>3.2</version>
		</dependency>
		<dependency>
			<groupId>org.omnifaces</groupId>
			<artifactId>omnisettings</artifactId>
			<version>0.1</version>
		</dependency>
		<dependency>
			<groupId>org.omnifaces</groupId>
			<artifactId>omniutils</artifactId>
			<version>0.10</version>
		</dependency>
		<dependency>
			<groupId>org.omnifaces</groupId>
			<artifactId>omnipersistence</artifactId>
			<version>0.9</version>
		</dependency>
		<dependency>
			<groupId>org.omnifaces</groupId>
			<artifactId>optimusfaces</artifactId>
			<version>0.9</version>
		</dependency>
		<dependency>
			<groupId>org.primefaces</groupId>
			<artifactId>primefaces</artifactId>
			<version>6.2</version>
		</dependency>
		<dependency>
			<groupId>com.h2database</groupId>
			<artifactId>h2</artifactId>
			<version>1.4.197</version>
		</dependency>

		<!-- Test dependencies.	-->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.dbunit</groupId>
			<artifactId>dbunit</artifactId>
			<version>2.5.4</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.jboss.arquillian.junit</groupId>
			<artifactId>arquillian-junit-container</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.jboss.arquillian.extension</groupId>
			<artifactId>arquillian-persistence-dbunit</artifactId>
			<version>1.0.0.Alpha7</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.jboss.shrinkwrap.resolver</groupId>
			<artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.jboss.arquillian.graphene</groupId>
			<artifactId>graphene-webdriver</artifactId>
			<version>2.3.2</version>
			<type>pom</type>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>22.0</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<dependencyManagement>
		<dependencies>
			<!-- Test dependencies.	-->
			<dependency>
				<groupId>org.jboss.arquillian</groupId>
				<artifactId>arquillian-bom</artifactId>
				<version>1.4.0.Final</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>org.jboss.arquillian.extension</groupId>
				<artifactId>arquillian-drone-bom</artifactId>
				<version>2.5.0</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<build>
		<finalName>${project.artifactId}</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-archetype-plugin</artifactId>
				<version>3.0.1</version>
				<configuration>
					<propertyFile>archetype.properties</propertyFile>
					<archetypeFilteredExtensions>java,xml,xhtml</archetypeFilteredExtensions>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<profiles>

		<!-- WildFly integration test profile: mvn verify -P wildfly -->
		<profile>
			<id>wildfly</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<dependencies>
				<dependency>
					<groupId>org.wildfly.arquillian</groupId>
					<artifactId>wildfly-arquillian-container-managed</artifactId>
					<version>2.1.1.Final</version>
					<scope>test</scope>
				</dependency>
			</dependencies>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<version>3.0.2</version>
						<executions>
							<execution>
								<phase>process-test-classes</phase>
								<goals>
									<goal>unpack</goal>
								</goals>
								<configuration>
									<artifactItems>
										<artifactItem>
											<groupId>org.wildfly</groupId>
											<artifactId>wildfly-dist</artifactId>
											<version>${test.wildfly.version}</version>
											<type>zip</type>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
						</executions>
						<configuration>
							<outputDirectory>${project.build.directory}</outputDirectory>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-surefire-plugin</artifactId>
						<version>2.20.1</version>
						<configuration>
							<systemPropertyVariables>
								<jboss.home>${project.build.directory}/wildfly-${test.wildfly.version}</jboss.home>
								<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
							</systemPropertyVariables>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-failsafe-plugin</artifactId>
						<version>2.20.1</version>
						<executions>
							<execution>
								<goals>
									<goal>integration-test</goal>
									<goal>verify</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<systemPropertyVariables>
								<jboss.home>${project.build.directory}/wildfly-${test.wildfly.version}</jboss.home>
								<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
							</systemPropertyVariables>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
Orestis Pantazos

Orestis Pantazos

DevOps Engineer