Skip to content

Commit be6d5e2

Browse files
committed
Gradle 9, independence from AT plugin, major update to DSL
This major update to the ForgeGradle 7 Beta introduces the Gradle 9 requirement and is now completely built on Java, instead of being a Java/Groovy mixture. There are two major changes beta testers should be aware of. First, the `net.minecraftforge.accesstransformers` plugin *must be applied* before ForgeGradle in order to use AccessTransformers. Additionally, ATs must be declared within the Minecraft dependency itself, not within the Minecraft extension block. ```groovy dependencies { implementation minecraft.dep(libs.forge) { accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') } } ``` Additionally, mappings can be declared either within the Minecraft extension or in the Minecraft dependency, with priority given to the latter. Second, this update now includes **very experimental** support for drop-in replacing the tools used by ForgeGradle, which are currently the Minecraft Mavenizer and Slime Launcher. Things could break and the implementation is very ugly, but will be stabilized in due time. Also, there is currently no IDE linting supported (because Gradle sucks). ```groovy fgtools { mavenizer { classpath = 'me.jonathing:mavenizer:1.0.0' } } ``` There is currently no other documentation on this and should be used at your own risk if you want to test custom versions of the mavenizer and launcher. Everything you need will be found in `net.minecraftforge.gradle.ToolsExtension` and `net.minecraftforge.gradle.ToolsDefinition`.
1 parent 7d7f525 commit be6d5e2

File tree

56 files changed

+3097
-3512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3097
-3512
lines changed

build.gradle

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
//import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin
23
import org.gradle.api.attributes.plugin.GradlePluginApiVersion
34

4-
// TODO [Jonathan][ForgeGradle7][Publishing] Re-enable the shadow jar once the AT Plugin dependency is figured out
5-
65
plugins {
76
id 'java-gradle-plugin'
8-
id 'groovy'
97
id 'idea'
8+
id 'eclipse'
109
id 'maven-publish'
10+
id 'io.freefair.javadoc-links'
11+
id 'net.minecraftforge.gradleutils'
12+
alias libs.plugins.gitversion
13+
alias libs.plugins.changelog
1114
alias libs.plugins.licenser
12-
alias libs.plugins.gradleutils
13-
alias libs.plugins.javadoc.links
14-
//alias libs.plugins.shadow
15+
alias libs.plugins.plugin.publish
16+
alias libs.plugins.shadow
1517
}
1618

1719
final projectDisplayName = 'ForgeGradle'
18-
final projectArtifactId = base.archivesName = 'forgegradle'
1920
description = "Forge's Gradle plugin for Mod development"
21+
base.archivesName = 'forgegradle'
2022
group = 'net.minecraftforge'
2123
version = gitversion.tagOffset
2224

2325
println "Version: $version"
2426

2527
java {
26-
// Gradle 9 will require Java 17
2728
toolchain.languageVersion = JavaLanguageVersion.of 17
2829
withSourcesJar()
2930
withJavadocJar()
@@ -38,74 +39,63 @@ configurations {
3839
}
3940
}
4041

41-
applyGradleVersionAttribute(apiElements)
42-
applyGradleVersionAttribute(runtimeElements)
43-
//applyGradleVersionAttribute(shadowRuntimeElements)
42+
named(JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME, applyGradleVersionAttribute)
43+
named(ShadowJavaPlugin.SHADOW_RUNTIME_ELEMENTS_CONFIGURATION_NAME, applyGradleVersionAttribute)
4444
}
4545

4646
dependencies {
47+
// Static Analysis
48+
compileOnly libs.nulls
49+
4750
// Gradle API
4851
compileOnly libs.gradle
49-
compileOnly libs.nulls
52+
53+
// GradleUtils Shared Base
54+
implementation libs.gradleutils.shared
5055

5156
// AccessTransformers
52-
runtimeOnly libs.accesstransformers.plugin
53-
compileOnlyApi libs.accesstransformers.binary
57+
compileOnlyApi libs.accesstransformers.gradle
5458

5559
// Utils
5660
implementation libs.bundles.utils
5761
}
5862

