Skip to content

Commit ebfb4e8

Browse files
committed
Update Gradle plugin to use Git Version 0.9, big API cleaning
Also includes: - Migration from Groovy to Java for plugin internals. - Migration from JetBrains to jSpecify for nullability annotations. - Update the entire workspace to Gradle 9.7.1. - Integrate proper (preliminary) support for Isolated projects. - Allow querying the version of other projects (closes #6). - Remove enhancements made when applying to `settings.gradle`. - Remove Gradle property to log project version after evaluation.
1 parent f07299a commit ebfb4e8

34 files changed

Lines changed: 666 additions & 645 deletions

‎.gitattributes‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
*.jar binary
2+
13
* text eol=lf
24
*.bat text eol=crlf
35
*.java text eol=lf

‎build.gradle‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ final projectVendor = 'Forge Development LLC'
1717
description = 'Used by MinecraftForge projects to calculate project versions based on Git history.'
1818
base.archivesName = 'gitversion'
1919
group = 'net.minecraftforge'
20-
version = gitversion.tagOffset
20+
version = gitversion.version
2121

2222
java {
2323
toolchain.languageVersion = JavaLanguageVersion.of(17)
2424
withSourcesJar()
2525
}
2626

2727
configurations {
28-
cli {
28+
register('cli') {
2929
extendsFrom implementation
3030
}
3131
}
@@ -44,7 +44,7 @@ dependencies {
4444
// JSON Output
4545
implementation libs.gson
4646

47-
cli project(':gitversion-cli')
47+
cli projects.gitversionCli
4848
}
4949

5050
license {
@@ -58,7 +58,7 @@ tasks.named('jar', Jar) {
5858
attributes([
5959
'Specification-Title' : gradleutils.displayName,
6060
'Specification-Vendor' : projectVendor,
61-
'Specification-Version' : gitversion.info.tag,
61+
'Specification-Version' : gitversion.info.get().tag,
6262
'Implementation-Title' : gradleutils.displayName,
6363
'Implementation-Vendor' : projectVendor,
6464
'Implementation-Version': project.version

‎gitversion-cli/build.gradle‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
plugins {
22
id 'application'
3+
id 'net.minecraftforge.gitversion'
34
}
45

56
group = 'net.minecraftforge'
6-
version = gitversion.tagOffset
7+
version = gitversion.of(rootProject).version
78

89
java {
910
toolchain.languageVersion = JavaLanguageVersion.of(17)
@@ -15,7 +16,7 @@ application {
1516
}
1617

1718
dependencies {
18-
implementation rootProject
19+
implementation projects.gitversion
1920
implementation libs.jopt
2021
runtimeOnly libs.slf4j
2122
}

‎gitversion-gradle/build.gradle‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.gradle.api.attributes.plugin.GradlePluginApiVersion
44

55
plugins {
66
id 'java-gradle-plugin'
7-
id 'groovy'
87
id 'idea'
98
id 'eclipse'
109
id 'maven-publish'

‎gitversion-gradle/changelog-gradle/src/main/java/net/minecraftforge/gitversion/gradle/changelog/ChangelogUtils.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.gradle.api.publish.maven.MavenPublication;
1212
import org.gradle.api.tasks.TaskProvider;
1313
import org.gradle.language.base.plugins.LifecycleBasePlugin;
14-
import org.jetbrains.annotations.Nullable;
14+
import org.jspecify.annotations.Nullable;
1515

1616
final class ChangelogUtils {
1717
private ChangelogUtils() {}
@@ -50,7 +50,7 @@ static void setupChangelogGenerationOnAllPublishTasks(Project project, Property<
5050
if (includingSubprojects.getOrElse(false)) {
5151
project.subprojects(it -> Util.ensureAfterEvaluate(it, subproject -> {
5252
// attempt to get the current subproject's changelog extension
53-
@Nullable var changelog = subproject.getExtensions().findByType(ChangelogExtension.class);
53+
var changelog = subproject.getExtensions().findByType(ChangelogExtension.class);
5454

5555
// find the changelog extension for the highest project that has it, if the subproject doesn't
5656
for (var parent = project; changelog == null && parent != null; parent = parent.getParent() == parent ? null : parent.getParent()) {

‎gitversion-gradle/changelog-gradle/src/main/java/net/minecraftforge/gitversion/gradle/changelog/package-info.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
// TODO [GitVersion Gradle] Documentation
66
/// The Changelog plugin, powered by Git Version, enables projects to generate a changelog based on Git version history.
7-
@NotNullByDefault
7+
@NullMarked
88
package net.minecraftforge.gitversion.gradle.changelog;
99

10-
import org.jetbrains.annotations.NotNullByDefault;
10+
import org.jspecify.annotations.NullMarked;

‎gitversion-gradle/common/src/main/java/net/minecraftforge/gitversion/gradle/common/GitVersionTools.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ public final class GitVersionTools {
1313

1414
// Git Version
1515
private static final String GITVERSION_NAME = "gitversion";
16-
private static final String GITVERSION_VERSION = "0.7.3";
17-
private static final String GITVERSION_URL = FORGE_MAVEN + "net/minecraftforge/gitversion/" + GITVERSION_VERSION + "/gitversion-" + GITVERSION_VERSION + "-fatjar.jar";
16+
private static final String GITVERSION_VERSION = "0.9.0";
17+
private static final String GITVERSION_ARTIFACT = "net.minecraftforge:gitversion:" + GITVERSION_VERSION + ":fatjar";
1818
private static final int GITVERSION_JAVA = 17;
19-
private static final String GITVERSION_MAIN = "net.minecraftforge.gitver.cli.Main";
20-
public static final Tool GITVERSION = Tool.of(GITVERSION_NAME, GITVERSION_VERSION, GITVERSION_URL, GITVERSION_JAVA, GITVERSION_MAIN);
19+
public static final Tool GITVERSION = Tool.ofForge(GITVERSION_NAME, GITVERSION_ARTIFACT, GITVERSION_JAVA);
2120
}

‎gitversion-gradle/gradle.properties‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ systemProp.org.gradle.unsafe.suppress-gradle-api=true
1010

1111
net.minecraftforge.gradleutils.ide.automatic.sources=true
1212
net.minecraftforge.gradleutils.compilation.defaults=true
13-
14-
net.minecraftforge.gitversion.log.version=true

‎gitversion-gradle/settings.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ gradle.beforeProject { Project project ->
3232
}
3333

3434
dependencyResolutionManagement.versionCatalogs.register('libs') {
35-
version 'gradleutils', '3.3.33'
35+
version 'gradleutils', '3.4.7'
3636

3737
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.licenser
3838
plugin 'javadoc-links', 'io.freefair.javadoc-links' version '8.14' // https://plugins.gradle.org/plugin/io.freefair.javadoc-links

‎gitversion-gradle/src/main/groovy/net/minecraftforge/gitversion/gradle/GitVersionExtension.java‎

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

0 commit comments

Comments
 (0)