ReactiveCircus / app-versioning

A Gradle Plugin for lazily generating Android app's versionCode & versionName from Git tags.
Apache License 2.0
205 stars 3 forks source link

Fails if root gradle project directory is not also root git directory #12

Closed gpothier closed 3 years ago

gpothier commented 3 years ago

The plugin fails with this error if the Gradle root directory is a subdirectory of the git repository: "Android App Versioning Gradle Plugin works with git tags but root project 'android' is not a valid git repository"

For instance, in a Ionic app, the Gradle project is within an android directory inside the repository. From the command line, git describe --tags works fine from within any subdirectory of the repository. I don't know if GitClient works the same, but the plugin checks if gitRefsDirectory exists before initializing GitClient.

ychescale9 commented 3 years ago

Thanks for reporting this. I just released 0.8.1 which allows you to specify the git root directory explicitly:

appVersioning {
    gitRootDirectory.set(rootProject.file("../"))
}

Let me know if it works :).


Here's why I decided to ask the user to specify the git root explicitly in case you're interested:

GitClient does work from anywhere within the repository. We could use git rev-parse --show-toplevel to dynamically find the git root instead of asking user to specify it, but then we won't be able to use the .git/refs directory as the task input to make the task incremental / cacheable.

gpothier commented 3 years ago

Wow thanks a lot, it works!