Skip to content

Commit 14206fa

Browse files
authored
Update buildscript to use external Gradle API (#1002)
I've confirmed all publish artifacts to be identical to the original (with the exception of nullable annotations). - The workspace is in Gradle 9.2.0 now, but uses an external Gradle 8.1 API dependency to target. - Cleaned up the dependency tree. There is no need to exclude ASM from all dependencies. - Switched nulls to JetBrains for consistency. - Don't apply the plugin publish plugin as we are not publishing ForgeGradle 6.0 to the Plugin Portal.
1 parent 2ed7557 commit 14206fa

File tree

110 files changed

+525
-510
lines changed

Some content is hidden

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

110 files changed

+525
-510
lines changed

build.gradle

Lines changed: 118 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,172 @@
11
plugins {
22
id 'java-gradle-plugin'
3+
id 'idea'
34
id 'eclipse'
45
id 'maven-publish'
5-
id 'net.minecraftforge.licenser' version '1.0.1'
6-
id 'net.minecraftforge.gradleutils' version '[2.3,2.4)'
7-
id 'com.github.ben-manes.versions' version '0.46.0'
6+
alias libs.plugins.gradleutils
7+
alias libs.plugins.gitversion
8+
alias libs.plugins.changelog
9+
alias libs.plugins.licenser
810
}
911

10-
version = gradleutils.getTagOffsetBranchVersion('FG_6.0')
11-
logger.lifecycle('Version: ' + version + ' Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
12+
gradleutils.displayName = 'ForgeGradle'
13+
description = "Forge's Gradle plugin for Mod development"
14+
group = 'net.minecraftforge.gradle'
15+
version = gitversion.tagOffset
1216

13-
changelog {
14-
from '6.0'
15-
publishAll = false
16-
}
17-
sourceSets {
18-
common
19-
mcp
20-
patcher
21-
userdev
22-
}
17+
println "Version: $version"
2318

2419
java {
2520
toolchain.languageVersion = JavaLanguageVersion.of(8)
2621
withSourcesJar()
2722
}
2823

29-
configurations {
30-
configureEach {
31-
exclude group: 'org.ow2.asm'
24+
sourceSets {
25+
register('common')
26+
27+
register('mcp') {
28+
configurations.named(implementationConfigurationName) {
29+
extendsFrom configurations.getByName(common.implementationConfigurationName)
30+
}
31+
32+
configurations.named(compileOnlyConfigurationName) {
33+
extendsFrom configurations.getByName(common.compileOnlyConfigurationName)
34+
}
3235
}
33-
mcpImplementation.extendsFrom commonImplementation
34-
patcherImplementation.extendsFrom commonImplementation
35-
userdevImplementation.extendsFrom mcpImplementation
36-
implementation.extendsFrom mcpImplementation, patcherImplementation, userdevImplementation
37-
}
3836

39-
tasks.named('jar', Jar).configure {
40-
from sourceSets.common.output
41-
from sourceSets.mcp.output
42-
from sourceSets.patcher.output
43-
from sourceSets.userdev.output
44-
}
37+
register('patcher') {
38+
configurations.named(implementationConfigurationName) {
39+
extendsFrom configurations.getByName(common.implementationConfigurationName)
40+
}
4541

46-
tasks.named('sourcesJar', Jar).configure {
47-
from sourceSets.common.allJava
48-
from sourceSets.mcp.allJava
49-
from sourceSets.patcher.allJava
50-
from sourceSets.userdev.allJava
51-
}
42+
configurations.named(compileOnlyConfigurationName) {
43+
extendsFrom configurations.getByName(common.compileOnlyConfigurationName)
44+
}
45+
}
5246

53-
repositories {
54-
mavenLocal()
55-
maven gradleutils.forgeMaven
56-
}
47+
register('userdev') {
48+
configurations.named(implementationConfigurationName) {
49+
extendsFrom configurations.getByName(mcp.implementationConfigurationName)
50+
}
5751

58-
license {
59-
header = file('HEADER')
60-
exclude '**/*.properties'
61-
exclude 'net/minecraftforge/gradle/common/diff/'
62-
exclude 'net/minecraftforge/gradle/common/util/JavaVersionParser.java'
63-
}
52+
configurations.named(compileOnlyConfigurationName) {
53+
extendsFrom configurations.getByName(mcp.compileOnlyConfigurationName)
54+
}
55+
}
56+
57+
named('main') {
58+
configurations.named(implementationConfigurationName) {
59+
extendsFrom(
60+
configurations.getByName(mcp.implementationConfigurationName),
61+
configurations.getByName(patcher.implementationConfigurationName),
62+
configurations.getByName(userdev.implementationConfigurationName),
63+
)
64+
}
6465

65-
tasks.named('wrapper', Wrapper).configure {
66-
gradleVersion = '8.4'
67-
distributionType = Wrapper.DistributionType.ALL
66+
configurations.named(compileOnlyConfigurationName) {
67+
extendsFrom(
68+
configurations.getByName(mcp.compileOnlyConfigurationName),
69+
configurations.getByName(patcher.compileOnlyConfigurationName),
70+
configurations.getByName(userdev.compileOnlyConfigurationName),
71+
)
72+
}
73+
}
6874
}
6975

7076
dependencies {
71-
commonImplementation gradleApi()
72-
commonImplementation 'commons-io:commons-io:2.11.0'
73-
commonImplementation 'com.google.code.gson:gson:2.10.1'
74-
commonImplementation 'com.google.guava:guava:31.1-jre'
75-
commonImplementation 'de.siegmar:fastcsv:2.2.1'
76-
commonImplementation('net.minecraftforge:artifactural:3.0.20') {
77+
commonCompileOnly libs.nulls
78+
79+
commonCompileOnly libs.gradle
80+
81+
commonImplementation libs.commons.io
82+
commonImplementation libs.gson
83+
commonImplementation libs.guava
84+
commonImplementation libs.fastcsv
85+
commonImplementation(libs.artifactural) {
7786
transitive = false
7887
}
79-
commonImplementation('net.minecraftforge:unsafe:0.2.0') {
88+
commonImplementation(libs.unsafe) {
8089
transitive = false
8190
}
82-
commonImplementation 'org.apache.maven:maven-artifact:3.9.1'
83-
commonImplementation 'org.apache.httpcomponents:httpclient:4.5.14'
84-
commonImplementation 'net.minecraftforge:srgutils:0.5.10'
85-
commonImplementation 'net.minecraftforge:DiffPatch:2.0.12:all'
91+
commonImplementation libs.maven.artifact
92+
commonImplementation libs.httpclient
93+
commonImplementation libs.srgutils
94+
commonImplementation variantOf(libs.diffpatch) { classifier 'all' }
8695

8796
mcpImplementation sourceSets.common.output
8897
patcherImplementation sourceSets.mcp.output
8998
patcherImplementation sourceSets.common.output
9099
userdevImplementation sourceSets.mcp.output
91100
userdevImplementation sourceSets.common.output
92101

93-
userdevImplementation 'net.minecraftforge:JarJarMetadata:0.3.19'
94-
userdevImplementation 'net.minecraftforge:JarJarSelector:0.3.19'
102+
userdevImplementation libs.jarjar.metadata
103+
userdevImplementation libs.jarjar.selector
104+
}
105+
106+
license {
107+
header = rootProject.file('HEADER')
108+
exclude '**/*.properties'
109+
exclude 'net/minecraftforge/gradle/common/diff/'
110+
exclude 'net/minecraftforge/gradle/common/util/JavaVersionParser.java'
111+
}
112+
113+
tasks.named('jar', Jar) {
114+
from sourceSets.common.output
115+
from sourceSets.mcp.output
116+
from sourceSets.patcher.output
117+
from sourceSets.userdev.output
118+
}
119+
120+
tasks.named('sourcesJar', Jar) {
121+
from sourceSets.common.allJava
122+
from sourceSets.mcp.allJava
123+
from sourceSets.patcher.allJava
124+
from sourceSets.userdev.allJava
125+
}
126+
127+
changelog {
128+
from '6.0'
95129
}
96130

97131
gradlePlugin {
132+
website = gitversion.url
133+
vcsUrl = gitversion.url + '.git'
134+
98135
plugins {
99-
mcp {
136+
register('mcp') {
100137
id = 'net.minecraftforge.gradle.mcp'
101138
implementationClass = 'net.minecraftforge.gradle.mcp.MCPPlugin'
102139
}
103-
patcher {
140+
141+
register('patcher') {
104142
id = 'net.minecraftforge.gradle.patcher'
105143
implementationClass = 'net.minecraftforge.gradle.patcher.PatcherPlugin'
106144
}
107-
userdev {
145+
146+
register('userdev') {
108147
id = 'net.minecraftforge.gradle'
109148
implementationClass = 'net.minecraftforge.gradle.userdev.UserDevPlugin'
149+
displayName = gradleutils.displayName.get()
150+
description = project.description
151+
tags = ['minecraftforge', 'minecraft']
110152
}
111153
}
112-
automatedPublishing = true
113154
}
114155

115156
publishing {
116-
publications {
117-
pluginMaven(MavenPublication) {
118-
// Automated publishing declares the java component for us
157+
repositories {
158+
maven gradleutils.publishingForgeMaven
159+
}
119160

120-
project.changelog.publish(it)
161+
publications.register('pluginMaven', MavenPublication) {
162+
changelog.publish(it)
163+
gradleutils.promote(it)
164+
165+
pom { pom ->
166+
name = gradleutils.displayName
167+
description = project.description
168+
169+
gradleutils.pom.addRemoteDetails(pom)
121170
}
122171
}
123-
repositories {
124-
maven gradleutils.getPublishingForgeMaven()
125-
}
126172
}

gradle.properties

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
group=net.minecraftforge.gradle
1+
org.gradle.caching=true
2+
org.gradle.parallel=true
3+
org.gradle.configureondemand=true
4+
5+
org.gradle.configuration-cache=true
6+
org.gradle.configuration-cache.parallel=true
7+
org.gradle.configuration-cache.problems=warn
8+
9+
systemProp.org.gradle.unsafe.suppress-gradle-api=true
10+
11+
net.minecraftforge.gradleutils.ide.automatic.sources=true
12+
net.minecraftforge.gradleutils.compilation.defaults=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.4-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)