Skip to content

Commit 3b16375

Browse files
committed
updated build script
1 parent 502f5d1 commit 3b16375

5 files changed

Lines changed: 225 additions & 168 deletions

File tree

build.gradle.kts

Lines changed: 156 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -3,157 +3,179 @@
33
import org.apache.tools.ant.taskdefs.condition.Os
44

55
plugins {
6-
id("fabric-loom") version "1.10.0-bta"
7-
id("java")
6+
id("fabric-loom")
7+
java
88
}
99

10-
val lwjglVersion = "3.3.4"
11-
10+
val lwjglVersion = providers.gradleProperty("lwjgl_version")
1211
val lwjglNatives = when {
13-
Os.isFamily(Os.FAMILY_UNIX) && !Os.isFamily(Os.FAMILY_MAC) -> "natives-linux"
14-
Os.isFamily(Os.FAMILY_WINDOWS) -> "natives-windows"
15-
Os.isFamily(Os.FAMILY_MAC) -> "natives-macos${if (Os.isArch("aarch64")) "-arm64" else ""}"
16-
else -> error("Unsupported OS")
12+
Os.isFamily(Os.FAMILY_UNIX) && !Os.isFamily(Os.FAMILY_MAC) -> "natives-linux"
13+
Os.isFamily(Os.FAMILY_WINDOWS) -> "natives-windows"
14+
Os.isFamily(Os.FAMILY_MAC) -> "natives-macos${if (Os.isArch("aarch64")) "-arm64" else ""}"
15+
else -> error("Unsupported OS")
1716
}
1817

19-
val mod_group: String by project
20-
val mod_name: String by project
21-
val mod_version: String by project
18+
val modVersion = providers.gradleProperty("mod_version")
19+
val modGroup = providers.gradleProperty("mod_group")
20+
val modName = providers.gradleProperty("mod_name")
21+
22+
val btaChannel = providers.gradleProperty("bta_channel")
23+
val btaVersion = providers.gradleProperty("bta_version")
24+
25+
val loaderVersion = providers.gradleProperty("loader_version")
26+
val legacyLwjglVersion = providers.gradleProperty("legacy_lwjgl_version")
2227

23-
val bta_channel: String by project
24-
val bta_version: String by project
28+
val halplibeVersion = providers.gradleProperty("halplibe_version")
29+
val modMenuVersion = providers.gradleProperty("mod_menu_version")
2530

26-
val loader_version: String by project
31+
val slf4jApiVersion = providers.gradleProperty("slf4j_api_version")
32+
val log4jVersion = providers.gradleProperty("log4j_version")
33+
val guavaVersion = providers.gradleProperty("guava_version")
34+
val gsonVersion = providers.gradleProperty("gson_version")
35+
val commonsLang3Version = providers.gradleProperty("commons_lang3_version")
2736

28-
val halplibe_version: String by project
29-
val mod_menu_version: String by project
37+
val javaVersion = providers.gradleProperty("java_version")
3038

31-
group = mod_group
32-
base.archivesName.set(mod_name)
33-
version = mod_version
39+
group = modGroup.get()
40+
base.archivesName = modName.get()
41+
version = modVersion.get()
3442

3543
loom {
36-
noIntermediateMappings()
37-
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/$bta_channel/v$bta_version/manifest.json")
44+
noIntermediateMappings()
45+
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${btaChannel.get()}/v${btaVersion.get()}/manifest.json")
3846
}
3947

