AVIO Consulting

Building BPM and ADF Applications with Maven – Part 1

Sep 4, 2012 | ADF, BPM, Maven

Recently we worked on a BPM 11g application at a customer where the build standard is Maven and Nexus is used as the repository manager.  The application consists of one BPM composite, one SOA composite and one ADF ViewController project which contains the associated taskflows for the human tasks in the BPM process.  In this application all backend integration is done through Web services and the data is self contained within the BPM process variables so no ADF Model project with ADF-BC was needed.  

This required us to build both SOA/BPM composites and ADF ViewController projects using Maven.  Mark Nelson has already written a very good post on building SOA composites with Maven.  Our approach to building our BPM and SOA composites was very similar to this, with the only difference being that we already have a set of Ant scripts that wrap the stock Oracle scripts to add additional configuration options and functionality.  Our Maven POM simply executes these other Ant scripts instead of the Oracle scripts directly.

Building ADF projects is not quite as simple as the composites.  Initially, we took an approach to leverage the Oracle tooling to perform the build, in this case ojdeploy, and allowing the existing tasks to handle all of the heavy lifting of the build.  This worked, but we found it very difficult to use many of the Maven plugins that already exist with this approach.  We needed to generate Checkstyle, PMD, and Findbug reports as well as Javadocs.  Based on the difficulties making these work while leveraging ojdeploy, we decided to move to a more standard Maven build for the ADF applications.  This results in a much cleaner and more controllable build process, but also has some additional setup that is required as well as continued maintanence of the build scripts.

The first thing you need in order to build your ADF View project with Maven is to load all of the required libraries into your Maven repository.  Luckily, there is already a tool written that will extract all of the library definitions from JDeveloper, generate the corresponding POM files for them, and generate shell scripts to simplify the importing of the JAR files and library definitions.  The tool is called maven-adf and can be downloaded from the google code site at http://code.google.com/p/maven-adf/.

Downloading and Configuring Maven-ADF

You can checkout a read only copy of maven-adf using the following command:

svn co http://maven-adf.googlecode.com/svn/trunk/ maven-adf

Once you have completed the checkout, you need to configure the sample.properties file.  Below are the properties it contains and sample values for each.

Property Value Example
version Your current version of JDeveloper 11.1.1.5.0
jdevhome Path to your installation of JDeveloper /opt/Oracle/Middleware/jdeveloper
repourl URL to the Nexus 3rd party repository https://www.avioconsulting.com/
repoid The configured nexus id in your maven settings.xml nexus
groupbase Group id base to use when importing libraries com.oracle.jdeveloper
pompath Directory to store library pom files target/scripts/poms
scriptpath Directory to store bash scripts to import libraries into maven target/scripts
usemanifestclasspath Follow manifest class paths within JAR files true

 

Generating POM files and Shell Scripts

Execute the finally command within your maven-adf directory:

mvn clean package exec:java -Dexec.args="-config sample.properties"

This will generate a POM file for each JDeveloper library, as well as 2 shell scripts.

deploy-adf-jars.sh – This will deploy all of the individual jar files into your maven repository. The POM file for each will be generated automatically during import.

deploy-adf-poms.sh – This will deploy all of the library POM files into the maven repository. They are each dependent on one or more of the jar files imported by the previous script.

You should see output that looks like the following if the command ran successfully:

adesjard@adesjard-laptop:~/maven-adf/maven-adf-read-only$ mvn clean package exec:java -Dexec.args="-config sample.properties"

[INFO] Scanning for projects...

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven ADF JAR Deployer

[INFO] task-segment: [clean, package, exec:java]

[INFO] ------------------------------------------------------------------------

[INFO] [clean:clean {execution: default-clean}]

[INFO] Deleting file set: /home/adesjard/maven-adf/maven-adf-read-only/target (included: [**], excluded: [])

[INFO] [resources:resources {execution: default-resources}]

