Skip to content

Commit 540dbb9

Browse files
committed
Build ourselves using GradleUtils 3.3.18
1 parent 964d90e commit 540dbb9

File tree

8 files changed

+109
-85
lines changed

8 files changed

+109
-85
lines changed

.github/workflows/publish.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ name: Publish
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ 'GU_2.6' ]
6+
paths-ignore:
7+
- '.github/workflows/**'
8+
- 'docs/**'
9+
- 'README.md'
610

711
permissions:
812
contents: read
913

1014
jobs:
1115
build:
12-
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main
16+
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@v0
1317
with:
1418
java: 17
15-
gradle_tasks: "publish publishPlugins"
16-
artifact_name: "gradleutils"
19+
gradle_tasks: 'check publish publishPlugins'
1720
secrets:
1821
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
1922
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}

build.gradle

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22

33
plugins {
4-
id 'dev.gradleplugins.groovy-gradle-plugin'
4+
id 'java-gradle-plugin'
5+
id 'groovy'
56
id 'idea'
67
id 'eclipse'
78
id 'maven-publish'
9+
alias libs.plugins.versions
810
alias libs.plugins.licenser
911
alias libs.plugins.gradleutils
12+
alias libs.plugins.gitversion
13+
alias libs.plugins.changelog
1014
alias libs.plugins.plugin.publish
1115
alias libs.plugins.shadow
1216
}
1317

14-
final projectDisplayName = 'Forge Gradle Utilities'
15-
description = 'Small collection of utilities for standardizing MinecraftForge gradle scripts'
18+
gradleutils.displayName = 'Forge Gradle Utilities'
19+
description = "Small collection of utilities for standardizing Forge's buildscripts."
1620
group = 'net.minecraftforge'
1721
version = gitversion.tagOffset
1822

1923
println "Version: $version"
2024

2125
// Git Version requires Java 17
22-
java.toolchain.languageVersion = JavaLanguageVersion.of 17
26+
java {
27+
toolchain.languageVersion = JavaLanguageVersion.of(17)
28+
withSourcesJar()
29+
withJavadocJar()
30+
}
31+
32+
gradleutils.pluginDevDefaults(configurations, libs.versions.gradle)
2333