4048
repositories {
41-
mavenCentral()
42-
maven { url = uri("https://jitpack.io") }
43-
maven {
44-
name = "Babric"
45-
url = uri("https://maven.glass-launcher.net/babric")
46-
}
47-
maven {
48-
name = "Fabric"
49-
url = uri("https://maven.fabricmc.net/")
50-
}
51-
maven {
52-
name = "SignalumMavenInfrastructure"
53-
url = uri("https://maven.thesignalumproject.net/infrastructure")
54-
}
55-
maven {
56-
name = "SignalumMavenReleases"
57-
url = uri("https://maven.thesignalumproject.net/releases")
58-
}
59-
ivy {
60-
url = uri("https://github.com/Better-than-Adventure")
61-
patternLayout {
62-
artifact("[organisation]/releases/download/v[revision]/[module].jar")
63-
}
64-
metadataSources { artifact() }
65-
}
66-
ivy {
67-
url = uri("https://downloads.betterthanadventure.net/bta-client/$bta_channel/")
68-
patternLayout {
69-
artifact("/v[revision]/client.jar")
70-
}
71-
metadataSources { artifact() }
72-
}
73-
ivy {
74-
url = uri("https://downloads.betterthanadventure.net/bta-server/$bta_channel/")
75-
patternLayout {
76-
artifact("/v[revision]/server.jar")
77-
}
78-
metadataSources { artifact() }
79-
}
80-
ivy {
81-
url = uri("https://piston-data.mojang.com")
82-
patternLayout {
83-
artifact("v1/[organisation]/[revision]/[module].jar")
84-
}
85-
metadataSources { artifact() }
86-
}
49+
mavenCentral()
50+
maven("https://jitpack.io")
51+
maven("https://maven.fabricmc.net/") { name = "Fabric" }
52+
maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" }
53+
maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" }
54+
ivy("https://github.com/Better-than-Adventure") {
55+
patternLayout { artifact("[organisation]/releases/download/v[revision]/[module].jar") }
56+
metadataSources { artifact() }
57+
}
58+
ivy("https://downloads.betterthanadventure.net/bta-client/${btaChannel.get()}/") {
59+
patternLayout { artifact("/v[revision]/client.jar") }
60+
metadataSources { artifact() }
61+
}
62+
ivy("https://downloads.betterthanadventure.net/bta-server/${btaChannel.get()}/") {
63+
patternLayout { artifact("/v[revision]/server.jar") }
64+
metadataSources { artifact() }
65+
}
66+
ivy("https://piston-data.mojang.com") {
67+
patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") }
68+
metadataSources { artifact() }
69+
}
8770
}
8871

8972
dependencies {
90-
minecraft("::${bta_version}")
91-
mappings(loom.layered {})
92-
93-
modRuntimeOnly("objects:client:43db9b498cb67058d2e12d394e6507722e71bb45") // https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar
94-
modImplementation("net.fabricmc:fabric-loader:$loader_version")
95-
96-
// Helper library
97-
// If you do not need Halplibe you can comment this line out or delete this line
98-
modImplementation("turniplabs:halplibe:$halplibe_version")
99-
100-
modImplementation("turniplabs:modmenu-bta:$mod_menu_version")
101-
102-
implementation("org.slf4j:slf4j-api:1.8.0-beta4")
103-
implementation("org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0")
104-
105-
implementation("com.google.guava:guava:33.0.0-jre")
106-
implementation("com.google.code.gson:gson:2.10.1")
107-
108-
val log4jVersion = "2.20.0"
109-
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
110-
implementation("org.apache.logging.log4j:log4j-api:$log4jVersion")
111-
implementation("org.apache.logging.log4j:log4j-1.2-api:$log4jVersion")
112-
113-
implementation("org.apache.commons:commons-lang3:3.12.0")
114-
include("org.apache.commons:commons-lang3:3.12.0")
115-
116-
modImplementation("com.github.Better-than-Adventure:legacy-lwjgl3:1.0.5")
117-
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
118-
119-
runtimeOnly("org.lwjgl:lwjgl::$lwjglNatives")
120-
runtimeOnly("org.lwjgl:lwjgl-assimp::$lwjglNatives")
121-
runtimeOnly("org.lwjgl:lwjgl-glfw::$lwjglNatives")
122-
runtimeOnly("org.lwjgl:lwjgl-openal::$lwjglNatives")
123-
runtimeOnly("org.lwjgl:lwjgl-opengl::$lwjglNatives")
124-
runtimeOnly("org.lwjgl:lwjgl-stb::$lwjglNatives")
125-
implementation("org.lwjgl:lwjgl:$lwjglVersion")
126-
implementation("org.lwjgl:lwjgl-assimp:$lwjglVersion")
127-
implementation("org.lwjgl:lwjgl-glfw:$lwjglVersion")
128-
implementation("org.lwjgl:lwjgl-openal:$lwjglVersion")
129-
implementation("org.lwjgl:lwjgl-opengl:$lwjglVersion")
130-
implementation("org.lwjgl:lwjgl-stb:$lwjglVersion")
131-
}
132-
133-
java {
134-
sourceCompatibility = JavaVersion.VERSION_1_8
135-
targetCompatibility = JavaVersion.VERSION_1_8
136-
withSourcesJar()
137-
}
138-
139-
tasks.compileJava {
140-
options.release.set(8)
141-
}
142-
143-
tasks.jar {
144-
from("LICENSE") {
145-
rename { "${it}_${base.archivesName.get()}" }
146-
}
147-
}
148-
149-
configurations.configureEach {
150-
// Removes LWJGL2 dependencies
151-
exclude(group = "org.lwjgl.lwjgl")
73+
minecraft("::${btaVersion.get()}")
74+
mappings(loom.layered {})
75+
76+
// https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar
77+
modRuntimeOnly("objects:client:43db9b498cb67058d2e12d394e6507722e71bb45")
78+
// If you do not need Halplibe you can comment out or delete this line.
79+
modImplementation("turniplabs:halplibe:${halplibeVersion.get()}")
80+
modImplementation("turniplabs:modmenu-bta:${modMenuVersion.get()}")
81+
modImplementation("net.fabricmc:fabric-loader:${loaderVersion.get()}")
82+
modImplementation("com.github.Better-than-Adventure:legacy-lwjgl3:${legacyLwjglVersion.get()}")
83+
84+
implementation(platform("org.lwjgl:lwjgl-bom:${lwjglVersion.get()}"))
85+
implementation("org.slf4j:slf4j-api:${slf4jApiVersion.get()}")
86+
87+
implementation("com.google.guava:guava:${guavaVersion.get()}")
88+
implementation("com.google.code.gson:gson:${gsonVersion.get()}")
89+
90+
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion.get()}")
91+
implementation("org.apache.logging.log4j:log4j-core:${log4jVersion.get()}")
92+
implementation("org.apache.logging.log4j:log4j-api:${log4jVersion.get()}")
93+
implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion.get()}")
94+
95+
implementation("org.apache.commons:commons-lang3:${commonsLang3Version.get()}")
96+
include("org.apache.commons:commons-lang3:${commonsLang3Version.get()}")
97+
98+
implementation("org.lwjgl:lwjgl:${lwjglVersion.get()}")
99+
implementation("org.lwjgl:lwjgl-assimp:${lwjglVersion.get()}")
100+
implementation("org.lwjgl:lwjgl-glfw:${lwjglVersion.get()}")
101+
implementation("org.lwjgl:lwjgl-openal:${lwjglVersion.get()}")
102+
implementation("org.lwjgl:lwjgl-opengl:${lwjglVersion.get()}")
103+
implementation("org.lwjgl:lwjgl-stb:${lwjglVersion.get()}")
104+
105+
runtimeOnly("org.lwjgl:lwjgl::$lwjglNatives")
106+
runtimeOnly("org.lwjgl:lwjgl-assimp::$lwjglNatives")
107+
runtimeOnly("org.lwjgl:lwjgl-glfw::$lwjglNatives")
108+
runtimeOnly("org.lwjgl:lwjgl-openal::$lwjglNatives")
109+
runtimeOnly("org.lwjgl:lwjgl-opengl::$lwjglNatives")
110+
runtimeOnly("org.lwjgl:lwjgl-stb::$lwjglNatives")
152111
}
153112

