Building Oracle ADF Applications with Maven Using Oracle Developer Cloud Service


Options



Before You Begin

Purpose

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

Time to Complete

30 Minutes

Background

Oracle Developer Cloud Service can build ADF applications using Maven, Oracle Maven Repository, JDeveloper and ADF libraries, and OJMake and OJDeploy utilities 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 Maven. You will configure the Maven POM file to access the Oracle Maven Repository to download ADF libraries, and to access the OJMake and OJDeploy utilities available on the Oracle Developer Cloud Service Hudson executor. You will then create a job in Oracle Developer Cloud Service that will run a Maven 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, Maven, POM file, Oracle Maven Repository, and OJMake and OJDeploy utilities.

If you are new to Maven, see https://maven.apache.org/. If you are new to Oracle Maven Repsoitory, see https://maven.oracle.com/doc.html.

The OJMake and OJDeploy utilities are available in JDeveloper that aid you in building and deploying applications. No installation is required to use OJMake or OJDeploy as both are available in JDeveloper by default. To know more about OJMake and 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)

  • Your Oracle Account username and password

  • Apache Maven

    You can install Maven (installation instructions) or use the JDeveloper Maven plugin installed at %ORACLE_HOME%/oracle_common/modules. Example:%ORACLE_HOME%/oracle_common/modules/org.apache.maven_3.2.5.

  • M2, M2_HOME, JAVA_HOME, and PATH environment variables set properly

    • M2_HOME set to the Maven directory
      Example: M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-3.2.5

    • M2 set to the Maven bin directory
      Example: M2=%M2_HOME%\bin

    • PATH set to the M2 variable
      Example: PATH=%PATH%;%M2%

    • JAVA_HOME set to the JDK directory
      Example: JAVA_HOME=C:\JDK8

  • 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.

  • Accept the Oracle Maven Repository license agreement.

    Open https://www.oracle.com/webapps/maven/register/license.htmlin your web browser, sign-in with your Oracle Account credentials, and accept the license agreement.

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.

    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 Maven

In this section, you will learn how to add a Maven pom.xml to an ADF Application in JDeveloper and then configure it to access the Oracle Maven Repository. You will also learn how to configure the POM file to use the OJMake and OJDeploy utilities with Oracle Developer Cloud Service system environment variables.

To enable the Maven pom.xmlto access the Oracle Maven Repository, you would need to enter the encrypted Maven master password in settings-security.xml and provide your encrypted Oracle SSO credentials in the Maven settings.xml file.

Adding the Maven POM file to the ADF Application

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

  2. If you are not using the Studio Developer role of JDeveloper, switch to it.

    In JDeveloper, from the Tools menu, select Switch Roles, and then select Studio Developer.

    Description of this image

    When you switch roles, JDeveloper will prompt you to save all files and restart it.

    JDeveloper roles enable you to tailor the JDeveloper environment. Some features that are available in one role may not be available in another. The Studio Developer role allows you to access all features of JDeveloper.

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

    Description of this image
  4. In the New Gallery dialog, select Maven in the General Category, and then select Application POM in the Items list.

    Description of this image
  5. Click OK.

  6. In the Create a Maven POM for the Application dialog, select the Include packaging plugin information (uses ojdeploy) and Include compile plugin information (uses ojmake) check boxes and click OK.

    Description of this image

    A pom.xml file is added to the ADF application.

    Description of this image

Configuring the POM file to Access Oracle Maven Repository, OJMake, and OJDeploy

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

    Description of this image
  2. Click the Repositories tab.

    Description of this image
  3. In the Remote Repositories section, click the Add Repository icon.

    Description of this image
  4. Enter the following information to add the Oracle Maven Repository as a remote repository:

    • Name: OracleMaven

    • ID: maven.oracle.com

    • URL: https://maven.oracle.com

    Description of this image
  5. Click the Plugins tab.

    Description of this image
  6. In the Plugin table, click the leftmost column of the first row to select the ojmake plugin row.

    Description of this image
  7. In the Configuration Parameters table, update the Parameter Value of the ojmake parameter to ${env.ORACLE_HOME_SOA_12_2_1}/jdev/bin/ojmake.

    Description of this image

    The ORACLE_HOME_SOA_12_2_1 environment variable defines the path of the JDeveloper 12.2.1 directory installed on the Oracle Developer Cloud Service Hudson executor.

  8. In the Plugin table, click the leftmost column of the second row to select the ojdeploy plugin row.

    Description of this image
  9. In the Configuration Parameters table, update the Parameter Value of the ojdeploy parameter to ${env.ORACLE_HOME_SOA_12_2_1}/jdev/bin/ojdeploy.

    Description of this image
  10. Save the pom.xml file.

Committing and Pushing Maven files to the Project Git Repository

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

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

    Note: When you add the Maven POM file to your application in JDeveloper, the selected project in the Applications window and the current application file are also updated and appear in the file list of the Add All dialog. Before you click OK, you may ignore the update to those files (.jpr and .jws). 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.

    Description of this image
  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 ignore the update to the project file (.jpr) and the application file (.jws). 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.

    Description of this image
  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 of Oracle Developer Cloud Service Web UI.

Creating and Configuring a Build Job in Oracle Developer Cloud Service

In this section you will learn how to configure a build job to run Maven and deploy the archived artifacts.

  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_Maven_Build as the Job Name and click Save.

    Description of this image
  4. In the Main tab of Configure build job, 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 adf-sample-application.gitGit repository .

    Description of this image
  7. Click the Environment tab.

    Description of this image
  8. In the Environment tab, select the Connect Oracle Maven Repository check box.

    Description of this image
  9. In OTN Login and OTN Password, enter your Oracle Account user name and password.

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

    Description of this image
  11. Click Add Build Step and select Invoke Maven 3.

    Description of this image

  12. In the POM File field, specify WorkBetterFaces/pom.xml as the path of the POM file.

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

    Description of this image
  14. In the Post Build tab, select the Archive the Artifacts check box, and specify WorkBetterFaces/target/*.ear in Files to Archive.

    Description of this image
  15. Click Save.

    Description of this image
  16. In the ADF_Maven_Build details page, click Build Now.

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

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

    Description of this image

    Click WorkBetterFaces_1.0-SNAPSHOT.ear to download the EAR file to your local computer and then 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.

    You can also see the build's status in JDeveloper. In the Team Server tab, expand Builds to see the build status of ADF_Maven_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 to Oracle Java Cloud Service, see the 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?