Oracle by Example brandingConfiguring and Building an ADF Application using Ant in Oracle Developer Cloud Service Classic

section 0Before You Begin

This 15-minute tutorial shows you how to configure and build an Oracle Application Development Framework (Oracle ADF) application with Apache Ant using Oracle JDeveloper and Oracle Developer Cloud Service.

Background

Oracle Developer Cloud Service can build Oracle ADF applications by using Ant, JDeveloper, OJMake and OJDeploy utilities.

In this tutorial, you use the Oracle Alta UI Work Better sample application and configure it in JDeveloper to use Ant build files. You configure the Ant build files file to access the JDeveloper, ADF libraries, OJMake and OJDeploy utilities on the Oracle Developer Cloud Service build system. You then create a job in Oracle Developer Cloud Service that runs an Ant build and generates the artifacts.

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

What Do You Need?


section 1Add Ant Build Files to the Oracle ADF Application

In this section, you add Ant build files, build.xml and build.properties, to an Oracle ADF application in JDeveloper.

  1. In JDeveloper, if you aren't using the Studio Developer role, from the Tools menu, select Switch Roles, and then select Studio Developer (All Features). Save all files and restart JDeveloper.
  2. Open the WorkBetterFaces application application from the cloned Git repository of the project.
  3. From the File menu, select New, and then select From Gallery.
    File - New submenu of JDeveloper
    Description of the illustration jdev_new.png
  4. In the New Gallery dialog box, select Ant in the General category, select Buildfile from Application in the Items list, and click OK.
    New Gallery dialog box
    Description of the illustration add_ant_02.png
  5. In the Create Buildfile from Application dialog box, select the Include Packaging Tasks (uses ojdeploy) check box and click OK.
    Create Buildfile from Application dialog box
    Description of the illustration add_ant_03.png
    Two new files, build.xml and build.properties, are added to the ADF application.
    Application Resources pane
    Description of the illustration add_ant_04.png

section 2Configure the Ant Buildfiles

In this section, you configure the Ant buildfiles to access Ant libraries, OJMake, and OJDeploy utilities on the Oracle Developer Cloud Service build system using Oracle Developer Cloud Service system environment variables.

  1. In JDeveloper, double-click build.xml to open it in the editor.
    Application Resources pane
    Description of the illustration config_ant_01.png
  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.
    build.xml file in code editor
    Description of the illustration config_ant_02.png
  3. Save build.xml.
  4. Double-click build.properties to open it in the code editor.
  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
    Make sure there are no spaces at the end of each property definition.
    build.properties in the code editor
    Description of the illustration config_ant_03.png
    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 build system.
    • 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 build system.
    • oracle.jdeveloper.ant.library defines the path of the Ant library on the Oracle Developer Cloud Service build system.
    • oracle.jdeveloper.ojdeploy.path defines the path of OJDeploy on the Oracle Developer Cloud Service build system.
    • 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 build system, see the Using the Oracle Developer Cloud Service Build Executor Environment Variables reference in the Want to Learn More section.
  6. Save the build.properties file.
  7. Using the Team > Git menu options, use the Add option to add the build.xml and build.properties files to the Git repository index, use the Commit option to commit them, and the Push coption to push the commit to the project Git repository.

section 3Configure a Build Job in Oracle Developer Cloud Service

In this section, you configure a build job to run Ant and deploy the archived artifacts.

  1. In the Oracle Developer Cloud Service web interface, create a ADF_Ant_Build job and open its configuration page.
    See the Create and Configure a Build Job in Developer Cloud OBE in the Want to Learn More section to learn about how to create and congigure a job in Oracle Developer Cloud Service.
  2. On the Main tab of Configure build job, select JDK 8 in the JDK field. ADF 12c (12.2.1.0.0) applications require JDK 8.
    Main tab of the Configure Build job page
    Description of the illustration config_build_ant_01.png
  3. Click the Source Control tab and select the Git option. In the Repositories section, select the adf-sample-application.git Git repository.
    Source Control tab of the Configure Build job page
    Description of the illustration config_build_source.png
  4. Click the Build Steps tab, click Add Build Step and select Invoke Ant.
    Build Steps tab of the Configure Build job page
    Description of the illustration config_build_ant_02.png
  5. In the Targets field, enter deploy.
    Build Steps tab of the Configure Build job page
    Description of the illustration config_build_ant_03.png
    JDeveloper created a default deploy target when you added build.xml to the WorkBetterFaces application.
    Code page showng the build.xml file
    Description of the illustration config_build_ant_04.png
    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.
  6. In the Build File field, enter WorkBetterFaces/build.xml as the path of build.xml.
    Build Steps tab of the Configure Build job page
    Description of the illustration config_build_ant_05.png
    You can verify the path of the file in the Code page.
  7. In the Post Build tab, select the Archive the Artifacts check box, enter WorkBetterFaces/ViewController/deploy/*.ear in Files to Archive, and click Save.
    Post Build tab of the Configure Build job page
    Description of the illustration config_build_ant_06.png
    Remember you specified the path of the output file in the oracle.jdeveloper.deploy.outputfile property of the build.properties file.
    build.propertis file in the Code page
    Description of the illustration config_build_ant_07.png
  8. In the ADF_Ant_Build details page, click Build Now and wait for the build to complete.
    Build Now button of the job
    Description of the illustration config_build_ant_08.png
    Check the build's progress in the Build History section.
  9. After the build is completed, expand Artifacts of Last Build to view the archived artifacts.
  10. To view the build status of ADF_Ant_Build in JDeveloper, refresh the project in Team Server. Place your cursor over Demo and click the Refresh icon.
    The Refresh icon of the Team tab
    Description of the illustration jdev_team_refresh.png
  11. In the Team tab, expand Builds.
    Builds section in the JDeveloper Team tab
    Description of the illustration config_build_ant_09.png
  12. After the build is successful, in the Deploy page of Oracle Developer Cloud Service, create a deployment configuration and deploy the ADF application to Oracle Java Cloud Service. See the Deploying an Application from Oracle Developer Cloud Service to Oracle Java Cloud Service OBE in the Want to Learn More section to learn about how to deploy an application to Oracle Java Cloud Service.

more informationWant to Learn More?