Skip to content

Commit 148ff23

Browse files
SONARGO-109 Update README.md: describe how to use this project as a git submodule (#16)
Co-authored-by: Jonas Wielage <jonas.wielage@sonarsource.com>
1 parent 7c8e2c9 commit 148ff23

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
11
# cloud-native-gradle-modules
22

33
Common Gradle modules for multiple projects
4+
5+
# Usage in a project
6+
This repository is supposed to be used as a submodule in a project. The Gradle build should then be configured as an include build.
7+
8+
To include this repository as a submodule in a project, run the following command in the project's root directory:
9+
```bash
10+
git submodule add https://github.com/SonarSource/cloud-native-gradle-modules gradle/build-logic
11+
```
12+
13+
Then, in the project's `settings.gradle.kts` file, add `includeBuild` to the `pluginManagement` block:
14+
```kotlin
15+
pluginManagement {
16+
includeBuild("gradle/build-logic")
17+
}
18+
```
19+
20+
Here we used `gradle/build-logic` as a directory, but the choice is arbitrary.
21+
An example usage can be seen in the [Sonar-Go analyzer](https://github.com/SonarSource/sonar-go/blob/d4b923d43c3183927a32dc0956cbf4e4ec50d8a9/settings.gradle.kts#L17)
22+
23+
### Configure Git to Automatically Checkout Changes in the Submodule
24+
25+
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:
26+
```text
27+
modified: gradle/build-logic (new commits)
28+
```
29+
30+
To configure Git to automatically checkout changes in the submodule, run the following command:
31+
32+
```bash
33+
git config submodule.recurse true
34+
```
35+
36+
Optionally, run this command with `--global` to apply this configuration globally.

0 commit comments

Comments
 (0)