In Part 1 of this series we imported JDeveloper libraries into our Maven repository and in Part 2 we built a WAR file for our ADF project using Maven. In Part 3, we will now take one or more of these WAR files and package them into an EAR file for deployment. Before we start looking at the pom.xml for the EAR build, you should know that, unlike JDeveloper, Maven defines the EAR as a separate project. Normally, you would keep your EAR level artifacts in this project, but in the case of JDeveloper and ADF the EAR level artifacts are kept in the application folder.
Setting up the EAR Project
The first thing you will need to do is to create the EAR project structure. This is really just another folder within your JDeveloper application that contains the pom.xml we will create. I usually name these the same as my view project with -ear appended for example, sample-project-view-ear.
Standard POM Information
The first information we will put in our pom.xml is the very standard as you can see below. The packaing type is ear and following the naming standard we have used I have defined a base.name property and then just appended -ear to the end of it for this artifact id.
<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">
<description>Sample Project - ADF Interface EAR</description>
We now need to declare our depenencies. In our case, we have no libraries we are dependent on at the EAR level so our only dependency is our WAR project. Below is how I have declared a dependency on the WAR file of the same version as our EAR.
The build configuration for the EAR is where things start to get more complicated. There are five items we need to account for in our build configuration:
- There are resources in the .adf folder at the application level that need to be placed in the adf folder within the EAR.
- The source files and resources in the src folder at the application level that need to be put in the EAR.
- The context root of the WAR file should be set correctly. In this case, we want a version specific context root.
- A jar file named adf-loc.jar is required to put the adf folder within the EAR on the classpath.
- JDeveloper/ojdeploy modify the adf-config.xml file during packaging (at least for BPM applications). We need to emulate these same changes.