Skip to content

Commit 4bb22d4

Browse files
committed
gradle-3.0 - Split from GradleUtils into dedicated plugins
Release notes: https://gist.github.com/Jonathing/c96051409fcdef58cc51bea8b2b7d4af
1 parent bbd0649 commit 4bb22d4

35 files changed

+124
-26
lines changed

.github/workflows/publish-plugin-changelog.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ on:
44
push:
55
branches: [ 'master' ]
66
paths:
7-
- 'gradle-plugin/changelog-gradle/**'
8-
- 'gradle-plugin/common/**'
7+
- 'gitversion-gradle/changelog-gradle/**'
8+
- 'gitversion-gradle/common/**'
99
- '!.github/workflows/**'
10+
- '!docs/**'
1011
- '!README.md'
1112

1213
permissions:
@@ -17,9 +18,9 @@ jobs:
1718
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@v0
1819
with:
1920
java: 17
20-
gradle_tasks: ':gitversion-gradle:changelog-gradle:check :gitversion-gradle:changelog-gradle:publish' # :gitversion-gradle:publishPlugins
21+
gradle_tasks: ':gitversion-gradle:changelog-gradle:check :gitversion-gradle:changelog-gradle:publish :gitversion-gradle:changelog-gradle:publishPlugins'
2122
artifact_name: 'changelog-gradle'
22-
project_path: 'gradle-plugin/changelog-gradle'
23+
project_path: 'gitversion-gradle/changelog-gradle'
2324
secrets:
2425
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
2526
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}

.github/workflows/publish-plugin-gitversion.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ on:
44
push:
55
branches: [ 'master' ]
66
paths:
7-
- 'gradle-plugin/**'
8-
- '!gradle-plugin/changelog-gradle/**'
7+
- 'gitversion-gradle/**'
8+
- '!gitversion-gradle/changelog-gradle/**'
99
- '!.github/workflows/**'
10+
- '!docs/**'
1011
- '!README.md'
1112

1213
permissions:
@@ -17,9 +18,9 @@ jobs:
1718
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@v0
1819
with:
1920
java: 17
20-
gradle_tasks: ':gitversion-gradle:check :gitversion-gradle:publish' # :gitversion-gradle:publishPlugins
21+
gradle_tasks: ':gitversion-gradle:check :gitversion-gradle:publish :gitversion-gradle:publishPlugins'
2122
artifact_name: 'gitversion-gradle'
22-
project_path: 'gradle-plugin'
23+
project_path: 'gitversion-gradle'
2324
secrets:
2425
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
2526
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}

.github/workflows/publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ on:
44
push:
55
branches: [ 'master' ]
66
paths-ignore:
7-
- 'gradle-plugin/**'
7+
- 'gitversion-gradle/**'
88
- '.github/workflows/**'
9+
- 'docs/**'
910
- 'README.md'
1011

1112
permissions:
@@ -16,7 +17,7 @@ jobs:
1617
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@v0
1718
with:
1819
java: 17
19-
gradle_tasks: 'check publish'
20+
gradle_tasks: ':check :publish'
2021
artifact_name: 'gitversion'
2122
secrets:
2223
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}

.gitversion

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitversion.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
[gradlePlugin]
2-
path = "gradle-plugin"
1+
[root]
2+
exclude = [ "gradle-plugin" ] # old folder name for gitversion-gradle
3+
4+
[gitverGradle]
5+
path = "gitversion-gradle"
36
tag = "gradle"
7+
8+
[changelogGradle]
9+
path = "gitversion-gradle/changelog-gradle"
10+
tag = "changelog-gradle"
11+
include = [ "gitversion-gradle/common" ]

docs/releases/3.0.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ changelog {
106106
}
107107

108108
gradlePlugin {
109-
website.set gitversion.url
110-
vcsUrl.set gitversion.url + '.git'
109+
website = gitversion.url
110+
vcsUrl = gitversion.url + '.git'
111111

112112
plugins.register('gitversion') {
113113
id = 'net.minecraftforge.gitversion'
114114
implementationClass = 'net.minecraftforge.gitversion.gradle.GitVersionPlugin'
115115
displayName = projectDisplayName
116116
description = project.description
117-
tags.set(['git', 'version'])
117+
tags = ['git', 'version']
118118
}
119119
}
120120

File renamed without changes.

gradle-plugin/changelog-gradle/src/main/groovy/net/minecraftforge/gitversion/gradle/changelog/ChangelogExtension.java renamed to gitversion-gradle/changelog-gradle/src/main/groovy/net/minecraftforge/gitversion/gradle/changelog/ChangelogExtension.java

File renamed without changes.

gradle-plugin/changelog-gradle/src/main/groovy/net/minecraftforge/gitversion/gradle/changelog/ChangelogExtensionImpl.groovy renamed to gitversion-gradle/changelog-gradle/src/main/groovy/net/minecraftforge/gitversion/gradle/changelog/ChangelogExtensionImpl.groovy

File renamed without changes.

0 commit comments

Comments
 (0)