-
Notifications
You must be signed in to change notification settings - Fork 6
Gradle
Gradle is used to specify Java dependencies, lint code, compile code, build Docker images, etc.
There's lots of tutorials online. Here are some tips:
- https://www.youtube.com/playlist?list=PL0UJI1nZ56yAHv9H9kZA6vat4N1kSRGis
- https://www.youtube.com/watch?v=5v92GbC9cqo
Since it's used frequently, a Bash alias is useful (alias g='$PWD/gradlew'
), which reduces typing g build
. (The $PWD
enables g
to be run from any folder.)
Additional aliases can be created:
alias g="$PWD/gradlew"
alias delint='g spotlessApply'
alias gbuild='delint && g build'
alias gdocker='g build && g docker'
alias gcdocker='g clean && gdocker'
alias gdcDown='g dockerComposeDown'
alias gdcUp='g dockerComposeUp'
alias gdcRestart='g dockerComposeDown dockerComposeUp'
-
settings.gradle
: includes subdirectories as Gradle subprojects -
build.gradle
in the project root,api
, andapp
subdirectories -
buildSrc
subdirectory: LHDI Starter Kit provides Gradle plugins; details in the README.md.
To see the current dependencies between subprojects, navigate to the root of the repo and run:
./gradlew :<GRADLE_PROJECT_NAME>:dependencies --configuration compileClasspath | grep "project :"
To see all (including 3rd-party) of the dependencies for a gradle subproject run:
./gradlew :<GRADLE_PROJECT_NAME>:dependencies --configuration compileClasspath > deps.txt
This command will print the dependency tree for the supplied subproject to the deps.txt
file.
./gradlew tasks
./gradlew tasks --all
https://gitlab.com/barfuin/gradle-taskinfo:
./gradlew tiTree assemble
./gradlew tiOrder docker
Jacoco is used to report test coverage for Java -- see https://rhamedy.medium.com/how-to-setup-jacoco-code-coverage-with-maven-gradle-76e0b2fca9fb.
At the root project folder:
./gradlew test jacocoTestReport
Then open build/reports/jacoco/jacocoAggregatedReport/html/index.html
in a browser.
For a subproject, for example:
cd svc-bip-api/
./gradlew test jacocoTestReport
Then open build/jacoco/jacocoAggregatedReport/html/index.html
.
If you're looking for a buildSrc
folder, use the gradle-plugins
folder instead -- it functions equivalently but is reusable and results in faster builds.
The codebase use Composite Builds to partition and decouple Gradle projects, resulting in faster builds.
The current composite builds are:
-
gradle-plugins
: only used for building the code; this is included by other Gradle projects -
mocks
: for projects that represent external APIs or services - (root): the main VRO codebase
A composite build is built independently unless it is referenced by an includeBuild
in settings.gradle
.
For example, since gradle-plugins
is included by other Gradle projects, it is re-built automatically when it changes.
However, mocks
will not be rebuilt unless the Gradle build task is explicitly run against mocks
folder ./gradlew -p mocks build
or:
cd mocks
./gradlew build
Since mocks
rarely need to be rebuilt (and are not integral to the deployed VRO), this will reduce build time.