154-
tasks.processResources {
155-
inputs.property("version", version)
156-
filesMatching("fabric.mod.json") {
157-
expand("version" to version)
158-
}
113+
tasks {
114+
withType<JavaCompile>().configureEach {
115+
options.encoding = "UTF-8"
116+
sourceCompatibility = javaVersion.get()
117+
targetCompatibility = javaVersion.get()
118+
if (javaVersion.get().toInt() > 8) options.release = javaVersion.get().toInt()
119+
}
120+
withType<JavaExec>().configureEach { defaultCharacterEncoding = "UTF-8" }
121+
withType<Javadoc>().configureEach { options.encoding = "UTF-8" }
122+
withType<Test>().configureEach { defaultCharacterEncoding = "UTF-8" }
123+
named<Jar>("jar") {
124+
val rootLicense = layout.projectDirectory.file("LICENSE")
125+
val parentLicense = layout.projectDirectory.file("../LICENSE")
126+
val licenseFile = when {
127+
rootLicense.asFile.exists() -> {
128+
logger.lifecycle("Using LICENSE from project root: ${rootLicense.asFile}")
129+
rootLicense
130+
}
131+
parentLicense.asFile.exists() -> {
132+
logger.lifecycle("Using LICENSE from parent directory: ${parentLicense.asFile}")
133+
parentLicense
134+
}
135+
else -> {
136+
logger.warn("No LICENSE file found in project or parent directory.")
137+
null
138+
}
139+
}
140+
licenseFile?.let {
141+
from(it) {
142+
rename { original -> "${original}_${archiveBaseName.get()}" }
143+
}
144+
}
145+
}
146+
processResources {
147+
val stringModVersion = modVersion.get()
148+
val stringLoaderVersion = loaderVersion.get()
149+
val stringJavaVersion = javaVersion.get()
150+
val stringHalplibeVersion = halplibeVersion.get()
151+
val stringModMenuVersion = modMenuVersion.get()
152+
inputs.property("modVersion", stringModVersion)
153+
inputs.property("loaderVersion", stringLoaderVersion)
154+
inputs.property("javaVersion", stringJavaVersion)
155+
inputs.property("HalplibeVersion", stringHalplibeVersion)
156+
inputs.property("modMenuVersion", stringModMenuVersion)
157+
filesMatching("fabric.mod.json") {
158+
expand(
159+
mapOf(
160+
"version" to stringModVersion,
161+
"fabricloader" to stringLoaderVersion,
162+
"halplibe" to stringHalplibeVersion,
163+
"java" to stringJavaVersion,
164+
"modmenu" to stringModMenuVersion
165+
)
166+
)
167+
}
168+
filesMatching("**/*.mixins.json") { expand(mapOf("java" to stringJavaVersion)) }
169+
}
170+
java {
171+
toolchain {
172+
languageVersion = JavaLanguageVersion.of(javaVersion.get())
173+
vendor = JvmVendorSpec.ADOPTIUM
174+
}
175+
sourceCompatibility = JavaVersion.toVersion(javaVersion.get().toInt())
176+
targetCompatibility = JavaVersion.toVersion(javaVersion.get().toInt())
177+
withSourcesJar()
178+
}
159179
}
180+
// Removes LWJGL2 dependencies
181+
configurations.configureEach { exclude(group = "org.lwjgl.lwjgl") }

gradle.properties

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
1-
org.gradle.jvmargs=-Xmx2G
2-
3-
# BTA
4-
bta_version=7.3_04
5-
bta_channel=release
6-
7-
# Loader
8-
loader_version=0.15.6-bta.7
9-
10-
# Other Mods
11-
mod_menu_version=3.0.0
12-
halplibe_version=5.3.1
13-
14-
# Mod
15-
mod_version=1.1.0
16-
mod_group=redart15
17-
mod_name=commandly
1+
##########################################################################
2+
# Standard Properties
3+
org.gradle.jvmargs = -Xmx2G
4+
org.gradle.warning.mode = all
5+
# This currently has to be set to false because the "Minecraft Client" and "Minecraft Server" configurations generated
6+
# by IntelliJ aren't currently compatible with the configuration cache. If you use the runClient and runServer Gradle
7+
# tasks instead, then this can (and should) be set to true.
8+
org.gradle.configuration-cache = false
9+
##########################################################################
10+
# Standard BTA Dependencies
11+
# Check this on https://downloads.betterthanadventure.net/bta-client/
12+
bta_version = 7.3_04
13+
# Options are release, prerelease, nightly, and misc.
14+
bta_channel = release
15+
# Check this on https://maven.thesignalumproject.net/#/infrastructure/net/fabricmc/fabric-loader/
16+
loader_version = 0.17.3-bta.8
17+
# Check this on https://maven.thesignalumproject.net/#/infrastructure/fabric-loom/fabric-loom.gradle.plugin/
18+
loom_version = 1.13.0-bta
19+
java_version = 8
20+
##########################################################################
21+
# Mod Properties
22+
mod_version = 1.1.1
23+
mod_group = turniplabs
24+
mod_name = examplemod
25+
##########################################################################
26+
# Mod Dependencies
27+
# Check this on https://github.com/Turnip-Labs/ModMenu/releases/latest/
28+
mod_menu_version = 3.0.0
29+
# Check this on https://github.com/Turnip-Labs/bta-halplibe/releases/latest/
30+
halplibe_version = 5.3.1
31+
# Check this on https://github.com/Better-than-Adventure/legacy-lwjgl3/releases/latest/
32+
legacy_lwjgl_version = 1.0.6
33+
##########################################################################
34+
# 3rd Party Dependencies
35+
# Check this on https://central.sonatype.com/artifact/org.slf4j/slf4j-api/
36+
slf4j_api_version = 2.0.17
37+
# Check this on https://central.sonatype.com/artifact/org.apache.logging.log4j/log4j-api/
38+
log4j_version = 2.20.0
39+
# Check this on https://central.sonatype.com/artifact/com.google.guava/guava/
40+
guava_version = 33.5.0-jre
41+
# Check this on https://central.sonatype.com/artifact/com.google.code.gson/gson/
42+
gson_version = 2.13.2
43+
# Check this on https://central.sonatype.com/artifact/org.apache.commons/commons-lang3/
44+
commons_lang3_version = 3.19.0
45+
# This should match the version used by the current BTA release.
46+
lwjgl_version = 3.3.3
47+
##########################################################################
48+
# Plugin Dependency
49+
# Check this on https://plugins.gradle.org/plugin/org.gradle.toolchains.foojay-resolver-convention/
50+
foojay_resolver_version = 1.0.0
51+
##########################################################################

gradle/wrapper/gradle-wrapper.jar

-13.7 KB
Binary file not shown.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Check this on https://gradle.org/releases/
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-all.zip
5+
networkTimeout=10000
6+
validateDistributionUrl=true
47
zipStoreBase=GRADLE_USER_HOME
58
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)