Skip to content

Commit aad47ec

Browse files
committed
Use JVMDowngrader (until GU3.0) for Git Version
Maintains backwards compatibility with GU2.0, which used J8.
1 parent 1fe556b commit aad47ec

10 files changed

+87
-66
lines changed

build.gradle

+21-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins {
1010
alias libs.plugins.gradleutils
1111
alias libs.plugins.plugin.publish
1212
alias libs.plugins.shadow
13+
alias libs.plugins.downgrader
1314
}
1415

1516
final projectDisplayName = 'Forge Gradle Utilities'
@@ -19,28 +20,31 @@ version = gitversion.tagOffset
1920

2021
println "Version: $version"
2122

22-
// GitVersion requires Java 17
23-
java.toolchain.languageVersion = JavaLanguageVersion.of 17
24-
25-
tasks.withType(GroovyCompile).configureEach {
26-
groovyOptions.optimizationOptions.indy = true
27-
}
23+
// Git Version requires Java 17
24+
java.toolchain.languageVersion = JavaLanguageVersion.of 8
2825

2926
configurations {
27+
resolvable('downgrade')
28+
3029
runtimeClasspath {
3130
exclude group: 'org.slf4j', module: 'slf4j-api'
3231
}
3332
}
3433

34+
jvmdg.dg(configurations.downgrade, true) { flags ->
35+
flags.downgradeTo = JavaVersion.VERSION_1_8
36+
}
37+
3538
dependencies {
3639
// GitHub Actions Workflows
3740
implementation libs.yaml
3841

3942
// Git Version
40-
implementation libs.gitver
43+
downgrade libs.gitver
4144

42-
// TODO - Deprecated git utilities, remove in 3.0
43-
implementation libs.jgit
45+
// Backwards compatibility
46+
downgrade libs.jgit
47+
implementation files(configurations.downgrade.files)
4448
}
4549

