Skip to content

Commit 9160c0c

Browse files
committed
Remove annoyances, fix remaining compatibility issues (#25)
Remaining incompatibilites (won't be fixed) - Dependence on Java 17 Buildscript changes - Updated Gradle to 8.14 - Removed `buildSrc` - GradleUtils is now built against a redistributed Gradle API 7.3 dependency - Updated the Shadow plugin to 9.0.0-beta13 - Force Gradle daemon's JVM version to 17 to fix issues with Groovydoc task Code changes - Yet another big cleanup - Removed PromoteArtifact task (was marked as experimental, will be re-added in 3.0) - Updated Git Version - Removed annoyances within PomUtils - Restored backwards compatibility with Gradle 7.3
1 parent 64dff97 commit 9160c0c

27 files changed

+315
-472
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# GradleUtils
2+
3+
GradleUtils is a convention plugin for Minecraft Forge. It is a set of utilities commonly used by our projects which
4+
helps us standardize our buildscripts.
5+
6+
## Compatibility
7+
8+
<!-- TODO [GradleUtils][Compatibility] If possible, make a precise compatibility matrix. -->
9+
10+
| GradleUtils | Java | Gradle |
11+
|----------------|------|--------|
12+
| 2.0.x | 8 | 7.2* |
13+
| 2.1.0 - 2.3.0 | 8 | 8.4* |
14+
| 2.3.1 - 2.3.3 | 11 | 8.4* |
15+
| 2.3.4 - 2.3.6 | 11 | 8.5* |
16+
| 2.4.0 - 2.4.9 | 17 | 8.6 |
17+
| 2.4.10 - 2.5.x | 17 | 8.1* |
18+
| 2.6.x | 17 | 7.3 |
19+
20+
\*Compatibility was not tested for this version, but this is the lowest recommended version as it was built
21+
against it.

build.gradle

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22

33
plugins {
4-
id 'java-gradle-plugin'
5-
id 'groovy'
4+
id 'dev.gradleplugins.groovy-gradle-plugin'
65
id 'idea'
76
id 'eclipse'
87
id 'maven-publish'
9-
id 'net.minecraftforge.licenser' version '1.1.1'
10-
id 'net.minecraftforge.gradleutils'
11-
id 'com.gradle.plugin-publish' version '1.3.1'
12-
id 'com.gradleup.shadow' version '8.3.6'
8+
alias libs.plugins.licenser
9+
alias libs.plugins.gradleutils
10+
alias libs.plugins.plugin.publish
11+
alias libs.plugins.shadow
1312
}
1413

1514
final projectDisplayName = 'Forge Gradle Utilities'
@@ -19,33 +18,63 @@ version = gitversion.tagOffset
1918

2019
println "Version: $version"
2120

22-
apply from: 'build_shared.gradle'
21+
// Git Version requires Java 17
22+
java.toolchain.languageVersion = JavaLanguageVersion.of 17
23+
24+
configurations {
25+
named(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME) {
26+
// Fixes a conflict between Git Version's shadowed SLF4J from JGit and Gradle's own loggers
27+
exclude group: 'org.slf4j', module: 'slf4j-api'
28+
}
29+
}
30+
31+
repositories {
32+
maven { url = 'https://maven.minecraftforge.net' }
33+
mavenCentral()
34+
}
35+
36+
dependencies {
37+
// Static Analysis
38+
compileOnly libs.nulls
39+
40+
// GitHub Actions Workflows
41+
implementation libs.yaml
42+
43+
// Git Version
44+
implementation libs.gitver
45+
46+
// Backwards compatibility
47+
implementation libs.jgit
48+
}
49+
50+
// Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
51+
// TODO [GradleUtils][GradleAPI] Remove this once they are fixed.
52+
// Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260
53+
// Shadow: https://github.com/GradleUp/shadow/pull/1422
54+
afterEvaluate { project ->
55+
project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { compileOnly ->
56+
compileOnly.dependencies.remove project.dependencies.gradleApi()
57+
}
58+
}
2359

2460
license {
25-
header = file('LICENSE-header.txt')
61+
header = rootProject.file 'LICENSE-header.txt'
2662
newLine = false
27-
exclude '** /*.properties'
63+
exclude '**/*.properties'
2864
}
2965

3066
tasks.named('jar', Jar) {
3167
archiveClassifier = 'thin'
3268
}
3369

3470
tasks.named('shadowJar', ShadowJar) {
35-
enableRelocation = true
71+
enableRelocation = true
3672
archiveClassifier = null
3773
relocationPrefix = 'net.minecraftforge.gradleutils.shadow'
3874
}
3975

40-
javadoc.enabled = false
41-
groovydoc.use = true
42-
43-
// javadocJar is created after evaluation, so we need to configure it here
44-
afterEvaluate {
45-
tasks.named('javadocJar', Jar) {
46-
dependsOn tasks.named('groovydoc', Groovydoc)
47-
from groovydoc.destinationDir
48-
}
76+
tasks.withType(GroovyCompile).configureEach {
77+
groovyOptions.optimizationOptions.indy = true
4978
}
5079

5180
changelog {
@@ -56,37 +85,51 @@ changelog {
5685
gradlePlugin {
5786
website.set gitversion.url
5887
vcsUrl.set gitversion.url + '.git'
88+
89+
compatibility {
90+
minimumGradleVersion = libs.versions.gradle.get()
91+
}
92+
93+
groovy {
94+
withSourcesJar()
95+
withGroovydocJar()
96+
}
97+
5998
plugins {
60-
gradleutils {
99+
register('gradleutils') {
61100
id = 'net.minecraftforge.gradleutils'
62101
implementationClass = 'net.minecraftforge.gradleutils.GradleUtilsPlugin'
63102
displayName = projectDisplayName
64103
description = project.description
65-
tags.set(['minecraftforge'])
104+
tags = ['minecraftforge']
66105
}
67-
changelog {
106+
register('changelog') {
68107
id = 'net.minecraftforge.changelog'
69108
implementationClass = 'net.minecraftforge.gradleutils.changelog.ChangelogPlugin'
70109
displayName = 'Git Changelog'
71-
description = 'Creates a changelog text file based on git history using GitVersion'
72-
tags.set(['git', 'changelog'])
110+
description = 'Creates a changelog text file based on git history using Git Version'
111+
tags = ['git', 'changelog']
73112
}
74113
}
75114
}
76115

77116
publishing {
78117
publications.register('pluginMaven', MavenPublication) {
79-
changelog.publish(it)
118+
artifactId = project.name
119+
120+
changelog.publish it
121+
80122
pom { pom ->
81-
artifactId = project.name
82123
name = projectDisplayName
83124
description = project.description
84125

85-
gradleutils.pom.gitHubDetails = pom
126+
gradleutils.pom.setGitHubDetails pom
86127

87-
license gradleutils.pom.licenses.LGPLv2_1
128+
licenses {
129+
license gradleutils.pom.licenses.LGPLv2_1
130+
}
88131

89-
// TODO [GradleUtils] Re-evaluate active developers in GU 3.0
132+
// TODO [GradleUtils][GU3.0] Re-evaluate active developers in GU 3.0
90133
developers {
91134
developer gradleutils.pom.developers.LexManos
92135
developer gradleutils.pom.developers.SizableShrimp

buildSrc/build.gradle

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

buildSrc/settings.gradle

Lines changed: 0 additions & 1 deletion
This file was deleted.

build_shared.gradle

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

gradle.properties

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ org.gradle.parallel=true
33
org.gradle.configureondemand=true
44

55
# TODO [GradleUtils][Gradle9] Re-enable config cache in Gradle 9
6-
# Configuration Cache comes with too many bugs to be worth the trouble.
6+
# Configuration Cache causes issues with plugin publishing.
77
# Do continue to make our Gradle plugins (GU, FG7, etc.) support it though.
8-
org.gradle.configuration-cache=false
9-
org.gradle.configuration-cache.parallel=false
8+
#org.gradle.configuration-cache=true
9+
#org.gradle.configuration-cache.parallel=true
10+
11+
systemProp.org.gradle.unsafe.suppress-gradle-api=true

gradle/gradle-daemon-jvm.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#This file is generated by updateDaemonJvm
2+
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/65aaef917b9f394804f058f1861225c9/redirect
3+
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/c728c5388b044fbdbbc44b0c6acee0df/redirect
4+
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/65aaef917b9f394804f058f1861225c9/redirect
5+
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/c728c5388b044fbdbbc44b0c6acee0df/redirect
6+
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/dc463b4a8183dbcaa1b32544189c7f03/redirect
7+
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/cb7dc109dd590ebca2d703734d23c9d3/redirect
8+
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/65aaef917b9f394804f058f1861225c9/redirect
9+
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/c728c5388b044fbdbbc44b0c6acee0df/redirect
10+
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/43ee83889b87bacad5d3071ae7bbd349/redirect
11+
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/2d57bdd1e17a18f83ff073919daa35ba/redirect
12+
toolchainVersion=17

gradle/wrapper/gradle-wrapper.jar

243 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -203,7 +205,7 @@ fi
203205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204206

205207
# Collect all arguments for the java command:
206-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207209
# and any embedded shellness will be escaped.
208210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209211
# treated as '${Hostname}' itself on the command line.

gradlew.bat

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
4345
%JAVA_EXE% -version >NUL 2>&1
4446
if %ERRORLEVEL% equ 0 goto execute
4547

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
5153

5254
goto fail
5355

@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5759

5860
if exist "%JAVA_EXE%" goto execute
5961

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
6567

6668
goto fail
6769

settings.gradle

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
1+
import org.gradle.api.initialization.resolve.RepositoriesMode
2+
13
plugins {
2-
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
4+
id 'dev.gradleplugins.gradle-plugin-development' version '1.9.0'
5+
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.10.0'
36
}
47

58
rootProject.name = 'gradleutils'
69

7-
apply from: 'settings_shared.gradle'
10+
dependencyResolutionManagement {
11+
// Repositories are located in build.gradle for this project
12+
// dev.gradleplugins.groovy-gradle-plugin is bugged and force adds repositories on the project
13+
// so, we can't declare the repositories in here
14+
repositoriesMode = RepositoriesMode.PREFER_PROJECT
15+
16+
versionCatalogs.register('libs') {
17+
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0'
18+
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '2.5.1'
19+
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '1.3.1'
20+
plugin 'shadow', 'com.gradleup.shadow' version '9.0.0-beta13'
21+
22+
// Gradle API
23+
version 'gradle', '7.3'
24+
25+
// Static Analysis
26+
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2'
27+
28+
// GitHub Actions Workflows
29+
library 'yaml', 'org.yaml', 'snakeyaml' version '2.4'
30+
31+
// Git Version
32+
library 'gitver', 'net.minecraftforge', 'gitversion' version '0.5.2'
33+
34+
// Backwards compatibility
35+
library 'jgit', 'org.eclipse.jgit', 'org.eclipse.jgit' version '7.2.0.202503040940-r'
36+
}
37+
}

0 commit comments

Comments
 (0)