Common Gradle modules for multiple projects
This repository is supposed to be used as a submodule in a project. The Gradle build should then be configured as an include build.
To include this repository as a submodule in a project, run the following command in the project's root directory:
git submodule add https://github.com/SonarSource/cloud-native-gradle-modules gradle/build-logic
Then, in the project's settings.gradle.kts
file, add includeBuild
to the pluginManagement
block:
pluginManagement {
includeBuild("gradle/build-logic")
}
Here we used gradle/build-logic
as a directory, but the choice is arbitrary.
An example usage can be seen in the Sonar-Go analyzer
When a newer version of the submodule is integrated into a remote branch, running git pull
will not automatically update the submodule. Instead, Git will display it as changed, and git status
will show a message like:
modified: gradle/build-logic (new commits)
To configure Git to automatically checkout changes in the submodule, run the following command:
git config submodule.recurse true
Optionally, run this command with --global
to apply this configuration globally.
- Apply
artifactory-configuration
to the root project to set some defaults - Apply
sonar-plugin
to the subproject that contains the plugin - If necessary, re-apply
artifactory-configuration
to the subproject to override the defaults
- Apply
go-binary-builder
script to the subproject that contains the Go code- It expects
make.sh
andmake.bat
scripts to be present in the same directory asbuild.gradle[.kts]
- It expects
- Configure the
goBuild
extension - Go-related tasks are automatically linked to
test
,assemble
,check
, andbuild
tasks - A configuration
goBinaries
is created, and it can be used to depend on the Go binaries likeimplementation(projects(":go-subprojcet", "goBinaries"))