Skip to content

Commit b253454

Browse files
committed
Update to FG6, Gradle 8.8, clean up some buildscript jank
1 parent 3641903 commit b253454

File tree

6 files changed

+188
-166
lines changed

6 files changed

+188
-166
lines changed

build.gradle

Lines changed: 46 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
buildscript {
2-
repositories {
3-
maven { url = 'https://maven.minecraftforge.net' }
4-
maven { url = 'https://maven.parchmentmc.org' }
5-
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
6-
mavenCentral()
7-
mavenLocal()
8-
}
9-
1+
buildscript{
102
dependencies {
11-
classpath "net.minecraftforge.gradle:ForgeGradle:5.1.+"
123
classpath 'org.parchmentmc:librarian:1.+'
134
}
145
}
@@ -17,26 +8,27 @@ plugins {
178
id "idea"
189
id "eclipse"
1910
id "maven-publish"
11+
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
12+
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
2013
}
2114

22-
apply plugin: "net.minecraftforge.gradle"
23-
apply plugin: 'org.parchmentmc.librarian.forgegradle'
24-
2515
var envVersion = System.getenv("VERSION") ?: "9.9.9"
2616
if (envVersion.startsWith("v"))
2717
envVersion = envVersion.trimStart('v')
2818

19+
var RUNNING_IN_CI = true // System.getenv().containsKey("CI") ?: false
20+
2921
archivesBaseName = mod_id
3022
group = "dev.compactmods.compactmachines"
3123
version = envVersion
3224

33-
tasks.create("mcVersion") {
25+
tasks.register("mcVersion") {
3426
doFirst {
3527
println("version=$minecraft_version")
3628
}
3729
}
3830

39-
tasks.create("forgeVersion") {
31+
tasks.register("forgeVersion") {
4032
doFirst {
4133
println("version=$forge_version")
4234
}
@@ -88,7 +80,6 @@ sourceSets {
8880
}
8981
}
9082

91-
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
9283
minecraft {
9384
mappings channel: 'parchment', version: parchment_version
9485
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
@@ -98,8 +89,8 @@ minecraft {
9889
// Default run configurations.
9990
// These can be tweaked, removed, or duplicated as needed.
10091
runs {
101-
client {
102-
workingDirectory project.file('run/client')
92+
data {
93+
workingDirectory project.file('run')
10394

10495
// Recommended logging data for a userdev environment
10596
property 'forge.logging.markers', '' // 'SCAN,REGISTRIES,REGISTRYDUMP'
@@ -110,35 +101,41 @@ minecraft {
110101
property 'mixin.env.remapRefMap', 'true'
111102
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
112103

104+
args '--mod', mod_id
105+
args '--existing', file('src/main/resources')
106+
args '--all'
107+
args '--output', file('src/generated/resources/')
108+
113109
if(!System.getenv().containsKey("CI")) {
114110
// JetBrains Runtime Hotswap
115111
jvmArg '-XX:+AllowEnhancedClassRedefinition'
116112
jvmArg '-XX:HotswapAgent=fatjar'
117113
}
118114

119-
args '--username', 'Nano'
120-
args '--width', 1920
121-
args '--height', 1080
122-
123115
mods {
124116
compactmachines {
125117
source sourceSets.tunnels
126118
source sourceSets.main
127119
source sourceSets.api
120+
source sourceSets.datagen
128121
}
129122
}
130123
}
131124

132-
server {
133-
workingDirectory project.file('run/server')
125+
gameTestServer {
126+
workingDirectory project.file('run/gametest')
134127

135128
// Recommended logging data for a userdev environment
136-
property 'forge.logging.markers', '' // 'SCAN,REGISTRIES,REGISTRYDUMP'
129+
// The markers can be added/remove as needed separated by commas.
130+
// "SCAN": For mods scan.
131+
// "REGISTRIES": For firing of registry events.
132+
// "REGISTRYDUMP": For getting the contents of all registries.
133+
property 'forge.logging.markers', ''
137134

138135
// Recommended logging level for the console
139-
property 'forge.logging.console.level', 'debug'
140-
141-
property 'forge.enabledGameTestNamespaces', mod_id
136+
// You can set various levels here.
137+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
138+
property 'forge.logging.console.level', 'info'
142139

143140
property 'mixin.env.remapRefMap', 'true'
144141
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
@@ -148,19 +145,23 @@ minecraft {
148145
jvmArg '-XX:+AllowEnhancedClassRedefinition'
149146
jvmArg '-XX:HotswapAgent=fatjar'
150147
}
151-
148+
152149
mods {
153150
compactmachines {
154151
source sourceSets.tunnels
155-
source sourceSets.main
156152
source sourceSets.api
153+
source sourceSets.main
157154
source sourceSets.test
158155
}
159156
}
160157
}
158+
}
159+
}
161160

162-
data {
163-
workingDirectory project.file('run')
161+
if(!RUNNING_IN_CI) {
162+
minecraft.runs {
163+
client {
164+
workingDirectory project.file('run/client')
164165

165166
// Recommended logging data for a userdev environment
166167
property 'forge.logging.markers', '' // 'SCAN,REGISTRIES,REGISTRYDUMP'
@@ -171,62 +172,50 @@ minecraft {
171172
property 'mixin.env.remapRefMap', 'true'
172173
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
173174

174-
args '--mod', mod_id
175-
args '--existing', file('src/main/resources')
176-
args '--all'
177-
args '--output', file('src/generated/resources/')
178-
179-
if(!System.getenv().containsKey("CI")) {
175+
if(!RUNNING_IN_CI) {
180176
// JetBrains Runtime Hotswap
181177
jvmArg '-XX:+AllowEnhancedClassRedefinition'
182178
jvmArg '-XX:HotswapAgent=fatjar'
183-
} else {
184-
forceExit false
185179
}
186180

187-
forceExit false
181+
args '--username', 'Nano'
182+
args '--width', 1920
183+
args '--height', 1080
188184

189185
mods {
190186
compactmachines {
191187
source sourceSets.tunnels
192188
source sourceSets.main
193189
source sourceSets.api
194-
source sourceSets.datagen
195190
}
196191
}
197192
}
198193

199-
gameTestServer {
200-
workingDirectory project.file('run/gametest')
194+
server {
195+
workingDirectory project.file('run/server')
201196

202197
// Recommended logging data for a userdev environment
203-
// The markers can be added/remove as needed separated by commas.
204-
// "SCAN": For mods scan.
205-
// "REGISTRIES": For firing of registry events.
206-
// "REGISTRYDUMP": For getting the contents of all registries.
207-
property 'forge.logging.markers', ''
198+
property 'forge.logging.markers', '' // 'SCAN,REGISTRIES,REGISTRYDUMP'
208199

209200
// Recommended logging level for the console
210-
// You can set various levels here.
211-
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
212-
property 'forge.logging.console.level', 'info'
201+
property 'forge.logging.console.level', 'debug'
202+
203+
property 'forge.enabledGameTestNamespaces', mod_id
213204

214205
property 'mixin.env.remapRefMap', 'true'
215206
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
216207

217-
forceExit false
218-
219-
if(!System.getenv().containsKey("CI")) {
208+
if(!RUNNING_IN_CI) {
220209
// JetBrains Runtime Hotswap
221210
jvmArg '-XX:+AllowEnhancedClassRedefinition'
222211
jvmArg '-XX:HotswapAgent=fatjar'
223212
}
224-
213+
225214
mods {
226215
compactmachines {
227216
source sourceSets.tunnels
228-
source sourceSets.api
229217
source sourceSets.main
218+
source sourceSets.api
230219
source sourceSets.test
231220
}
232221
}

gradle/wrapper/gradle-wrapper.jar

-15.7 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015-2021 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
3232
# Busybox and similar reduced shells will NOT work, because this script
3333
# requires all of these POSIX shell features:
3434
# * functions;
35-
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36-
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37-
# * compound commands having a testable exit status, especially «case»;
38-
# * various built-in commands including «command», «set», and «ulimit».
35+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37+
# * compound commands having a testable exit status, especially «case»;
38+
# * various built-in commands including «command», «set», and «ulimit».
3939
#
4040
# Important for patching:
4141
#
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
8080
esac
8181
done
8282

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
83+
# This is normally unused
84+
# shellcheck disable=SC2034
8685
APP_BASE_NAME=${0##*/}
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# 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
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
147+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148+
# shellcheck disable=SC2039,SC3045
146149
MAX_FD=$( ulimit -H -n ) ||
147150
warn "Could not query maximum file descriptor limit"
148151
esac
149152
case $MAX_FD in #(
150153
'' | soft) :;; #(
151154
*)
155+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156+
# shellcheck disable=SC2039,SC3045
152157
ulimit -n "$MAX_FD" ||
153158
warn "Could not set maximum file descriptor limit to $MAX_FD"
154159
esac
@@ -193,18 +198,28 @@ if "$cygwin" || "$msys" ; then
193198
done
194199
fi
195200

196-
# Collect all arguments for the java command;
197-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198-
# shell script including quotes and variable substitutions, so put them in
199-
# double quotes to make sure that they get re-expanded; and
200-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
201210

202211
set -- \
203212
"-Dorg.gradle.appname=$APP_BASE_NAME" \
204213
-classpath "$CLASSPATH" \
205214
org.gradle.wrapper.GradleWrapperMain \
206215
"$@"
207216

217+
# Stop when "xargs" is not available.
218+
if ! command -v xargs >/dev/null 2>&1
219+
then
220+
die "xargs is not available"
221+
fi
222+
208223
# Use "xargs" to parse quoted args.
209224
#
210225
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

0 commit comments

Comments
 (0)