Closed kennir closed 2 years ago
You can specify the git root directory:
appVersioning {
gitRootDirectory.set(rootProject.file("app/"))
}
Hi @ychescale9
Thanks for your reply,
I added the line to the build.gradle.kts
appVersioning {
fetchTagsWhenNoneExistsLocally.set(true)
println("My root folder is: ${rootProject.file("app/")}")
gitRootDirectory.set(rootProject.file("app/"))
......
}
and the error still exists, I think the root directory is wrong after the line is added.
BUILD FAILED in 3s
1 actionable task: 1 executed
❯ ./gradlew generateAppVersionInfoForDebug
> Configure project :app
My root folder is: /Users/ken/Developer/projects/2021/workspace/app/app
> Task :app:generateAppVersionInfoForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:generateAppVersionInfoForDebug'.
> A failure occurred while executing io.github.reactivecircus.appversioning.tasks.GenerateAppVersionInfoWorkAction
> Android App Versioning Gradle Plugin works with git tags but root project 'browser-app' is not a git root directory, and a valid gitRootDirectory is not provided.
so :app
is already your root Gradle project?
what's :browser-app
?
Yes, the app and lib are two different git repository, :browser-app is name of project, app is the directory
folder structure:
- workspace (/Users/ken/Developer/projects/2021/workspace)
- app (/Users/ken/Developer/projects/2021/workspace/app) :browser-app
- lib (/Users/ken/Developer/projects/2021/workspace/lib) :scaffold-lib
there are two top-level Gradle project, linked by composite build
app/settings.gradle
includeBuild("../lib")
app/app/build.gradle.kts
dependencies {
implementation("scaffold-lib:baseapp")
}
I checked the tag of commit seemed ok
cd app
git log
commit b98b5d4a8e60997b065e7c9a0a5801765c86930e (HEAD -> develop, tag: 3.0.0, origin/develop)
Ok then I would expect it to work without setting gitRootDirectory
.
Does this folder exist? /Users/ken/Developer/projects/2021/workspace/app/.git/refs/
the app/.git
is not a folder, It's seems a symbol-link
cat app/.git
gitdir: ../.repo/projects/app.git
I think we found the cause of the error, I use git-repo-go for manage multi repositories, I think this tool modify the default git behavior.
I tried adding this line to build.grade.kts, It didn't work as expected, because ../.repo/projects/app.git
is .git
instead of not contains it
gitRootDirectory.set(rootProject.file("../.repo/projects/app.git"))
Yeah this is not going to work, as the plugin expect GIT_REFS_DIRECTORY = ".git/refs"
.
If you go into app.git
do you see a refs
folder?
Yeah, I thinks It's the ".git" directory itself
❯ ls
COMMIT_EDITMSG HEAD co.gitup.mac description index logs packed-refs sourcetreeconfig
FETCH_HEAD ORIG_HEAD config hooks info objects refs
Ok then we could add a gitRefsDirectory
to point to the /refs
directly (and ignore gitRootDirectory
), but I'm not sure how useful this is to others as it seems like an uncommon setup 😄
Yeah, this is not common scene
I think If the .git directory of android repo is same as go-repo, there should more project use composite build and the .git will be a link, not a folder .
give me some time, let me confirm it :)
Thank you very much
https://git-scm.com/docs/gitrepository-layout
Hi, It's seemed the gitdir is an option of git
Thanks I didn't know that 😅
I'll come up with a fix soon hopefully without introducing new plugin configuration.
I've just added support for specifying the location of bare git repository:
appVersioning {
/**
* Bare Git repository directory.
* Use this to explicitly set the directory of a bare git repository (e.g. `app.git`) instead of the standard `.git`.
* Setting this will override the value of [gitRootDirectory] property.
*/
bareGitRepoDirectory.set(rootProject.file("../.repo/projects/app.git")) // if the .git directory in the Gradle project root is a symlink to app.git.
}
Can you please help me test the 1.1.0-SNAPSHOT
version of the plugin?
You'll need to add the sonatype snapshot repository to the buildscript:
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
I had to add a new plugin config because the plugin doesn't know the name of a bare git repo.
I did modify these files
app/app/build.gradle.kts
plugins {
id("com.android.application")
id("io.github.reactivecircus.app-versioning") version "1.1.0-SNAPSHOT"
kotlin("android")
kotlin("kapt")
id("dagger.hilt.android.plugin")
id("dependencies")
}
app/build.gradle.kts
buildscript {
repositories {
google()
mavenCentral()
maven {
setUrl("https://maven.aliyun.com/nexus/content/groups/public/")
}
maven {
setUrl("https://jitpack.io")
}
maven {
setUrl("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
I got error message
org.gradle.internal.exceptions.LocationAwareException: Build file '/Users/ken/Developer/projects/2021/workspace/app/app/build.gradle.kts' line: 4
Plugin [id: 'io.github.reactivecircus.app-versioning', version: '1.1.0-SNAPSHOT'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (None of the included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'io.github.reactivecircus.app-versioning:io.github.reactivecircus.app-versioning.gradle.plugin:1.1.0-SNAPSHOT')
Searched in the following repositories:
Gradle Central Plugin Repository
Ah the snapshots are only published to maven central so you can't use id("io.github.reactivecircus.app-versioning") version "x.y.z"
which needs Gradle Plugin Portal or defining classpath("io.github.reactivecircus.appversioning:app-versioning-gradle-plugin:${Versions.appVersioning}")
.
I'll just publish a RC build now so you don't need to use snapshot 😄
I just published 1.1.0
. Can you try again?
appVersioning {
...
bareGitRepoDirectory.set(rootProject.file("../.repo/projects/app.git"))
}
> Task :app:generateAppVersionInfoForDebug
Generated app version code: 30000.
Generated app version name: "3.0.0-4fef94e".
Nice, It works as well as normal .git
Thank you very much!
Hi
I have the structure of composite build project look likes
I added the appVersioning plugin to app/build.gradle.kts
but I encountered the error:
I confirmed that the app folder contains the.git directory
Thank you