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
-
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
-
Open JDeveloper.
-
From the Team menu, click Team Server, and then click Add Team Server.
View ImageDescription of this image -
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/
View ImageDescription 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.
-
Click OK.
The Team tab is now available in JDeveloper.
View ImageDescription of this image -
In the Team tab, click Click here to select project.
View ImageDescription of this image -
In the Developer Cloud Team Server list, click Login.
View ImageDescription of this image -
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
View ImageDescription of this image -
-
Click Login.
After a successful login, the Team Server displays all projects that you own or are a member of.
View ImageDescription of this image
Cloning the Project Git Repository
-
In the Developer Cloud Team Server project list, click ADF Sample Application.
View ImageDescription of this image -
Expand Sources and click the get link of the
adf-sample-application.git
repository.View ImageDescription of this image -
In the Get Sources from Oracle Developer Cloud Service dialog, click Get from Developer Server.
View ImageDescription of this image -
In the Welcome page of the Clone from Git wizard, click Next.
View ImageDescription of this image -
In the Remote Repository page, click Next.
View ImageDescription 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.
-
In the Remote Branch page, click Next.
View ImageDescription of this image The page is empty because the Git repository being cloned is empty.
-
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.
View ImageDescription of this image -
-
Click Next.
-
In the Git Clone Summary page, click Finish.
View ImageDescription of this image -
In the New Gallery dialog, click Cancel to close the dialog.
View ImageDescription 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
-
In the cloned repository directory, extract the contents of the Oracle Alta UI Work Better Application zip file (
WorkBetterFaces1221.zip
).View ImageDescription of this image -
In JDeveloper, open the WorkBetterFaces application.
View ImageDescription of this image -
From the Team menu, select Git, and then select Add All.
View ImageDescription of this image -
In the Add All dialog, click OK.
View ImageDescription 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.
View ImageDescription of this image -
From the Team menu, select Git, and then select Commit All.
View ImageDescription of this image -
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.View ImageDescription of this image -
Click OK.
Notice the icons in the Applications window have changed to show a yellow circle in the lower-left corner.
View ImageDescription of this image -
From the Team menu, select Git, and then select Push.
View ImageDescription of this image -
In the Welcome page of the Push to Git wizard, click Next.
View ImageDescription of this image -
In the Remote Repository page, click Next.
View ImageDescription 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.
-
In the Local Branch page, click Next.
View ImageDescription of this image The
master
branch was created when you committed the application files. -
In the Commits page, click Next.
View ImageDescription of this image -
In the Git Push Summary page, click Finish.
View ImageDescription 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.
View ImageDescription 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.
View ImageDescription 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
-
In JDeveloper, open the WorkBetterFaces application, if you closed it.
-
From the File menu, click New, and then click From Gallery.
View ImageDescription of this image -
In the New Gallery dialog, select Ant in the General Category, and then select Buildfile from Application in the Items list.
View ImageDescription of this image -
Click OK.
-
In the Create Buildfile from Application dialog, select the Include Packaging Tasks (uses ojdeploy) check box and click OK.
View ImageDescription of this image Two new files,
build.xml
andbuild.properties
, are added to the ADF application.View ImageDescription of this image
Configuring the Ant Buildfiles
-
Double-click
build.xml
to open it in the code editor.View ImageDescription of this image -
Add the following code line before
<property file="build.properties"/>
:<property environment="env"/>
The
<property environment="env"/>
code inbuild.xml
enables Ant to access the system environment variables and store them in properties, prefixed withenv
.View ImageDescription of this image -
Save
build.xml
. -
Double-click
build.properties
to open it in the code editor.View ImageDescription of this image -
Remove the existing code of
build.properties
and add the following code to it.View Codeoracle.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=onIn the above code, you are configuring Ant to use the Oracle Developer Cloud Service environment variables.
-
oracle.home
uses theORACLE_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 theMIDDLEWARE_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.
View ImageDescription of this image Make sure there are no spaces at the end of each property definition.
-
-
Save the
build.properties
file.
Committing and Pushing Ant Buildfils to the Project Git Repository
-
From the Team menu, select Git, and then select Add All.
-
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.View ImageDescription of this image -
From the Team menu, select Git, and then select Commit All.
-
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.View ImageDescription 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. - Click OK.
-
From the Team menu, select Git, and then select Push.
View ImageDescription of this image -
In the Welcome page of the Push to Git wizard, click Next.
-
In the Remote Repository page, click Finish.
View ImageDescription 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.
-
In Oracle Developer Cloud Service web interface, open your project and click Build in the navigation bar.
View ImageDescription of this image -
In the Jobs Overview page, click New Job.
View ImageDescription of this image -
In the New Job dialog, enter
ADF_Ant_Build
as the Job Name and click Save.View ImageDescription of this image -
In the Main tab of the Configure build job page, select
JDK 8
in JDK.View ImageDescription of this image ADF 12c (12.2.1.0.0) applications require JDK 8.
-
Click the Source Control tab and select the Git option.
View ImageDescription of this image -
In the Repositories section, select the Git repository URL of
adf-sample-application.git
.View ImageDescription of this image -
Click the Build Steps tab.
View ImageDescription of this image -
In the Build Steps tab, click Add Build Step and select Invoke Ant.
View ImageDescription of this image -
In the Targets field, enter
deploy
.View ImageDescription of this image JDeveloper created a default
deploy
target when you addedbuild.xml
to the WorkBetterFaces application.View ImageDescription 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 inbuild.xml.
-
In the Build File field, specify the path of
build.xml
.View ImageDescription of this image You can find the path of the file in the Code page.
View ImageDescription of this image -
Click the Post Build tab.
View ImageDescription of this image -
In the Post Build tab, select the Archive the Artifacts check box, and enter
WorkBetterFaces/ViewController/deploy/*.ear
in Files to Archive.View ImageDescription of this image Remember you specified the path of the output file in the
oracle.jdeveloper.deploy.outputfile
property of thebuild.properties
file.View ImageDescription of this image -
Click Save.
View ImageDescription of this image -
In the ADF_Ant_Build details page, click Build Now.
View ImageDescription of this image -
Wait for the build to complete.
View ImageDescription of this image -
After the build has run, expand Artifacts of the Last Build to view the archived artifacts.
View ImageDescription 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
icon to view the build console. You may want to do that in case of a build failure.
View ImageDescription 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.
View ImageDescription 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.
View ImageDescription 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?
-
Using Hudson Environment Variables in Using Developer Cloud Service
-
Deploying an Application from Oracle Developer Cloud Service to Oracle Java Cloud Service tutorial
-
Building Java Projects in Oracle Fusion Middleware Developing Applications with Oracle JDeveloper
-
Deploying Applications in Oracle Fusion Middleware Developing Applications with Oracle JDeveloper