Building Oracle ADF Applications with Ant Using Oracle Developer Cloud Service


Options



Before You Begin

Purpose

This tutorial shows you how to build an Oracle ADF application with Apache Ant using Oracle JDeveloper and Oracle Developer Cloud Service.

Time to Complete

30 Minutes

Background

Oracle Developer Cloud Service can build ADF applications using Ant, OJDeploy, and JDeveloper libraries available on the Hudson executor of Oracle Developer Cloud Service.

Scenario

In this tutorial, you will use the Oracle Alta UI Work Better sample application and configure it in JDeveloper to use Ant libraries and the OJDeploy utility available on the Hudson executor of Oracle Developer Cloud Service. You will be using the Oracle Developer Cloud Service system environment variables to access the libraries on the Hudson executor. You will then create a job in Oracle Developer Cloud Service that will run an Ant build and generate the artifacts.

The Alta UI Work Better sample application is a demo application that uses Alta UI, which is used to develop the most recent Oracle Cloud products.

Context

This tutorial expects you to be familiar with creating and configuring a job in Oracle Developer Cloud Service. You should also be familiar with JDeveloper, Ant and its buildfiles, and the OJDeploy utility.

If you are new to Ant, read the Ant manual at https://ant.apache.org/manual/ to know more about Ant and its buildfiles. You do not need to install Ant to run this tutorial.

The OJDeploy utility is available in JDeveloper that aids you in deploying applications. No installation is required to use OJDeploy as it is available in JDeveloper by default. To know more about OJDeploy, see the references to Oracle Fusion Middleware documentation in the Want to Learn More section.

What Do You Need?

  • A subscription to an Oracle Developer Cloud Service instance

  • Oracle JDeveloper 12.2.1.0.0

  • An Oracle ADF application

    Download the Oracle Alta UI Work Better Application Demo - 12.2.1.

  • One of the following supported browsers:

    • Chrome 48 or later

    • Firefox 38 or later

    • Internet Explorer 11 or 12

    • Safari 7 or 8 (Mac OS)

    • Safari Mobile (iOS)

  • An empty Git repository in an Oracle Developer Cloud Service project to which you have access

    This tutorial assumes that you have created an ADF Sample Application project with an initial Git repository that is empty.

Setting Up the ADF Application in Oracle Developer Cloud Service

In this section, you will learn how to create and use a Team Server in JDeveloper to clone an Oracle Developer Cloud Service project Git repository. You will then add the sample ADF Application files to the cloned Git repository, commit, and push the updates to the project Git repository.

A Team Server is an extension in JDeveloper that you can use to manage your Oracle Developer Cloud Service projects from the IDE. Using the Team Server, you can clone the project repositories to your local computer, perform Git actions, manage project issues, and view status of project builds. The Oracle Developer Cloud Service Team Server extension is installed by default in JDeveloper.

Creating a Team Server in Oracle JDeveloper

  1. Open JDeveloper.

  2. From the Team menu, click Team Server, and then click Add Team Server.

    Description of this image
  3. In the New Team Server dialog, enter the following information:

    • Name: Enter Developer Cloud Team Server

    • URL: Enter the URL of your organization on the Oracle Developer Cloud Service instance

      Example: https://developer.us2.oraclecloud.com/my-org/

      Description of this image

      Oracle Developer Cloud Service is the default provider of the Team Server. If necessary, click Proxy Configuration to configure the proxy settings.

  4. Click OK.

    The Team tab is now available in JDeveloper.

    Description of this image
  5. In the Team tab, click Click here to select project.

    Description of this image
  6. In the Developer Cloud Team Server list, click Login.

    Description of this image
  7. In the Login to Team Server dialog, enter the following information:

    • Username: Enter your Oracle Developer Cloud Service instance user name

    • Password: Enter your Oracle Developer Cloud Service instance password

    Description of this image
  8. Click Login.

    After a successful login, the Team Server displays all projects that you own or are a member of.

    Description of this image

Cloning the Project Git Repository

  1. In the Developer Cloud Team Server project list, click ADF Sample Application.

    Description of this image
  2. Expand Sources and click the get link of the adf-sample-application.git repository.

    Description of this image
  3. In the Get Sources from Oracle Developer Cloud Service dialog, click Get from Developer Server.

    Description of this image
  4. In the Welcome page of the Clone from Git wizard, click Next.

    Description of this image
  5. In the Remote Repository page, click Next.

    Description of this image

    The wizard picks the values for Repository URL, Username, and Password from the Team Server. If you prefer to use SSH, update the values of Repository URL and Private Key File before clicking Next.

  6. In the Remote Branch page, click Next.

    Description of this image

    The page is empty because the Git repository being cloned is empty.

  7. In the Destination page, if necessary, update the following information:

    • Destination: The path of the directory where you want to clone the Git repository

    • Clone Name: The name of the cloned Git repository directory

    The Checkout Branch drop-down list is expected to be empty.

    Description of this image
  8. Click Next.

  9. In the Git Clone Summary page, click Finish.

    Description of this image
  10. In the New Gallery dialog, click Cancel to close the dialog.

    Description of this image

    You will not create an application, but add the Oracle Alta UI Work Better Application to the cloned Git repository directory.