59-
/*
6063
// Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
61-
// TODO [GradleUtils][GradleAPI] Remove this once they are fixed.
6264
// Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260
6365
// Shadow: https://github.com/GradleUp/shadow/pull/1422
6466
afterEvaluate { project ->
6567
project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { compileOnly ->
66-
compileOnly.dependencies.remove project.dependencies.gradleApi()
68+
compileOnly.dependencies.remove(project.dependencies.gradleApi())
6769
}
6870
}
69-
*/
7071

7172
license {
7273
header = rootProject.file('LICENSE-header.txt')
7374
newLine = false
7475
exclude '**/*.properties'
7576
}
7677

77-
/*
7878
tasks.named('jar', Jar) {
7979
archiveClassifier = 'thin'
8080
}
8181

8282
tasks.named('shadowJar', ShadowJar) {
83-
enableRelocation = true
83+
enableAutoRelocation = true
8484
archiveClassifier = null
8585
relocationPrefix = 'net.minecraftforge.gradle.shadow'
86-
87-
dependencies {
88-
libs.bundles.accesstransformers.get().collect { exclude dependency(it) }
89-
}
90-
}
91-
*/
92-
93-
tasks.withType(GroovyCompile).configureEach {
94-
groovyOptions.optimizationOptions.indy = true
9586
}
9687

9788
tasks.withType(Javadoc).configureEach {
98-
javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of 24 }
89+
javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(24) }
9990

10091
options { StandardJavadocDocletOptions options ->
10192
options.windowTitle = projectDisplayName + project.version
102-
options.tags 'apiNote:a:API Note:', 'implNote:a:Implementation Note:'
93+
options.tags 'apiNote:a:API Note:', 'implNote:a:Implementation Note:', 'implSpec:a:Implementation Requirements:'
10394
}
10495
}
10596

10697
changelog {
10798
fromBase()
108-
publishAll = false
10999
}
110100

111101
gradlePlugin {
@@ -117,26 +107,24 @@ gradlePlugin {
117107
implementationClass = 'net.minecraftforge.gradle.ForgeGradlePlugin'
118108
displayName = projectDisplayName
119109
description = project.description
110+
tags = ['minecraftforge', 'minecraft']
120111
}
121112
}
122113

