-
Notifications
You must be signed in to change notification settings - Fork 623
Gradle Build Scripts
Collapse
-
Declares the configuration required to instantiate and configure the hierarchy of
Projectinstances which are to participate in a build. -
There is a one-to-one correspondence between a
Settingsinstance and asettings.gradlesettings file. Before Gradle assembles the projects for a build, it creates aSettingsinstance and executes the settings file against it. -
Open Liberty's
settings.gradlefile loads properties from either~/gradle.startup.propertiesor it loads the property file passed as an option-Dbuild.properties.pathon an automated build. These are the expected properties (and typical values for a continuous integration build):
artifactory.download.server = eu.artifactory.swg-devops.com
artifactory.download.token = (token)
artifactory.download.user = [email protected]
artifactory.upload.server = na.artifactory.swg-devops.com
artifactory.upload.token = (token)
artifactory.upload.user = [email protected]
buildLabel = 20190704-1647
buildResultUUID = _VAzRUJ5xEemn7JSbMpQERQ
dhe.password = (password)
dhe.user = [email protected]
disable.run.runUnitTests = false
ghe.build.type = Continuous
gradle-tasks.log = /home/jazz_build/_VAzRUJ5xEemn7JSbMpQERQ-EBC.PROD.WASRTC-BT4-001-00-00/jbe/build/open-liberty/dev/gradle-tasks.log
gradle.log = /home/jazz_build/_VAzRUJ5xEemn7JSbMpQERQ-EBC.PROD.WASRTC-BT4-001-00-00/jbe/build/open-liberty/dev/gradle.log
gradle.opts = --stacktrace
gradle.properties.output.path= /home/jazz_build/_VAzRUJ5xEemn7JSbMpQERQ-EBC.PROD.WASRTC-BT4-001-00-00/jbe/build.launch/pass-thru-gradle.properties
intranet.id = [email protected]
intranet.password = (password)
intranet.user = [email protected]
junit.report.zip = /home/jazz_build/_VAzRUJ5xEemn7JSbMpQERQ-EBC.PROD.WASRTC-BT4-001-00-00/jbe/build/open-liberty/dev/open-liberty.unitTest.results.zip
published.gradle.log = /home/jazz_build/_VAzRUJ5xEemn7JSbMpQERQ-EBC.PROD.WASRTC-BT4-001-00-00/jbe/build/open-liberty/dev/tmp/gradle.log
Other properties that may be included:
artifactory.force.external.repo = true
is.personal = true
is.continuous.build = true
is.release = true
buildLabelPrefix =
is.public.publishing = true
build.os.native.packages = true
openLibertyBuild.disable = true
dont.build.open.liberty = true
- Properties are loaded onto a
Propertiesinstance calledgradle.ext.userProps. It is also referred to asgradle.userPropsin build scripts that use it. - If the build is not using Artifactory, it will download Gradle plugins from https://plugins.gradle.org/m2/ and the default values for repository properties are set to:
is.using.artifactory = false
fetch.oss.repository = aQute.bnd.repository.maven.provider.MavenBndRepository;name = RemotePublic;releaseUrl=https://repo.maven.apache.org/maven2/;index=${build}/oss_dependencies.maven
fetch.oss.ibm.repository = aQute.bnd.repository.maven.provider.MavenBndRepository;name = RemoteIBM;local=~/.ibmdhe/repository;releaseUrl=https://public.dhe.ibm.com/ibmdl/export/pub/software/olrepo/;index=${build}/oss_ibm.maven
fetch.ibm.java.repository = aQute.bnd.repository.maven.provider.MavenBndRepository;name = DummyRepo
push.ibm.repository = aQute.bnd.repository.maven.provider.MavenBndRepository;name = RemotePublish
- If all the expected Artifactory properties are set and
artifactory.force.external.repois false, the build configures itself to use Artifactory to download Gradle plugins and sets non-default values for the repository properties:
is.using.artifactory = true
fetch.oss.repository = aQute.bnd.repository.maven.provider.MavenBndRepository;name = RemotePublic;local=~/.ibmartifactory/repository;releaseUrl=https://eu.artifactory.swg-devops.com/artifactory/wasliberty-open-liberty;snapshotUrl=https://eu.artifactory.swg-devops.com/artifactory/wasliberty-open-liberty;index=${build}/oss_dependencies.maven
fetch.oss.ibm.repository = aQute.bnd.repository.maven.provider.MavenBndRepository;name = RemoteIBM;local=~/.ibmartifactory/repository;releaseUrl=https://eu.artifactory.swg-devops.com/artifactory/wasliberty-open-liberty;snapshotUrl=https://eu.artifactory.swg-devops.com/artifactory/wasliberty-open-liberty;index=${build}/oss_ibm.maven
fetch.ibm.java.repository = aQute.bnd.repository.maven.provider.MavenBndRepository;name = IBMInternalJava;local=~/.ibmartifactory/repository;releaseUrl=https://eu.artifactory.swg-devops.com/artifactory/wasliberty-open-liberty;snapshotUrl=https://eu.artifactory.swg-devops.com/artifactory/wasliberty-open-liberty;index=${build}/ibm_java.maven
push.ibm.repository = aQute.bnd.repository.maven.provider.MavenBndRepository;name = RemotePublish;releaseUrl=https://na.artifactory.swg-devops.com/artifactory/wasliberty-open-liberty;snapshotUrl=https://na.artifactory.swg-devops.com/artifactory/wasliberty-open-liberty;index=${build}/openliberty.maven
1.1. wlp-gradle/propertiesSettings.gradle:
- Additional properties are set to
gradle.ext.userProps. The properties fromgenerated.propertiesare set if the file exists. - If these properties were not already set, then they are set (with these default values):
is.automated.build = false
is.personal = false
is.continuous.build = false
is.release = false
is.public.publishing = false
disable.run.runUnitTests = false
build.os.native.packages = false
javac.bootclasspath.1.4 = (varies by environment)
javac.bootclasspath.1.6 = (varies by environment)
javac.bootclasspath.1.7 = (varies by environment)
javac.bootclasspath.1.8 = (varies by environment)
version.qualifier = (timestamp with the format yyyyHHddHHmm)
buildLabel = (timestamp with the format yyyyHHddHHmm)
- If the build is using Artifactory, then these properties are set with non-default values:
javac.bootclasspath.1.4 = ${internaljavac.bootclasspath.1.4}
javac.bootclasspath.1.6 = ${internaljavac.bootclasspath.1.6}
javac.bootclasspath.1.7 = ${internaljavac.bootclasspath.1.7}
javac.bootclasspath.1.8 = ${internaljavac.bootclasspath.1.8}
1.2. wlp-gradle/bndSettings.gradle:
- This file is responsible for including all the
Projectinstances to the Gradle build. Seeincludefor more information on howProjectinstances are added to the Gradle build. - First, it configures bnd plugin dependencies to the
bndSettings.gradlebuild script androotProjectbuild script instances. That enablesbndSettings.gradleto initialize using bnd classes androotProjectto apply thebiz.aQute.bndplugin to other projects. - Then it instantiates a
aQute.bnd.build.Workspaceinstance and sets each property ingradle.userPropsto aPropertiesinstance on theWorkspace. This is so we can use the properties in any.bndfile in the workspace. Specifically, we heavily use the properties incnf/build.bndand other files included by that. More on these files soon. - Lastly, the "cnf" project is included in the Gradle build, along with "build.image", "wlp-bndPlugins", "wlp-rasInstrumentation", and any project returned by
workspace.getAllProjects(). If a project returned byworkspace.getAllProjects()includes a sub directory containing aspringboot.gradlebuild script, that directory is included as a project in the Gradle build too. - The
Workspaceinitialized here is namedrootProject.ext.bndWorkspace, so anyProjectinstance may reference it asrootProject.bndWorkspace. - The collection of bnd project names is named
rootProject.ext.gradleBndProject, soProjectinstances that need to know about projects in the entire workspace may reference that asrootProject.gradleBndProject.
1.2.1 cnf/build.bnd
- More to come.
1.3. wlp-gradle/buildCacheSettings.gradle:
- The build cache stores
Taskoutputs. The remote build cache (https://na.artifactory.swg-devops.com/artifactory/wasliberty-generic-local) is always enabled. If the build is not automated, the local build cache (~/.gradle/caches/build-cache-1) is enabled. If it is a continuous integration build, newTaskoutputs are pushed to the remote build cache.
Collapse
- There is a one-to-one relationship between a
Projectand abuild.gradlefile. TherootProjectis configured by thisbuild.gradlefile with the name "dev". Any project in the hierarchy can refer to it by therootProjectproperty. Because of this, we set some commonly used extra properties onto therootProject.cnfis a reference to theProjectnamed "cnf".buildImageis a reference to theProjectnamed "build.image".storePropsis a named function to write some of the properties determined at build time to a file namedgenerated.propertiesfor future builds. - Throughout the remainder of the configuration lifecycle phase, keep in mind that tasks may have
doFirstordoLastcode configured.doFirstanddoLastcode will be configured, but not executed during this phase.
2.1. wlp-gradle/java.gradle:
- Each sub project of the
rootProjecthas thejavaplugin applied to it, adding many of the common development tasks to these projects. - This build script makes various configuration tweaks on tasks applied by the
javaplugin, such as test tasks are configured to ignore failures.JavaCompiletype tasks set source and target compatibility to "1.7" if they would have been build with "1.6" and the JVM is compatible with Java 12, and if the JVM is compatible with Java 9 or higher, they add a--releaseargument to the compiler. Lastly,Javadoctype tasks add aXdoclint:noneand-quietoption if the JVM is compatible with Java 9. - The build script adds the
testReportandtestResultstasks to generate a HTML test report of all unit test results.
2.2. wlp-gradle/biz.aQute.bnd.gradle:
- This build script is responsible for applying plugins to bnd Projects (or projects that have a
.bndfile). That is determined by selecting projects for whichbndWorkspace.getProject(name)does not return null. - First, the
biz.aQute.bndplugin is applied. Doing that addsrelease,releaseNeededand several other development tasks commonly used in the build. - Next, the build scripts in
wlp-gradle/subprojectsare applied as described below. - Lastly, if a bnd Project does not have the bnd properties
fat.projectandtest.projectset to true, and does not set-nobundles, then it is considered a runtime project and thenet.ossindex.auditplugin is applied, causing the theaudittask to be added.
2.2.1. wlp-gradle/subprojects/repos.gradle
- This build script configures a Maven repository for Artifactory if
is.using.artifactoryis set to true. Otherwise, Maven Central and https://public.dhe.ibm.com/ibmdl/export/pub/software/olrepo/ are used to download project dependencies. The script does not fall back to Maven Central and IBM DHE when there are Artifactory outages.
2.2.2. wlp-gradle/subprojects/publish.gradle
- Applies the
maven-publishplugin, which allows the use ofpublishingblocks and thepublishdevelopment task, so projects' build scripts can declare additional artifacts to upload into the localcnf/releaseMaven repository.
2.2.3. wlp-gradle/subprojects/anttaskdefs.gradle
- This build script runs
ant.taskdeffor several Ant tasks built in the workspace so that they can be used by Gradle tasks.
2.2.4. wlp-gradle/subprojects/tasks.gradle
- Configure 'globalize', 'copyPiiFiles', 'verifyBundleNLS', 'compileJava', 'test', 'apiSpiJavadoc', and 'zipJavadoc' tasks.
2.2.5. wlp-gradle/subprojects/jacoco.gradle
- This build script applies the
Jacocoplugin, which adds thejacocoTestReporttask, and that is configured to depend ontesttasks and generate an HTML report.
2.2.6. wlp-gradle/subprojects/assemble.gradle
- Create 'publishWLPJars', 'publishJavadoc', 'publishToolScripts', 'publishToolJars', 'publishSchemaResources', 'publishPlatformManifests', 'publishPlatformFiles', 'publishTemplates', 'publishBinScripts', 'publishClientScripts', and 'publishLibNative' tasks. Configure 'assemble' to depend on above tasks.
2.2.7. wlp-gradle/subprojects/fat.gradle
- Configure 'buildfat', 'runfat', 'buildandrun', and 'cleanFat' tasks on FAT projects.
Collapse
-
When the build reaches a task to execute, it runs
doFirstcode, executes, then runsdoLastcode. -
The build executes tasks in the order they were configured by the plugin's defaults and then the task's
dependsOnproperty. The build skips executingUP-TO-DATE,FROM-CACHE, andSKIPPEDtasks.-
UP-TO-DATEandFROM-CACHEtasks are determined by theinputsandoutputsof a task. These inputs/outputs can be files or properties. If theinputsandoutputshave same hash values as stored in~/.gradle/cachesor a remote Gradle cache, then the tasks will be markedFROM-CACHE. If the outputs are already built, the tasks will be markedUP-TO-DATE. -
SKIPPEDtasks are determined by a task'senabledproperty. If the property evaluates to false, the task is skipped.
-
- [project:]taskName - TaskType
- Depends on: List of tasks this task depends on
- Description of this task.
- cnf:initialize
- Depends on: cleanRepos, copyMavenLibs, and updatePluginClasses
- Aggregate task that deletes "cnf/release", "cnf/release.mvn", "cnf/local", and "cnf/local.mvn", copies several libraries into "cnf/mavenlibs", and builds "wlp-bndPlugins" into "cnf/bndplugins/classes" and refreshes the bnd Project instances.
- This must be run once after a clone, clean, or checking out a new branch.

- compileJava - JavaCompile
- Depends on: All tasks which contribute to the compilation classpath, including jar tasks from projects that are on the classpath via project dependencies
- Compiles production Java source files using the JDK compiler.
- jar - Jar
- Depends on: classes
- Assembles the production JAR file, based on the classes and resources attached to the main source set.
- javadoc - Javadoc
- Depends on: classes
- Generates API documentation for the production Java source using Javadoc.
- compileTestJava - JavaCompile
- Depends on: classes, and all tasks that contribute to the test compilation classpath
- Compiles test Java source files using the JDK compiler.
- test - Test
- Depends on: testClasses, and all tasks which produce the test runtime classpath
- Runs the unit tests using JUnit or TestNG.
- testReport - TestReport
- Depends on: test tasks of all subprojects included in the build
- Generates an HTML test report from the results of one or more Test tasks.
- testResults
- Depends on: testReport, and test tasks of all subprojects
- Aggregate task to create a test report for all subprojects.
- assemble
- Depends on: jar, and all other tasks that create artifacts attached to the archives configuration
- Aggregate task that assembles all the archives in the project. This task is added by the Base Plugin — which the Java Plugin applies automatically.
- jacocoTestReport - JacocoReport
- Depends on: test
- Task to generate HTML, Xml and CSV reports of Jacoco coverage data.
- audit
- Audits a gradle project using the OSS Index REST API v3 to identify known vulnerabilities in its dependencies.
- publish
- Depends on: All publishPubNamePublicationToRepoNameRepository tasks
- An aggregate task that publishes all defined publications to all defined repositories. It does not include copying publications to the local Maven cache.
- release
- Depends on: jar, and all other tasks that create artifacts attached to the archives configuration
- Releases the project's bundles to the -releaserepo, if one is configured for the project.
- releaseNeeded
- Depends on: jar, and all other tasks that create artifacts attached to the archives configuration
- Releases the project and all projects it depends on.
- bndproperties
- Display the Bnd properties of the project.
- cleanFat - Delete
- Deletes the build/autoFVT directory of a project.
- buildfat
- Depends on: cleanFat, assemble, build, zipProjectFVT
- Aggregate task that deletes the build/autoFVT directory of a project, assembles, builds, and creates a zip of the project's autoFVT bucket.
- runfat - Exec
- Depends on: cleanBeforeRun
- Aggregate task that assembles all the archives in the project. This task is added by the Base Plugin — which the Java Plugin applies automatically.
- buildandrun
- Depends on: buildfat, runfat
- Aggregate task that runs builds and runs a FAT.
copyMavenLibs - Copy
updatePluginClasses - Copy
cleanRepos - Delete
everythingElseHasBeenReleased
createGradleBootstrap
createESALists
createGeneratedReplacementProjects
index - Index
createIndex
zipGradleBootstrap - Zip
libertyReleaseVersions
printProjectDependencies
checkForUpdates
updateArtifact
globalize
copyPiiFiles - Copy
verifyBundleNLS
publishWLPJars - Copy
apiSpiJavadoc - Javadoc
zipJavadoc - Zip
publishJavadoc - Copy
publishToolScripts - Copy
publishToolJars - Copy
publishSchemaResources - Copy
publishPlatformManifests - Copy
publishPlatformFiles - Copy
publishTemplates - Copy
publishBinScripts - Copy
publishClientScripts - Copy
publishLibNative - Copy
cleanBeforeRun - Delete
addRequiredLibraries - Copy
addDerby - Copy
copyFeatureBundles
autoFVT
zipAutoFVT - Zip
zipProjectFVT - Zip
copyPropertiesToBuildImage - Copy
copyReadmeToBuildImage - Copy
copyLicenseToBuildImage - Copy
copySwidTagToBuildImage - Copy
packageOpenLiberty - PackageLibertyWithFeatures
packageOpenLibertyKernel - PackageLibertyWithFeatures
packageOpenLibertyWebProfile8 - PackageLibertyWithFeatures
packageOpenLibertyJavaee8 - PackageLibertyWithFeatures
packageOpenLibertyMicroProfile2 - PackageLibertyWithFeatures
packageOpenLibertyMicroProfile3 - PackageLibertyWithFeatures
zipOpenLiberty - Zip
zipOpenLibertyKernel - Zip
zipOpenLibertyWebProfile8 - Zip
zipOpenLibertyJavaee8 - Zip
zipOpenLibertyMicroProfile2 - Zip
zipOpenLibertyMicroProfile3 - Zip
zipOpenLibertyAll - Zip
createOLRuntimePoms
zipOpenLibertyMaven - Zip
zipTestReport - Zip
createJSONForPublicArtifacts
gatherTestResults
copyOpenLiberty - Copy
updateSpecTemplate - Copy
updateChangelogTemplate - Copy
updateBuildPackageScriptTemplate - Copy
updateRulesTemplate - Copy
buildOsNativePackages - Exec
help
tasks [--all]
wrapper
properties
model