Jun 17, 2015

Automating Oracle ADF project builds outside of Oracle JDeveloper

Background: In my previous blog entry: https://www.metalogic.ie/news/9/46/Best-Practice-Code-Organisation-and-Management-for-Oracle-ADF-Applications/d,ML_V2_News_Detail  I described some initial considerations when starting a new Oracle ADF project, particularly in relation to ADF modules structure. Another consideration, when starting new ADF projects is that of building the project. In this blog I would like to explain one possible way to approach the application build process.

The Default JDeveloper Build

Most Oracle ADF-based development projects require code reorganisation  during their lifetime.  A significant reason of the reorganisation task is that the application was developed using the default JDeveloper ADF Application project structure. Reorganisation of this structure , along with good source control practices will save significant effort during the project lifetime.

Oracle Default Project Structure

Oracle JDeveloper provides a very good out-of-box build tool. It is easy to configure and execute deployment profiles in JDeveloper IDE. However this requires using JDeveloper. What about the requirement to integrate the build process with external tools like Jenkins? The best solution would be to have Ant or Maven configured. Luckily JDeveloper gives the option to create Ant build scripts out of the ADF project/application based on deployment profiles defined in the IDE.

For illustration purposes, I created an example application in JDeveloper 12c which consists of two separate ADF model projects and one ViewController project.

  • Sample application split into two separate areas, Model and ViewControler, each to have separate list of projects.
  • Ant build.xml script in each of the JDeveloper projects as well as in the view application level.
  • Database script sql to create and populate two tables required by the sample application
  • Cmd script cmd running top level build.

Figure one below illustrates the structure of the sample project.

Figure 1. Sample Application Folder Structure

Figure two below displays two rich tables coming from two different Application Modules but gathered to be in one transaction together in one Root Application Module. The “Save” button commits the changes from both tables in one transaction. The “Update with” button calls the client interface method of each Application Module and sets description fields for each record. The structure of the application and the use of the root module also illustrates the topic covered in my last post.

Figure 2. Sample  Application Structure
Figure 2. Sample Application Structure

The sample application needs:

  • A database to install build_database.sql script
  • A Weblogic server (can be Internal Server in JDeveloper)
  • A Weblogic data source with JNDI name jdbc/Connection1DS pointing to the database with deployed tables
  • Ant installed

The application, post deployment should be available (depending on the hostname and port used by the server) under something similar to: http://localhost:7101/SampleViewApp-SampleViewController-context-root/faces/SamplePage.

Build Script Creation

The purpose of this blog entry is to show one of the build strategies for an ADF application.

First, in each of the ADF projects of the application generate an Ant script using the JDeveloper option in the menu (Buildfile from Project). While doing this make sure the option “Include Packaging Tools” is set.

Figure 3: Build from Project dialog

Then, use the other Ant option (Buildfile from Applications) to create a script to build the application-level EAR file. These two levels are sufficient to create a proper build infrastructure. The options are available in new gallery under the Ant section.

Figure 4: Ant options available in Oracle JDeveloper


  • The previous step creates a set of separate scripts. The easiest way to connect them is to use a “glue” OS script, such as a file in the root of the application (build.cmd). This script enters each project one by one in the correct order (some projects reference the other projects) and creates all jar/war/ear files required.
  • The JDeveloper utility to create the Ant script also creates build.properties files which can contain full paths. For the purpose of this blog I rely on the fact that the application is stored in the D:\WORKSPACES\JDeveloper12\SampleApp (this can be replaced or even the scripts could be regenerated after download). If the team uses the same directory structure on every developer’s machine (which is recommended) then using the full paths in the scripts will be ok.

At this point the main build.cmd will compile and build all of the parts of the system and produce one EAR file (in SampleApp\ViewController\SampleViewApp\deploy directory) which can be then deployed using http://localhost:7101/console.

Of course during everyday development it is much easier to use the JDeveloper built-in deployment available in the IDE. The two different methods can be used interchangeably depending on the needs. The Ant script should be used mostly when building the whole application, before repository commits as part of the release procedure, etc. Also, the EAR file deployment can be automated using WLST (WebLogic Scripting Tool), however this is outside the scope of this document.

To summarize:

  • It is useful to have an external build script for Oracle ADF applications.
  • It is easy to generate a build script out of the Oracle JDeveloper deployment profiles settings.
  • It is worth keeping the application code together with the build infrastructure in the same disc path across the whole team.

If you would like further details about any of the topics raised in this post or if you would like a copy of the example application please email Tomasz Zwierzchowski.


Other News Articles

  • Page 1 of 2
  • >
  • >>