Committing and Pushing the ADF Application to Oracle Cloud Developer Service

  1. In the cloned repository directory, extract the contents of the Oracle Alta UI Work Better Application zip file (WorkBetterFaces1221.zip).

    Description of this image
  2. In JDeveloper, open the WorkBetterFaces application.

    Description of this image
  3. From the Team menu, select Git, and then select Add All.

    Description of this image
  4. In the Add All dialog, click OK.

    Description of this image

    After all files are added to the staging index, notice the icons in the Applications window have changed to show a + icon in the lower left corner.

    Description of this image
  5. From the Team menu, select Git, and then select Commit All.

    Description of this image
  6. In the Commit All dialog, enter a comment in Comments.

    If necessary, specify your name and email address in the Author and Commiter fields in the Name <email> format.

    Description of this image
  7. Click OK.

    Notice the icons in the Applications window have changed to show a yellow circle in the lower-left corner.

    Description of this image
  8. From the Team menu, select Git, and then select Push.

    Description of this image
  9. In the Welcome page of the Push to Git wizard, click Next.

    Description of this image
  10. In the Remote Repository page, click Next.

    Description of this image

    The wizard picks the values for Repository URL, Username, and Password from the Team Server. If you prefer to use SSH, update the values of Repository URL and Private Key File before clicking Next.

  11. In the Local Branch page, click Next.

    Description of this image

    The master branch was created when you committed the application files.

  12. In the Commits page, click Next.

    Description of this image
  13. In the Git Push Summary page, click Finish.

    Description of this image

    A Git Push progress bar appears in the Status bar of JDeveloper. Wait for JDeveloper to push all files to the project Git repository.

    Description of this image

    After the Git Push is complete, open the project in Oracle Developer Cloud Service web interface and verify the commit in the Project page.

    Description of this image

Configuring the ADF Application to use Ant

In this section, you will learn how to add Ant buildfiles to an ADF Application in JDeveloper, and then configure them to use OJDeploy with Oracle Developer Cloud Service system environment variables.

Adding Ant Buildfiles to the ADF Application

  1. In JDeveloper, open the WorkBetterFaces application, if you closed it.

  2. From the File menu, click New, and then click From Gallery.

    Description of this image
  3. In the New Gallery dialog, select Ant in the General Category, and then select Buildfile from Application in the Items list.

    Description of this image
  4. Click OK.

  5. In the Create Buildfile from Application dialog, select the Include Packaging Tasks (uses ojdeploy) check box and click OK.

    Description of this image

    Two new files, build.xml and build.properties, are added to the ADF application.

    Description of this image

Configuring the Ant Buildfiles

  1. Double-click build.xml to open it in the code editor.

    Description of this image
  2. Add the following code line before <property file="build.properties"/>:

    <property environment="env"/>

    The <property environment="env"/> code in build.xml enables Ant to access the system environment variables and store them in properties, prefixed with env.

    Description of this image
  3. Save build.xml.

  4. Double-click build.properties to open it in the code editor.

    Description of this image
  5. Remove the existing code of build.properties and add the following code to it.

    oracle.commons=../../../../oracle_common/
    install.dir=../../../..
    oracle.home=${env.ORACLE_HOME_SOA_12_2_1}
    oracle.jdeveloper.workspace.path=${env.WORKSPACE}/WorkBetterFaces/WorkBetterFaces.jws
    middleware.home=${env.MIDDLEWARE_HOME_SOA_12_2_1}
    workspace=${env.WORKSPACE}
    oracle.jdeveloper.ant.library=${env.ORACLE_HOME_SOA_12_2_1}/jdev/lib/ant-jdeveloper.jar
    oracle.jdeveloper.deploy.dir=${env.WORKSPACE}/ViewController/deploy
    oracle.jdeveloper.ojdeploy.path=${oracle.home}/jdev/bin/ojdeploy
    javac.nowarn=off
    oracle.jdeveloper.project.name=ViewController
    oracle.jdeveloper.deploy.outputfile=${env.WORKSPACE}/WorkBetterFaces/ViewController/deploy/${profile.name}
    output.dir=classes
    javac.deprecation=off
    oracle.jdeveloper.deploy.profile.name=*
    javac.debug=on

    In the above code, you are configuring Ant to use the Oracle Developer Cloud Service environment variables.

    • oracle.home uses the ORACLE_HOME_SOA_12_2_1 environment variable to define the path of the JDeveloper 12.2.1 directory installed on the Oracle Developer Cloud Service Hudson executor.

    • middleware.home uses the MIDDLEWARE_HOME_SOA_12_2_1 environment variable to define the path of the Oracle Fusion Middleware directory installed on the Oracle Developer Cloud Service Hudson executor.

    • oracle.jdeveloper.ant.library defines the path of the Ant library on the Oracle Developer Cloud Service Hudson executor

    • oracle.jdeveloper.ojdeploy.path defines the path of OJDeploy on the Oracle Developer Cloud Service Hudson executor

    • oracle.jdeveloper.deploy.outputfile defines the path of the output file

    • oracle.jdeveloper.deploy.dir defines the path of the deployed artifacts directory

    To learn more about Oracle Developer Cloud Service environment variables on the Hudson executor, see the Using Hudson Environment Variables reference in the Want to Learn More section.

    Description of this image

    Make sure there are no spaces at the end of each property definition.

  6. Save the build.properties file.