123-
/*
124-
// Allows the thin jar to be published, but won't be considered as the java-runtime variant in the module
125-
// This forces Gradle to use the fat jar when applying the plugin
126-
(components.java as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations.runtimeElements) {
127-
skip()
128-
}
129-
*/
130-
131114
publishing {
115+
repositories {
116+
maven gradleutils.publishingForgeMaven
117+
}
118+
132119
publications.register('pluginMaven', MavenPublication) {
133-
artifactId = projectArtifactId
120+
changelog.publish(it)
121+
gradleutils.promote(it)
134122

135123
pom { pom ->
136124
name = projectDisplayName
137125
description = project.description
138126

139-
gradleutils.pom.setGitHubDetails pom
127+
gradleutils.pom.addRemoteDetails(pom)
140128

141129
licenses {
142130
license gradleutils.pom.licenses.LGPLv2_1
@@ -147,10 +135,7 @@ publishing {
147135
}
148136
}
149137
}
150-
151-
repositories {
152-
maven gradleutils.publishingForgeMaven
153-
}
154138
}
155139

156140
idea.module { downloadSources = downloadJavadoc = true }
141+
eclipse.classpath { downloadSources = downloadJavadoc = true }

gradle.properties

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ 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

119
systemProp.org.gradle.unsafe.suppress-gradle-api=true

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

settings.gradle

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
plugins {
2-
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.10.0'
2+
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0' // https://plugins.gradle.org/plugin/org.gradle.toolchains.foojay-resolver-convention
3+
4+
// NOTE: We need to load this into the classpath before GradleUtils for the service to load correctly
5+
id 'io.freefair.javadoc-links' version '8.14' apply false // https://plugins.gradle.org/plugin/io.freefair.javadoc-links
6+
7+
id 'net.minecraftforge.gradleutils' version '3.2.5' // https://plugins.gradle.org/plugin/net.minecraftforge.gradleutils
38
}
49

510
rootProject.name = 'forgegradle'
611

712
dependencyResolutionManagement {
813
repositories {
9-
maven { url = 'https://maven.minecraftforge.net/' }
10-
maven { url = 'https://maven.moddinglegacy.com/maven' } // Gradle API
11-
mavenCentral()
1214
//mavenLocal()
15+
mavenCentral()
16+
maven gradleutils.forgeMaven
17+
maven { url = 'https://maven.moddinglegacy.com/maven' } // Gradle API
1318
}
1419

1520
//@formatter:off
1621
versionCatalogs.register('libs') {
17-
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.licenser
18-
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '2.6.0' // https://plugins.gradle.org/plugin/net.minecraftforge.gradleutils
19-
plugin 'javadoc-links', 'io.freefair.javadoc-links' version '8.13.1' // https://plugins.gradle.org/plugin/io.freefair.javadoc-links
20-
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '1.3.1' // https://plugins.gradle.org/plugin/com.gradle.plugin-publish
21-
plugin 'shadow', 'com.gradleup.shadow' version '9.0.0-beta15' // https://plugins.gradle.org/plugin/com.gradleup.shadow
22+
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.licenser
23+
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.0.3' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
24+
plugin 'changelog', 'net.minecraftforge.changelog' version '3.0.3' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
25+
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '1.3.1' // https://plugins.gradle.org/plugin/com.gradle.plugin-publish
26+
plugin 'shadow', 'com.gradleup.shadow' version '9.0.2' // https://plugins.gradle.org/plugin/com.gradleup.shadow
27+
28+
// Static Analysis
29+
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2'
2230

2331
// Gradle API
24-
// TODO [ForgeGradle][FG7][Gradle Api] REMOVE once Gradle publish their own API artifacts
25-
// Original: https://github.com/remal-gradle-api/packages/packages/760197
26-
// Mirror: https://maven.moddinglegacy.com/#browse/browse:maven-public:name%2Fremal%2Fgradle-api%2Fgradle-api%2F8.14.1
27-
version 'gradle', '8.14.1'
32+
// Original: https://github.com/remal-gradle-api/packages/packages/760197?version=9.0.0
33+
// Mirror: https://repos.moddinglegacy.com/#/modding-legacy/name/remal/gradle-api/gradle-api/9.0.0
34+
version 'gradle', '9.0.0'
2835
library 'gradle', 'name.remal.gradle-api', 'gradle-api' versionRef 'gradle'
29-
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2'
36+
37+
// GradleUtils Shared Base
38+
library 'gradleutils-shared', 'net.minecraftforge', 'gradleutils-shared' version '3.2.5'
3039

3140
// AccessTransformers Gradle Plugin
3241
// https://plugins.gradle.org/plugin/net.minecraftforge.accesstransformers
33-
version 'accesstransformers', '1.0.1'
34-
library 'accesstransformers-plugin', 'net.minecraftforge.accesstransformers', 'net.minecraftforge.accesstransformers.gradle.plugin' versionRef 'accesstransformers'
35-
library 'accesstransformers-binary', 'net.minecraftforge', 'accesstransformers-gradle' versionRef 'accesstransformers'
36-
bundle 'accesstransformers', ['accesstransformers-plugin', 'accesstransformers-binary']
42+
library 'accesstransformers-gradle', 'net.minecraftforge.accesstransformers', 'net.minecraftforge.accesstransformers.gradle.plugin' version '3.0.0'
3743

3844
library 'utils-data', 'net.minecraftforge', 'json-data-utils' version '0.2.1' // https://files.minecraftforge.net/net/minecraftforge/json-data-utils/index.html
3945
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.1.9' // https://files.minecraftforge.net/net/minecraftforge/hash-utils/index.html

0 commit comments

Comments
 (0)