Build Sports App using Gradle (OEDF) - KiltedKanuck/OpenEdgeOps GitHub Wiki
This section will describe how to compile ABL files, write ABLUnit tests, and package PAS for OpenEdge artifacts using Gradle and OpenEdge DevOps Framework (OEDF).
- OpenEdge (installed with
Progress Dev AS for OE
license) - VSCode editor
- OpenEdge DevOps Framework (OEDF)
- Gradle
- GitHub
- Get the Windows VM details,
- VM Hostname
- Authentication password
- Use the
Remote Desktop Connection
app to log in to the above VM asAdministrator
user
- Open this GitHub repo in a browser and create a fork from it
- For consistency use the default repo name
- You can browse through the folders and files for a high-level understanding of the repo
- Now let's get those projects into your VM for development. In the Windows VM, create a folder named
work
at theC:\Users\Administrator
location - Open a
Command Prompt
terminal and navigate to the folderC:\Users\Administrator\work
- Clone GitHub repo
git clone <https-clone-url-to-your-github-repo>
- Open a
Progress Developer Studio for OpenEdge (PDSOE)
workspace - Import the project
C:\Users\Administrator\work\pug2023OpenEdgeOps\Sports
- Don't worry, if you see multiple compilation errors. The OpenEdge database connection is not configured with the project yet
- Let's create and start a Sports2020 database. Open
proenv
command line and type the below commands, [SKIP FOR THE WORKSHOP]mkdir db\sports cd db\sports prodb sports sports2020 proserve sports -S 9876
- Come back to PDSOE, create a Database connection profile (Window -> Preferences -> Progress OpenEdge -> Database Connections), and point to the
sports
database created above- You can use the below values and leave the other fields empty
Connection name: con_sports Physical name: C:\OpenEdge\WRK\db\sports\sports.db Service/port: 9876
- Click Next until you see the
Define Database Server Configuration
page. Make sure to check both the Auto-start and Auto-shutdown database server options - Click Finish -> Apply
- You can use the below values and leave the other fields empty
- Go to Project properties (Progress OpenEdge -> Database Connections) and attach the created Database connection to the project
- Restart OpenEdge AVM (
<right-click-on-project>
-> Progress OpenEdge -> Restart OpenEdge AVM) - Clean and build the project (Project -> clean)
- Check that the compilation errors will be fixed
- Open
Customer.cls
and navigate to thecount
method - Check references (Find References) for the variable
jsonParser
and rename it tojParser
at all the places inside thecount
method - Run check syntax to confirm there are no compilation errors
- Open
CustomerTest.cls
and run the ABLUnit tests - Check the export
ABL Web Application
â What are the checks we perform for a change? Should you automate these steps? Why?
-
Open VSCode and open the folder
C:\Users\Administrator\work\pug2023OpenEdgeOps
-
Open a Terminal in VSCode
- Use a
Command Prompt
type of terminal
- Use a
-
Let's create a feature branch before we modify the project further,
git checkout -b feature/enable-ci-cd
âšī¸ In general, the
main
branch is restricted from direct commits. You will be able to make changes locally but will not be able to push directly to the remote GitHub repo. Therefore, as a best practice, one should always work on a feature branch and merge it to themain
repo using aPull Request
after reviews and tests are complete. -
Initialize a Gradle for the Sports project
- Open
proenv
, navigate to the project root location and initialize Gradlecd C:\Users\Administrator\work\pug2023OpenEdgeOps\Sports progradle init
- Press enter to keep the defaults for all of the options, except to ensure that the
Select build script DSL
is selected as Groovy. - Notice
build.gradle
file along with other Gradle files would have been generated.build.gradle
file is the main build script where tasks are defined to do certain work such as compile, test, package, and so on.
- Open
-
Open
build.gradle
file in VSCode and add the below code to apply OEDF plugin,plugins { id "progress.openedge.abl" version "2.2.1" }
âšī¸ Since OEDF's latest version (
2.2.1
) doesn't supportGradle 8.x
yet, update the Gradle version insidegradle\wrapper\gradle-wrapper.properties
from8.2.1
to7.3.3
. This will not be needed in future when you actually OE 12.8. -
Set DLC as environment variable -
set DLC=C:/Apps/OE12.8LTS/DLC
-
To see the list of default tasks present run the below command
cd Sports gradlew tasks
Notice tasks, especially under the sections
ABL Compile tasks
andABL Database Connection tasks
-
Configure the rcode output directory for the ABL Compile tasks
tasks.named("compileAbl-root-AppServer"){ rcodeDir = "${buildDir}/rcode/AppServer" } tasks.named("compileAbl-root-PASOEContent-WEB-INF-openedge"){ rcodeDir = "${buildDir}/rcode/PASOEContent/WEB-INF/openedge" } tasks.named("compileAbl-root-tests-AppServer"){ rcodeDir = "${buildDir}/rcode/tests/AppServer" }
âšī¸ There is an issue with OEDF's main ABL plugin where it is not honoring the
output
attribute of the PROPATH. -
Now, let's try to run the build task
gradlew build
There will be compilation errors due to Database connection details not being provided.
-
Let's create a Sports 2020 database on the fly and configure it for the tasks. Copy the below code and paste it at the start of the
build.gradle
file just after thePlugins {}
section// Gather required variables def stageEnv = System.getProperty("STAGE_ENVIRONMENT") stageEnv = stageEnv != null ? stageEnv : System.getenv("STAGE_ENVIRONMENT") def STAGE_ENVIRONMENT = stageEnv != null ? stageEnv : "dev" println "DLC: ${abl.dlcHome}" println "Stage Environment: ${STAGE_ENVIRONMENT}" group = 'com.progress.openedge' version = "1.0.0" description = 'Sports App' abl { if (STAGE_ENVIRONMENT == "dev") { dbConnection { dbName="${buildDir}/db/sports2020/sports" connectionParameters = "-1" } } else { dbConnection { parameterFile='conf/startup.pf' } } } // ABL App tasks task createSports2020(type: CreateDB){ dbName = 'sports' sourceDb = "${dlcHome}/sports2020" outputDir = "${buildDir}/db/sports2020" } if (STAGE_ENVIRONMENT == "dev") { compileAbl.dependsOn "createSports2020" }
-
Let's try to run the build task again
./gradlew build
Notice, the compilation succeeded and rcode will be generated at the
${buildDir}/rcode
location
- Add the below code at the end of the
build.gradle
file,task testABLApp(type: ABLUnit){ source("tests/AppServer") include("**/*Suite.cls") propath("tests/AppServer", "AppServer") outputDir = "${buildDir}/test-results/test" arguments = [haltOnFailure: "true"] } if (STAGE_ENVIRONMENT == "dev") { testABLApp.dependsOn "createSports2020" } check.dependsOn "testABLApp", "compileAbl"
- Run the build task again
Notice, that the ABLUnit tests ran and a summary will be printed in the terminal. You can also open the report file (
./gradlew build
Sports\build\test-results\test\results.xml
) in a browser for a pretty view.
- Add the below code at the end of the
build.gradle
task packageWebApp(type: OEWar){ webAppName = "Sports" archiveVersion = "" // to ignore version in the archive name, otherwise has to be handled during deployment verbose = true projectLocation = project.projectDir println "projectLocation: ${projectLocation.get()}" destinationDirectory = project.file "${project.distsDirectory.get()}/webapps" // exclude Sources from 'openedge' directory // (the ANT task used internally does it by default but added here anyway) exclude "PASOEContent/WEB-INF/openedge/*.(cls|p|i)" webInf { from("${buildDir}/rcode/PASOEContent/WEB-INF/openedge") into("openedge") } manifest { attributes "Implementation-Title": "My Sports ABL Web Application" attributes "Implementation-Version": "1.0.0" // from ("PASOEContent/META-INF/MANIFEST.MF") } } packageWebApp.dependsOn "compileAbl-root-PASOEContent-WEB-INF-openedge" assemble.dependsOn "packageWebApp"
- Run the build task again
Notice, that the WAR file is generated,
./gradlew build
build\distributions\webapps\Sports.war
- Copy the below code at the end of the
build.gradle
filetask packageABLApp(type: Oear) { ablAppName = "Sports" archiveVersion = "" destinationDirectory = project.file "${project.distsDirectory.get()}/ablapps" //will create 'Sports.oear' file at this location tlr { from 'tlr' include '**/*.properties' include '**/*.xml' } webapps { from "${project.distsDirectory.get()}/webapps" include '**/*.war' include '**/*.zip' } openedge { from "${buildDir}/rcode/AppServer" include '**/*.r' } conf { from 'conf' exclude '**/*.MF' //exclude direct copy of manifest file and append using manifest section } manifest { attributes "Implementation-Title": "My Sports ABL Application" attributes "Implementation-Version": "1.0.0" // from ("conf/MANIFEST.MF") } } packageABLApp.dependsOn "compileAbl-root-AppServer" packageABLApp.dependsOn "packageWebApp" assemble.dependsOn "packageABLApp"
- Run the build task again
Notice, that the OEAR file is generated,
./gradlew build
build\distributions\ablapps\Sports.oear
This completes the build steps in the local VM setup. After the local changes, we tested compile, unit test, and package locally. Now let's push the changes to remote GitHub repo and work on creating a CI pipeline.
git add <files-added>
git commit -m "OEDF scripts for building Sports app"
git push origin feature/enable-ci-cd
If you don't have Git client configured, you need to do that.
- Add the user
git config --global user.email "<email-id>"
- Sign in while pushing to remote rep
Go to the Setup CI Pipeline Activity