4650
license {
@@ -57,6 +61,12 @@ tasks.named('shadowJar', ShadowJar) {
5761
enableRelocation = true
5862
archiveClassifier = null
5963
relocationPrefix = 'net.minecraftforge.gradleutils.shadow'
64+
65+
finalizedBy shadeDowngradedApi
66+
}
67+
68+
tasks.withType(GroovyCompile).configureEach {
69+
groovyOptions.optimizationOptions.indy = true
6070
}
6171

6272
javadoc.enabled = false
@@ -91,7 +101,7 @@ gradlePlugin {
91101
id = 'net.minecraftforge.changelog'
92102
implementationClass = 'net.minecraftforge.gradleutils.changelog.ChangelogPlugin'
93103
displayName = 'Git Changelog'
94-
description = 'Creates a changelog text file based on git history using GitVersion'
104+
description = 'Creates a changelog text file based on git history using Git Version'
95105
tags = ['git', 'changelog']
96106
}
97107
}
@@ -100,6 +110,7 @@ gradlePlugin {
100110
publishing {
101111
publications.register('pluginMaven', MavenPublication) {
102112
artifactId = project.name
113+
103114
changelog.publish it
104115

105116
pom { pom ->

settings.gradle

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ dependencyResolutionManagement {
1212
}
1313

1414
versionCatalogs.register('libs') {
15-
plugin 'licenser', 'net.minecraftforge.licenser' version '1.1.1'
15+
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0'
1616
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '2.5.1'
1717
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '1.3.1'
1818
plugin 'shadow', 'com.gradleup.shadow' version '8.3.6'
19+
plugin 'downgrader', 'xyz.wagyourtail.jvmdowngrader' version '1.2.2'
1920

2021
// GitHub Actions Workflows
21-
library('yaml', 'org.yaml', 'snakeyaml').version('2.4')
22+
library 'yaml', 'org.yaml', 'snakeyaml' version '2.4'
2223

2324
// Git Version
24-
library('gitver', 'net.minecraftforge', 'git-version').version('0.4.2')
25+
library 'gitver', 'net.minecraftforge', 'gitversion' version '0.5.2'
2526

2627
// TODO - Deprecated git utilities, remove in 3.0
27-
library('jgit', 'org.eclipse.jgit', 'org.eclipse.jgit').version('7.2.0.202503040940-r')
28+
library 'jgit', 'org.eclipse.jgit', 'org.eclipse.jgit' version '7.2.0.202503040940-r'
2829
}
2930
}

src/main/groovy/net/minecraftforge/gradleutils/ConfigureTeamCity.groovy

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.gradle.api.provider.Property
1010
import org.gradle.api.provider.ProviderFactory
1111
import org.gradle.api.tasks.Input
1212
import org.gradle.api.tasks.TaskAction
13+
import org.jetbrains.annotations.ApiStatus
1314

1415
import javax.inject.Inject
1516
/**
@@ -18,7 +19,8 @@ import javax.inject.Inject
1819
* @deprecated Will be removed once Forge moves off of TeamCity.
1920
*/
2021
@CompileStatic
21-
@Deprecated(forRemoval = true)
22+
@Deprecated
23+
@ApiStatus.ScheduledForRemoval
2224
@SuppressWarnings('GrDeprecatedAPIUsage')
2325
abstract class ConfigureTeamCity extends DefaultTask {
2426
public static final String NAME = 'configureTeamCity'

src/main/groovy/net/minecraftforge/gradleutils/GenerateActionsWorkflow.groovy

+2-3
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,9 @@ abstract class GenerateActionsWorkflow extends DefaultTask {
102102
if (!file.parentFile.exists() && !file.parentFile.mkdirs())
103103
throw new IllegalStateException('Failed to create directories for output!')
104104

105-
Files.writeString(
105+
Files.write(
106106
file.toPath(),
107-
workflow,
108-
StandardCharsets.UTF_8
107+
workflow.getBytes(StandardCharsets.UTF_8)
109108
)
110109
}
111110
}

src/main/groovy/net/minecraftforge/gradleutils/GradleUtils.groovy

+19-18
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable
2727
* @see GradleUtilsExtension
2828
*/
2929
@CompileStatic
30-
@Deprecated(forRemoval = true, since = '2.5')
30+
@Deprecated
3131
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
3232
class GradleUtils {
3333
static void ensureAfterEvaluate(Project project, Action<? super Project> action) {
@@ -44,7 +44,7 @@ class GradleUtils {
4444
//@formatter:on
4545

4646
private static boolean rsplitDeprecationLogged
47-
@Deprecated(forRemoval = true, since = '2.4')
47+
@Deprecated
4848
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
4949
static @Nullable List<String> rsplit(@Nullable String input, String del, int limit = -1) {
5050
if (!rsplitDeprecationLogged) {
@@ -55,7 +55,7 @@ class GradleUtils {
5555
rsplitInternal input, del, limit
5656
}
5757

58-
@Deprecated(forRemoval = true, since = '2.4')
58+
@Deprecated
5959
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
6060
private static @Nullable List<String> rsplitInternal(@Nullable String input, String del, int limit = -1) {
6161
if (input === null) return null
@@ -72,7 +72,7 @@ class GradleUtils {
7272
}
7373

7474
/** @deprecated Use {@link GitVersion#disableSystemConfig() */
75-
@Deprecated(forRemoval = true, since = '2.4')
75+
@Deprecated
7676
@CompileStatic
7777
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
7878
static class DisableSystemConfig extends SystemReader.Delegate {
@@ -97,7 +97,7 @@ class GradleUtils {
9797

9898
private static boolean gitInfoDeprecationLogged
9999
/** @deprecated Use {@link GitVersion#getInfo()} via {@link net.minecraftforge.gradleutils.gitversion.GitVersionExtension#getVersion() GitVersionExtension.getVersion()} */
100-
@Deprecated(forRemoval = true, since = '2.4')
100+
@Deprecated
101101
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
102102
static Map<String, String> gitInfo(File dir, String... globFilters) {
103103
if (!gitInfoDeprecationLogged) {
@@ -114,7 +114,7 @@ class GradleUtils {
114114
branch : version.info.branch,
115115
commit : version.info.commit,
116116
abbreviatedId: version.info.abbreviatedId,
117-
url : version.info.url
117+
url : version.url
118118
].tap { it.removeAll { it.value == null } }
119119
}
120120
}
@@ -267,14 +267,14 @@ class GradleUtils {
267267
* @return a version in the form {@code $tag.$offset}, e.g. 1.0.5
268268
* @deprecated Use {@link GitVersion#getTagOffset()} instead
269269
*/
270-
@Deprecated(forRemoval = true, since = '2.4')
270+
@Deprecated
271271
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
272272
static String getTagOffsetVersion(Map<String, String> info) {
273273
"${info.tag}.${info.offset}"
274274
}
275275

276276
/** @deprecated Filters can no longer be defined at configuration. Use the Git Version config. */
277-
@Deprecated(forRemoval = true, since = '2.4')
277+
@Deprecated
278278
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
279279
static String getFilteredTagOffsetVersion(Map<String, String> info, boolean prefix = false, String filter) {
280280
getTagOffsetVersion info
@@ -289,7 +289,7 @@ class GradleUtils {
289289
* @return a version in the form {@code $tag.$offset} or {@code $tag.$offset-$branch}
290290
* @deprecated Use {@link GitVersion#getTagOffsetBranch(String ...)} via {@link net.minecraftforge.gradleutils.gitversion.GitVersionExtension#getVersion() GitVersionExtension.getVersion()}
291291
*/
292-
@Deprecated(forRemoval = true, since = '2.4')
292+
@Deprecated
293293
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
294294
static String getTagOffsetBranchVersion(Map<String, String> info, String... allowedBranches) {
295295
if (!allowedBranches || allowedBranches.length === 0)
@@ -303,7 +303,7 @@ class GradleUtils {
303303
}
304304

305305
/** @deprecated Filters can no longer be defined at configuration. Use the Git Version config. */
306-
@Deprecated(forRemoval = true, since = '2.4')
306+
@Deprecated
307307
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
308308
static String getFilteredTagOffsetBranchVersion(Map<String, String> info, boolean prefix = false, String filter, String... allowedBranches) {
309309
getTagOffsetBranchVersion info, allowedBranches
@@ -319,7 +319,7 @@ class GradleUtils {
319319
* @return a version in the form {@code $mcVersion-$tag.$offset} or {@code $mcVersion-$tag.$offset-$branch}
320320
* @deprecated Use {@link GitVersion#getMCTagOffsetBranch(String, String ...)} instead
321321
*/
322-
@Deprecated(forRemoval = true, since = '2.4')
322+
@Deprecated
323323
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
324324
static String getMCTagOffsetBranchVersion(Map<String, String> info, String mcVersion, String... allowedBranches) {
325325
if (!allowedBranches || allowedBranches.length === 0)
@@ -329,21 +329,21 @@ class GradleUtils {
329329
}
330330

331331
/** @deprecated Filters for GitVersion should be set early, using one of the methods in {@link GradleUtilsExtension} */
332-
@Deprecated(forRemoval = true, since = '2.4')
332+
@Deprecated
333333
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
334334
static String getFilteredMCTagOffsetBranchVersion(Map<String, String> info, boolean prefix = false, String filter, String mcVersion, String... allowedBranches) {
335335
getMCTagOffsetBranchVersion info, mcVersion, allowedBranches
336336
}
337337

338338
/** @see net.minecraftforge.gitver.internal.GitUtils#buildProjectUrl(String) GitUtils.buildProjectUrl(String) */
339-
@Deprecated(forRemoval = true, since = '2.4')
339+
@Deprecated
340340
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
341341
static String buildProjectUrl(String project) {
342342
buildProjectUrl "MinecraftForge", project
343343
}
344344

345345
/** @see net.minecraftforge.gitver.internal.GitUtils#buildProjectUrl(String, String) GitUtils.buildProjectUrl(String, String) */
346-
@Deprecated(forRemoval = true, since = '2.4')
346+
@Deprecated
347347
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
348348
static String buildProjectUrl(String organization, String project) {
349349
buildProjectUrlLogDeprecation()
@@ -355,9 +355,9 @@ class GradleUtils {
355355
* {@link net.minecraftforge.gitver.internal.GitUtils#buildProjectUrl(Git) GitUtils.buildProjectUrl(Git)}. The only
356356
* difference is that this does not return {@code null} to preserve GradleUtils 2.x behavior.
357357
*
358-
* @deprecated Replaced by GitVersion, use {@link GitVersion.Info#getUrl()} via {@link net.minecraftforge.gradleutils.gitversion.GitVersionExtension#getVersion() GitVersionExtension.getVersion()}
358+
* @deprecated Replaced by GitVersion, use {@link GitVersion#getUrl()} via {@link net.minecraftforge.gradleutils.gitversion.GitVersionExtension#getVersion() GitVersionExtension.getVersion()}
359359
*/
360-
@Deprecated(forRemoval = true, since = '2.4')
360+
@Deprecated
361361
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
362362
static String buildProjectUrl(Git git) {
363363
buildProjectUrlLogDeprecation()
@@ -403,7 +403,7 @@ class GradleUtils {
403403
}
404404

405405
private static boolean buildProjectUrlDeprecationLogged
406-
@Deprecated(forRemoval = true, since = '2.4')
406+
@Deprecated
407407
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
408408
private static void buildProjectUrlLogDeprecation() {
409409
if (!buildProjectUrlDeprecationLogged) {
@@ -418,7 +418,8 @@ class GradleUtils {
418418
* @param project The project to configure TeamCity tasks for
419419
* @deprecated Once Forge has completely moved off of TeamCity, this will be deleted. New tasks added to GradleUtils should handle registration themselves.
420420
*/
421-
@Deprecated(forRemoval = true)
421+
@Deprecated
422+
@ApiStatus.ScheduledForRemoval
422423
static void setupCITasks(Project project) {
423424
project.tasks.register ConfigureTeamCity.NAME, ConfigureTeamCity
424425
}

src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsExtension.groovy

+14-10
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ class GradleUtilsExtension {
3434
public final PomUtils pom
3535

3636
/** @deprecated Use {@link net.minecraftforge.gitver.api.GitVersion#getRoot() GitVersion.getRoot()} via {@link GitVersionExtension#getVersion()} instead. */
37-
@Deprecated(forRemoval = true, since = '2.4') @Lazy DirectoryProperty gitRoot = {
37+
@Deprecated
38+
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
39+
@Lazy DirectoryProperty gitRoot = {
3840
this.project.logger.warn "WARNING: This project is still using 'gradleutils.gitRoot'. It has been deprecated and will be removed in GradleUtils 3.0. Consider using 'gitversion.rootDir' instead."
3941

4042
this.gitversion.rootDir
4143
}()
4244
/** @deprecated Use {@link net.minecraftforge.gitver.api.GitVersion#getInfo() GitVersion.getInfo()} via {@link GitVersionExtension#getVersion()} instead. */
43-
@Deprecated(forRemoval = true, since = '2.4') @Lazy Map<String, String> gitInfo = {
45+
@Deprecated
46+
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
47+
@Lazy Map<String, String> gitInfo = {
4448
this.project.logger.warn "WARNING: This project is still using 'gradleutils.gitInfo'. It has been deprecated and will be removed in GradleUtils 3.0. Consider using 'gitversion.info' instead."
4549

4650
var gitversion = this.project.extensions.getByType(GitVersionExtension)
@@ -59,7 +63,7 @@ class GradleUtilsExtension {
5963

6064
/** @deprecated This constructor will be made package-private in GradleUtils 3.0 */
6165
@Inject
62-
@Deprecated(forRemoval = true)
66+
@Deprecated
6367
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
6468
GradleUtilsExtension(Project project, ObjectFactory objects, ProviderFactory providers) {
6569
this.project = project
@@ -89,7 +93,7 @@ class GradleUtilsExtension {
8993
*
9094
* @deprecated Use {@link net.minecraftforge.gitver.api.GitVersion#getTagOffset() GitVersion.tagOffset} instead.
9195
*/
92-
@Deprecated(forRemoval = true, since = '2.4')
96+
@Deprecated
9397
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
9498
String getTagOffsetVersion() {
9599
this.logDeprecation('tagOffsetVersion', 'tagOffsetVersion')
@@ -109,7 +113,7 @@ class GradleUtilsExtension {
109113
*
110114
* @deprecated Use {@link net.minecraftforge.gitver.api.GitVersion#getTagOffset() GitVersion.tagOffset} instead.
111115
*/
112-
@Deprecated(forRemoval = true, since = '2.4')
116+
@Deprecated
113117
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
114118
String getFilteredTagOffsetVersion(boolean prefix = false, String filter) {
115119
this.updateInfo(prefix, filter)
@@ -128,7 +132,7 @@ class GradleUtilsExtension {
128132
*
129133
* @deprecated Use {@link net.minecraftforge.gitver.api.GitVersion#getTagOffsetBranch(String ...) GitVersion.getTagOffsetBranch(String...)} instead.
130134
*/
131-
@Deprecated(forRemoval = true, since = '2.4')
135+
@Deprecated
132136
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
133137
String getTagOffsetBranchVersion(String... allowedBranches) {
134138
this.logDeprecation('tagOffsetBranchVersion', 'getTagOffsetBranchVersion(String...)')
@@ -150,7 +154,7 @@ class GradleUtilsExtension {
150154
*
151155
* @deprecated Use {@link net.minecraftforge.gitver.api.GitVersion#getTagOffset() GitVersion.tagOffset} instead.
152156
*/
153-
@Deprecated(forRemoval = true, since = '2.4')
157+
@Deprecated
154158
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
155159
String getFilteredTagOffsetBranchVersion(boolean prefix = false, String filter, String... allowedBranches) {
156160
this.updateInfo(prefix, filter)
@@ -169,7 +173,7 @@ class GradleUtilsExtension {
169173
*
170174
* @deprecated Use {@link net.minecraftforge.gitver.api.GitVersion#getMCTagOffsetBranch(String, String ...) GitVersion.getMCTagOffsetBranch(String, String...)} instead.
171175
*/
172-
@Deprecated(forRemoval = true, since = '2.4')
176+
@Deprecated
173177
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
174178
String getMCTagOffsetBranchVersion(String mcVersion, String... allowedBranches) {
175179
this.logDeprecation('MCTagOffsetBranchVersion', 'getMCTagOffsetBranchVersion(String, String...)')
@@ -191,14 +195,14 @@ class GradleUtilsExtension {
191195
*
192196
* @deprecated Use {@link net.minecraftforge.gitver.api.GitVersion#getMCTagOffsetBranch(String, String ...) GitVersion.getMCTagOffsetBranch(String, String...)} instead.
193197
*/
194-
@Deprecated(forRemoval = true, since = '2.4')
198+
@Deprecated
195199
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
196200
String getFilteredMCTagOffsetBranchVersion(boolean prefix = false, String filter, String mcVersion, String... allowedBranches) {
197201
this.updateInfo(prefix, filter)
198202
this.getMCTagOffsetBranchVersion(mcVersion, allowedBranches)
199203
}
200204

201-
@Deprecated(forRemoval = true, since = '2.4')
205+
@Deprecated
202206
@ApiStatus.ScheduledForRemoval(inVersion = '3.0')
203207
private void updateInfo(boolean prefix, String filter) {
204208
this.gitversion.versionInternal.tap {

0 commit comments

Comments
 (0)