[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!

[INFO] skip non existing resourceDirectory /home/adesjard/maven-adf/maven-adf-read-only/src/main/resources

[INFO] [compiler:compile {execution: default-compile}]

[INFO] Compiling 3 source files to /home/adesjard/maven-adf/maven-adf-read-only/target/classes

[INFO] [resources:testResources {execution: default-testResources}]

[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!

[INFO] skip non existing resourceDirectory /home/adesjard/maven-adf/maven-adf-read-only/src/test/resources

[INFO] [compiler:testCompile {execution: default-testCompile}]

[INFO] No sources to compile

[INFO] [surefire:test {execution: default-test}]

[INFO] No tests to run.

[INFO] Surefire report directory: /home/adesjard/maven-adf/maven-adf-read-only/target/surefire-reports

-------------------------------------------------------

 T E S T S

-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] [jar:jar {execution: default-jar}]

[INFO] Building jar: /home/adesjard/maven-adf/maven-adf-read-only/target/maven-adf-1.0-SNAPSHOT.jar

[INFO] Preparing exec:java

[INFO] No goals needed for project - skipping

[INFO] [exec:java {execution: default-cli}]

Started: Mon Aug 20 14:28:22 CDT 2012

Finished: Mon Aug 20 14:28:48 CDT 2012

Now run either run the 'deploy-mvnsh' maven shell script or the 'deploy-adf-jars' and 'deploy-adf-poms' scripts generated in: /home/adesjard/maven-adf/maven-adf-read-only/target/scripts to populate your maven repository.

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESSFUL

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 31 seconds

[INFO] Finished at: Mon Aug 20 14:28:48 CDT 2012

[INFO] Final Memory: 21M/301M

[INFO] ------------------------------------------------------------------------

adesjard@adesjard-laptop:~/maven-adf/maven-adf-read-only$ cd target/scripts/


 

Uploading the Artifacts to the Nexus Repository

The final step is to upload the artifacts to your Nexus repository.

Change to the maven-adf/target/scripts directory and execute the deploy-adf.jars.sh first.

You should see output like below for each JAR file being imported.  There are a lot (600+) so be patient as this may take a while to complete.

[INFO] Searching repository for plugin with prefix: 'deploy'.

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven Default Project

[INFO] task-segment: [deploy:deploy-file] (aggregator-style)

[INFO] ------------------------------------------------------------------------

[INFO] [deploy:deploy-file {execution: default-cli}]

Uploading: https://www.avioconsulting.com/:8081/nexus/content/repositories/thirdparty/com/oracle/…

805K uploaded (bc4jtester-11.1.1.5.0.jar)

[INFO] Retrieving previous metadata from nexus

[INFO] Uploading repository metadata for: 'artifact com.oracle.jdeveloper.jars.jdeveloper.BC4J.jlib:bc4jtester'

[INFO] Uploading project information for bc4jtester 11.1.1.5.0

Once that command has completed you can now run the deploy-adf-poms.sh which will deploy the pom files for the library definitions.  Each of these depends on one or more of the JAR files that were just imported.  Again the output should look like below for each library definition imported.




[INFO] Searching repository for plugin with prefix: 'deploy'.

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven Default Project

[INFO] task-segment: [deploy:deploy-file] (aggregator-style)

[INFO] ------------------------------------------------------------------------

[INFO] [deploy:deploy-file {execution: default-cli}]

Uploading: https://www.avioconsulting.com/:8081/nexus/content/repositories/thirdparty/com/oracle/…

8K uploaded (ADF_Common_Runtime-11.1.1.5.0.pom)

[INFO] Uploading project information for ADF_Common_Runtime 11.1.1.5.0

[INFO] Retrieving previous metadata from nexus

[INFO] Uploading repository metadata for: 'artifact com.oracle.jdeveloper.library:ADF_Common_Runtime'

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESSFUL

[INFO] ------------------------------------------------------------------------

 

Results

Once you have completed these tasks you should see results like below in your Nexus repository.  The individual JAR files will be in one group and the JDeveloper libraries in another.  You can now declare dependencies on either a JAR file or a JDeveloper library from your Maven POM now.

Summary

In this first part, you can see how to import the JDeveloper libraries that are required to build an ADF project into a Maven repository.  In the next part we will look at what it takes to build the WAR file for an ADF project, followed by an EAR project to package one or more WAR files for deployment, and lastly a demonstration of a full working solution built from a Jenkins server and deploying the resulting artifacts to a Nexus repository.