2434
configurations {
2535
named(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME) {
@@ -28,15 +38,16 @@ configurations {
2838
}
2939
}
3040

31-
repositories {
32-
maven { url = 'https://maven.minecraftforge.net' }
33-
mavenCentral()
34-
}
35-
3641
dependencies {
3742
// Static Analysis
3843
compileOnly libs.nulls
3944

45+
// Gradle API
46+
compileOnly libs.gradle
47+
48+
// Versions Plugin
49+
compileOnly libs.gradle.versions
50+
4051
// GitHub Actions Workflows
4152
implementation libs.yaml
4253

@@ -47,59 +58,55 @@ dependencies {
4758
implementation libs.jgit
4859
}
4960

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-
}
59-
6061
license {
61-
header = rootProject.file 'LICENSE-header.txt'
62+
header = rootProject.file('LICENSE-header.txt')
6263
newLine = false
6364
exclude '**/*.properties'
6465
}
6566

67+
tasks.named('javadoc', Javadoc) {
68+
// Groovydoc is used instead
69+
enabled = false
70+
}
71+
72+
tasks.named('groovydoc', Groovydoc) {
73+
use = true
74+
}
75+
6676
tasks.named('jar', Jar) {
6777
archiveClassifier = 'thin'
6878
}
6979

7080
tasks.named('shadowJar', ShadowJar) {
71-
enableRelocation = true
81+
enableAutoRelocation = true
7282
archiveClassifier = null
7383
relocationPrefix = 'net.minecraftforge.gradleutils.shadow'
7484
}
7585

76-
tasks.withType(GroovyCompile).configureEach {
77-
groovyOptions.optimizationOptions.indy = true
86+
// javadocJar is created after evaluation, so we need to configure it here
87+
afterEvaluate {
88+
tasks.named('javadocJar', Jar) {
89+
final groovydoc = tasks.named('groovydoc', Groovydoc)
90+
91+
dependsOn = [groovydoc]
92+
archiveClassifier = 'groovydoc'
93+
from groovydoc.map(Groovydoc.&getDestinationDir)
94+
}
7895
}
7996

8097
changelog {
8198
fromBase()
82-
publishAll = false
8399
}
84100

85101
gradlePlugin {
86102
website.set gitversion.url
87103
vcsUrl.set gitversion.url + '.git'
88104

89-
compatibility {
90-
minimumGradleVersion = libs.versions.gradle.get()
91-
}
92-
93-
groovy {
94-
withSourcesJar()
95-
withGroovydocJar()
96-
}
97-
98105
plugins {
99106
register('gradleutils') {
100107
id = 'net.minecraftforge.gradleutils'
101108
implementationClass = 'net.minecraftforge.gradleutils.GradleUtilsPlugin'
102-
displayName = projectDisplayName
109+
displayName = project.gradleutils.displayName.get() // project. before gradleutils otherwise it would reference itself
103110
description = project.description
104111
tags = ['minecraftforge']
105112
}
@@ -114,16 +121,19 @@ gradlePlugin {
114121
}
115122

116123
publishing {
117-
publications.register('pluginMaven', MavenPublication) {
118-
artifactId = project.name
124+
repositories {
125+
maven gradleutils.publishingForgeMaven
126+
}
119127

120-
changelog.publish it
128+
publications.register('pluginMaven', MavenPublication) {
129+
changelog.publish(it)
130+
gradleutils.promote(it)
121131

122132
pom { pom ->
123-
name = projectDisplayName
133+
name = gradleutils.displayName
124134
description = project.description
125135

126-
gradleutils.pom.setGitHubDetails pom
136+
gradleutils.pom.addRemoteDetails(pom)
127137

128138
licenses {
129139
license gradleutils.pom.licenses.LGPLv2_1
@@ -138,10 +148,4 @@ publishing {
138148
}
139149
}
140150
}
141-
142-
repositories {
143-
maven gradleutils.publishingForgeMaven
144-
}
145151
}
146-
147-
idea.module { downloadSources = downloadJavadoc = true }

gradle.properties

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ org.gradle.caching=true
22
org.gradle.parallel=true
33
org.gradle.configureondemand=true
44

5-
# TODO [GradleUtils][Gradle9] Re-enable config cache in Gradle 9
6-
# Configuration Cache causes issues with plugin publishing.
7-
# Do continue to make our Gradle plugins (GU, FG7, etc.) support it though.
8-
#org.gradle.configuration-cache=true
9-
#org.gradle.configuration-cache.parallel=true
5+
org.gradle.configuration-cache=true
6+
org.gradle.configuration-cache.parallel=true
7+
org.gradle.configuration-cache.problems=warn
108

11-
systemProp.org.gradle.unsafe.suppress-gradle-api=true
9+
net.minecraftforge.gradleutils.ide.automatic.sources=true
10+
net.minecraftforge.gradleutils.compilation.defaults=true

gradle/wrapper/gradle-wrapper.jar

59 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.14-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ case "$( uname )" in #(
114114
NONSTOP* ) nonstop=true ;;
115115
esac
116116

117-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
118118

119119

120120
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
213213
set -- \
214214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
215215
-classpath "$CLASSPATH" \
216-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217217
"$@"
218218

219219
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7474

7575

7676
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7878

7979
:end
8080
@rem End local scope for the variables with windows NT shell

settings.gradle

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,55 @@
1-
import org.gradle.api.initialization.resolve.RepositoriesMode
2-
31
plugins {
4-
id 'dev.gradleplugins.gradle-plugin-development' version '1.9.0'
5-
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.10.0'
2+
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
63
}
74

85
rootProject.name = 'gradleutils'
96

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
7+
// Applying plugins causes them to not have any IDE support when also applied to any build.gradle files
8+
// The workaround for now is to use this listener here so that it can stay in settings.gradle
9+
// See: https://youtrack.jetbrains.com/issue/IDEA-332061/Gradle-Missing-Code-Completion-Suggestions-for-Settings-Plugins-in-Groovy-DSL
10+
gradle.beforeProject { Project project ->
11+
project.pluginManager.withPlugin('net.minecraftforge.gradleutils') {
12+
project.repositories {
13+
mavenCentral()
14+
gradlePluginPortal()
15+
maven project.gradleutils.forgeMaven
16+
maven { url = 'https://maven.moddinglegacy.com' } // Gradle API
17+
//mavenLocal()
18+
}
19+
}
20+
}
21+
22+
//@formatter:off
23+
dependencyResolutionManagement.versionCatalogs.register('libs') {
24+
version 'gradle-versions', '0.53.0'
1525

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'
26+
plugin 'versions', 'com.github.ben-manes.versions' versionRef 'gradle-versions'
27+
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0'
28+
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '3.3.18'
29+
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.1.1'
30+
plugin 'changelog', 'net.minecraftforge.changelog' version '3.1.2'
31+
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '2.0.0'
32+
plugin 'shadow', 'com.gradleup.shadow' version '9.2.2'
2133

22-
// Gradle API
23-
version 'gradle', '7.3'
34+
// Static Analysis
35+
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2'
2436

25-
// Static Analysis
26-
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2'
37+
// Gradle API
38+
// Original: https://github.com/remal-gradle-api/packages/packages/760197?version=7.3
39+
// Mirror: https://repos.moddinglegacy.com/#/modding-legacy/name/remal/gradle-api/gradle-api/7.3
40+
version 'gradle', '7.3'
41+
library 'gradle', 'name.remal.gradle-api', 'gradle-api' versionRef 'gradle'
2742

28-
// GitHub Actions Workflows
29-
library 'yaml', 'org.yaml', 'snakeyaml' version '2.4'
43+
// Versions Plugin
44+
library 'gradle-versions', 'com.github.ben-manes.versions', 'com.github.ben-manes.versions.gradle.plugin' versionRef 'gradle-versions'
3045

31-
// Git Version
32-
library 'gitver', 'net.minecraftforge', 'gitversion' version '0.5.2'
46+
// GitHub Actions Workflows
47+
library 'yaml', 'org.yaml', 'snakeyaml' version '2.4'
3348

34-
// Backwards compatibility
35-
library 'jgit', 'org.eclipse.jgit', 'org.eclipse.jgit' version '7.2.0.202503040940-r'
36-
}
49+
// Git Version
50+
library 'gitver', 'net.minecraftforge', 'gitversion' version '0.5.2'
51+
52+
// Backwards compatibility
53+
library 'jgit', 'org.eclipse.jgit', 'org.eclipse.jgit' version '7.2.0.202503040940-r'
3754
}
55+
//@formatter:on

0 commit comments

Comments
 (0)