|
| 1 | +# Git Version Gradle 3 |
| 2 | + |
| 3 | +Git Version Gradle 3 the new release of the Git Version plugin now independent |
| 4 | +of GradleUtils. It also includes a complete rewrite of the plugin, now uses |
| 5 | +the Git Version jar as an executable (`ValueSource` for Git Version, `JavaExec` |
| 6 | +for Changelog), and provides access to much more data regarding the containing |
| 7 | +Git repository. This plugin is written for Java version 17 and targets Gradle |
| 8 | +9.0.0. |
| 9 | + |
| 10 | +## Additions |
| 11 | + |
| 12 | +### Git Version |
| 13 | + |
| 14 | +Git Version Gradle now delegates all actions to Git Version, which is a separate |
| 15 | +tool that can be invoked from the command line. This was done to address the |
| 16 | +need to calculate consistent version numbers from Git history while not being |
| 17 | +restricted to Gradle's runtime. For example, in MinecraftForge projects, the |
| 18 | +SharedActions configurations (currently on branch `v0`) will invoke Git Version |
| 19 | +as a command to verify the version and send it to the Discord server in the |
| 20 | +`#builds` channel. |
| 21 | + |
| 22 | +> [!WARNING] |
| 23 | +> Git Version Gradle does not currently have a way of comparing the project's |
| 24 | +> version to one that could be given by a CI. This will be done in a future |
| 25 | +> update when necessary. |
| 26 | +
|
| 27 | +### Proper API Isolation |
| 28 | + |
| 29 | +Git Version Gradle exposes proper API interfaces as opposed to full-on Groovy |
| 30 | +classes. The implementations of these classes implement Gradle's `HasPublicType` |
| 31 | +interface, so they will be linted by IDEs correctly. The goal is to allow |
| 32 | +implementations to change dynamically without accidentally adding or removing |
| 33 | +public members. |
| 34 | + |
| 35 | +> [!WARNING] |
| 36 | +> There is a known issue with IntelliJ's Gradle Groovy DSL linter where plugins |
| 37 | +> that are applied to `settings.gradle` do not have any linting in either that |
| 38 | +> file or in the `build.gradle` if it is later applied in the project. |
| 39 | +
|
| 40 | +### Proper Errors and Warnings |
| 41 | + |
| 42 | +Git Version Gradle now takes full advantage of Gradle's incubating Problems API |
| 43 | +to report problems with as much detail as is available. IDEs are beginning to |
| 44 | +adopt the Problems API, with the first one being Eclipse (disabled by default, |
| 45 | +check settings). |
| 46 | + |
| 47 | +Exceptions that are thrown with problems attached to them by Git Version will |
| 48 | +have increased details in the error message on the console window, visible in |
| 49 | +terminals and IDEs. |
| 50 | + |
| 51 | +> [!WARNING] |
| 52 | +> This feature is still experimental, and there may be some cases where an error |
| 53 | +> is thrown that Git Version has not provided extra details on. Additionally, |
| 54 | +> the Problems API is still incubating, and changes to it can be made at any |
| 55 | +> time which can break Git Version in a minor update of Gradle 9.x. |
| 56 | +
|
| 57 | +## Changes |
| 58 | + |
| 59 | +### Proper Configuration Caching |
| 60 | + |
| 61 | +Git Version is now free of all configuration cache issues that had plagued it |
| 62 | +in GradleUtils 2.x. This was done by changing how the plugin works at a |
| 63 | +fundemental level. Instead of doing all the work within Gradle, a `ValueSource` |
| 64 | +is now used to run a `JavaExec` action on the Git Version fatjar, which will |
| 65 | +output the data in a JSON format that can be consumed by the plugin. |
| 66 | + |
| 67 | +The Git Version fatjar is downloaded by Git Version Gradle using the tooling |
| 68 | +system from GradleUtils Shared. Gradle is aware of this tool, and changes to it |
| 69 | +will affect the cache (usually invalidation). Since Gradle does not use its file |
| 70 | +watcher when executing programs, Git Version does not need to use hacks (i.e. |
| 71 | +disabling the system configuration) in order to get the information it needs, |
| 72 | +leading to much more consistent data. |
| 73 | + |
| 74 | +### Plugin Application |
| 75 | + |
| 76 | +Git Version Gradle is no longer restricted to only projects. It can now be |
| 77 | +applied to the `settings.gradle(.kts)` as well. Settings that apply this plugin |
| 78 | +will act identical to projects, but all projects contained within the build |
| 79 | +will have their `version` values set to `gitversion.tagOffset`. Additionally, |
| 80 | +if the root project applies the plugin, it will copy the extension from the one |
| 81 | +created from `settings.gradle` instead of creating an entirely new object and |
| 82 | +re-running GitVersion gradle. This makes versioning for subprojects much more |
| 83 | +practical, efficient, and intentional. |
| 84 | + |
| 85 | +## Removals |
| 86 | + |
| 87 | +### Mutable Version Info |
| 88 | + |
| 89 | +Git version info can no longer be mutated in the Gradle runtime. The source of |
| 90 | +truth for how versions are calculated and what subprojects to consider will be |
| 91 | +read from `.gitversion.toml` in the *root project's* folder. More documentation |
| 92 | +on how to best utilize Git Version to advantage will come at a later date. |
0 commit comments