-
Notifications
You must be signed in to change notification settings - Fork 160
Description
I have a repository which contains multiple gradle projects (not subprojects, but independent builds) and I wish to keep them on the same version.
I understand it is possible to configure the repository path via:
scmVersion {
repository {
directory.set(rootProject.file("../").path)
}
}
...which enables the non-root projects to see the git repo and pick up tags for versioning, however for incrementing and snapshots, it doesn't seem to take any commits outside its path into account. It seems like monorepoConfig
is how we should be telling it how to include changes outside its dir when filtering the git log, but setting monorepoConfig.include(listOf(rootProject.file("../").path))
doesn't seem to help. I noticed in jgit that path filters are supposed to be relative to the root of the repository, so I tried using .
as an include (eg monorepoConfig.dependenciesDirs.add(".")
) to see changes in the whole repo, which also didn't work.
For example, I have a test project with the following layout:
❯ tree
.
├── build.gradle.kts
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── project1
├── build.gradle.kts
├── gradlew
└── gradlew.bat
4 directories, 8 files
build.gradle.kts
:
plugins {
id("pl.allegro.tech.build.axion-release") version "1.18.13"
}
group = "com.example"
version = scmVersion.version
project1/build.gradle.kts
:
plugins {
id("pl.allegro.tech.build.axion-release") version "1.18.13"
}
scmVersion {
repository {
directory.set(rootProject.file("../").path)
}
}
group = "com.example"
version = scmVersion.version
tasks.wrapper {
setJarFile("../gradle/wrapper/gradle-wrapper.jar")
}
If I have a v0.1.0 release followed by some commit, eg adding a README to the root, the versions diverge:
❯ ./gradlew release -Prelease.localOnly
> Task :verifyRelease
Looking for uncommitted changes..
Skipping ahead of remote check
Checking for snapshot versions..
> Task :release
Creating tag: v0.1.0
Changes made to local repository only
BUILD SUCCESSFUL in 716ms
2 actionable tasks: 2 executed
❯ touch README.md
❯ git add README.md
❯ git commit -am "Add README"
[main 455a6e5] Add README
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.md
❯ ./gradlew currentVersion -q
Project version: 0.1.1-SNAPSHOT
❯ ./gradlew --project-dir project1 currentVersion -q
Project version: 0.1.0
The docs state that a -SNAPSHOT
is suffixed when not on a tag, but the project1
version isn't being decorated despite the commit being ahead of the v0.1.0
tag. I'm guessing it has to do with the changes being made outside of the project1
directory, but including the root path via monorepoConfig didn't help, though it's certainly possible I misunderstand its configuration.
How can I get the non-root project to always have the same version?