Committing and Pushing Ant Buildfils to the Project Git Repository

  1. From the Team menu, select Git, and then select Add All.

  2. In the Add All dialog, click OK.

    Note: When you add Ant buildfiles to your application in JDeveloper, the selected project in the Applications window is also updated and appears in the file list of the Add All dialog. Before you click OK, you may choose to ignore the update to the project .jpr file. To ignore the update, deselect the Select check box on the right of the file row.

    Description of this image
  3. From the Team menu, select Git, and then select Commit All.

  4. In the Commit All dialog, enter the commit comment in Comments.

    If necessary, specify your name and email address in the Author and Commiter fields in the Name <email> format.

    Description of this image

    Note: You may choose to ignore the update to the project .jpr file. To ignore the update, deselect the Select check box on the right of the file row.

  5. Click OK.
  6. From the Team menu, select Git, and then select Push.

    Description of this image
  7. In the Welcome page of the Push to Git wizard, click Next.

  8. In the Remote Repository page, click Finish.

    Description of this image

You do not need to go through all pages of the Push to Git wizard. Wait for JDeveloper to push all files to the project Git repository. After the Git Push is complete, verify the added files in the Code page.

Creating and Configuring a Build Job in Oracle Developer Cloud Service

In this section you will learn how to configure an Oracle Developer Cloud Service build job to run Ant and deploy the artifacts to the Ant deploy directory.

  1. In Oracle Developer Cloud Service web interface, open your project and click Build in the navigation bar.

    Description of this image
  2. In the Jobs Overview page, click New Job.

    Description of this image
  3. In the New Job dialog, enter ADF_Ant_Build as the Job Name and click Save.

    Description of this image
  4. In the Main tab of the Configure build job page, select JDK 8in JDK.

    Description of this image

    ADF 12c (12.2.1.0.0) applications require JDK 8.

  5. Click the Source Control tab and select the Git option.

    Description of this image
  6. In the Repositories section, select the Git repository URL of adf-sample-application.git.

    Description of this image
  7. Click the Build Steps tab.

    Description of this image
  8. In the Build Steps tab, click Add Build Step and select Invoke Ant.

    Description of this image
  9. In the Targets field, enter deploy.

    Description of this image

    JDeveloper created a default deploy target when you added build.xml to the WorkBetterFaces application.

    Description of this image

    If you have modified the target name, make sure that the Targets value must match the value of the name attribute of the <target> element specified in build.xml.

  10. In the Build File field, specify the path of build.xml.

    Description of this image

    You can find the path of the file in the Code page.

    Description of this image
  11. Click the Post Build tab.

    Description of this image
  12. In the Post Build tab, select the Archive the Artifacts check box, and enter WorkBetterFaces/ViewController/deploy/*.ear in Files to Archive.

    Description of this image

    Remember you specified the path of the output file in the oracle.jdeveloper.deploy.outputfile property of the build.properties file.

    Description of this image
  13. Click Save.

    Description of this image
  14. In the ADF_Ant_Build details page, click Build Now.

    Description of this image
  15. Wait for the build to complete.

    Description of this image
  16. After the build has run, expand Artifacts of the Last Build to view the archived artifacts.

    Description of this image

    Click WorkBetterFaces_Project1_WorkBetterFaces.ear to download the EAR file to your local computer, which you may deploy to your preferred web server.

    Click the Console icon to view the build console. You may want to do that in case of a build failure.

    Description of this image

    You can also see the build's status in JDeveloper. In the Team Server tab, expand Builds to see the build status of ADF_Ant_Build.

    Description of this image

    You might have to refresh the project in Team Server. Mouse over the project name ADF Sample Application and click the Refresh icon.

    Description of this image

To deploy the build artifact to Oracle Java Cloud Service, see the reference to Deploying an Application from Oracle Developer Cloud Service to Oracle Java Cloud Service tutorial in the Want to Learn More section.

Want to Learn More?