Skip to content

Commit 7f70e60

Browse files
Merge branch 'main' into kotlin
2 parents 88d9dc8 + 251d966 commit 7f70e60

7 files changed

Lines changed: 119 additions & 139 deletions

File tree

build.gradle.kts

Lines changed: 96 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,81 @@ plugins {
77
java
88
`java-library`
99
`maven-publish`
10-
kotlin("jvm") version "2.3.20"
10+
kotlin("jvm") version "2.4.0"
1111
id("com.gradleup.shadow") version "9.4.1"
1212
id("org.jetbrains.gradle.plugin.idea-ext") version "1.4.1"
13-
id("xyz.wagyourtail.unimined") version "1.4.18-kappa"
13+
id("xyz.wagyourtail.unimined") version "1.4.23-kappa"
1414
id("net.kyori.blossom") version "2.2.0"
1515
}
1616

17-
// Early Assertions
18-
assertProperty("mod_version")
19-
assertProperty("root_package")
20-
assertProperty("mod_id")
21-
assertProperty("mod_name")
17+
val mod_version: String by project
18+
val root_package: String by project
19+
val mod_id: String by project
20+
val mod_name: String by project
2221

23-
assertSubProperties("use_access_transformer", "access_transformer_locations")
24-
assertSubProperties("is_coremod", "coremod_includes_mod", "coremod_plugin_class_name")
25-
assertSubProperties("use_asset_mover", "asset_mover_version")
22+
require(mod_version.isNotEmpty()) { "mod_version is empty!" }
23+
require(root_package.isNotEmpty()) { "root_package is empty!" }
24+
require(mod_id.isNotEmpty()) { "mod_id is empty!" }
25+
require(mod_name.isNotEmpty()) { "mod_name is empty!" }
2626

27-
setDefaultProperty("generate_sources_jar", true, false)
28-
setDefaultProperty("generate_javadocs_jar", true, false)
29-
setDefaultProperty("minecraft_username", true, "Developer")
30-
setDefaultProperty("extra_jvm_args", false, "")
27+
val generate_sources_jar: String by project
28+
val generateSourcesJar = generate_sources_jar.toBoolean()
29+
val generate_javadocs_jar: String by project
30+
val generateJavadocsJar = generate_javadocs_jar.toBoolean()
31+
val minecraft_username: String by project
32+
val extra_jvm_args: String by project
33+
val enable_shadow: String by project
34+
val enableShadow = enable_shadow.toBoolean()
35+
val use_access_transformer: String by project
36+
val useAccessTransformer = use_access_transformer.toBoolean()
37+
val is_coremod: String by project
38+
val isCoremod = is_coremod.toBoolean()
39+
val coremod_includes_mod: String by project
40+
val coremodIncludesMod = coremod_includes_mod.toBoolean()
41+
val coremod_plugin_class_name: String by project
42+
val use_asset_mover: String by project
43+
val useAssetMover = use_asset_mover.toBoolean()
44+
val asset_mover_version: String by project
45+
val enable_junit_testing: String by project
46+
val enableJunitTesting = enable_junit_testing.toBoolean()
47+
val show_testing_output: String by project
48+
val showTestingOutput = show_testing_output.toBoolean()
49+
val enable_foundation_debug: String by project
50+
val enableFoundationDebug = enable_foundation_debug.toBoolean()
51+
val mod_description: String by project
52+
val mod_authors: String by project
53+
val mod_credits: String by project
54+
val mod_url: String by project
55+
val mod_update_json: String by project
56+
val mod_logo_path: String by project
3157

32-
version = propertyString("mod_version")
33-
group = propertyString("root_package")
58+
val access_transformer_locations: String = "${mod_id}_at.cfg"
59+
60+
if (useAccessTransformer) {
61+
require(access_transformer_locations.isNotEmpty()) { "access_transformer_locations is empty!" }
62+
}
63+
if (isCoremod) {
64+
require(coremod_plugin_class_name.isNotEmpty()) { "coremod_plugin_class_name is empty!" }
65+
}
66+
if (useAssetMover) {
67+
require(asset_mover_version.isNotEmpty()) { "asset_mover_version is empty!" }
68+
}
69+
70+
version = mod_version
71+
group = root_package
3472

3573
base {
36-
archivesName.set(propertyString("mod_id"))
74+
archivesName.set(mod_id)
3775
}
3876

3977
java {
4078
toolchain {
4179
languageVersion = JavaLanguageVersion.of(25)
4280
}
43-
if (propertyBool("generate_sources_jar")) {
81+
if (generateSourcesJar) {
4482
withSourcesJar()
4583
}
46-
if (propertyBool("generate_javadocs_jar")) {
84+
if (generateJavadocsJar) {
4785
withJavadocJar()
4886
}
4987
}
@@ -61,7 +99,7 @@ configurations {
6199
runtimeOnly { extendsFrom(modRuntimeOnly) }
62100
}
63101

64-
val remapTaskName = if (propertyBool("enable_shadow")) "remapShadowJar" else "remapJar"
102+
val remapTaskName = if (enableShadow) "remapShadowJar" else "remapJar"
65103

66104
unimined.minecraft {
67105
version("1.12.2")
@@ -71,31 +109,30 @@ unimined.minecraft {
71109
}
72110

73111
cleanroom {
74-
if (propertyBool("use_access_transformer")) {
75-
accessTransformer("${rootProject.projectDir}/src/main/resources/${propertyString("access_transformer_locations")}")
112+
if (useAccessTransformer) {
113+
accessTransformer("${rootProject.projectDir}/src/main/resources/$access_transformer_locations")
76114
}
77-
loader("0.5.12-alpha")
115+
loader("0.5.14-alpha")
78116
runs.all {
79-
args.addAll(listOf("--username", "minecraft_username"))
80-
val extraArgs = propertyString("extra_jvm_args")
81-
if (extraArgs.trim().isNotEmpty()) {
82-
jvmArgs(extraArgs.split("\\s+"))
117+
args.addAll(listOf("--username", minecraft_username))
118+
if (extra_jvm_args.isNotEmpty()) {
119+
jvmArgs(extra_jvm_args.split("\\s+"))
83120
}
84-
if (propertyBool("enable_foundation_debug")) {
121+
if (enableFoundationDebug) {
85122
systemProperties.apply {
86123
set("foundation.dump", "true")
87124
set("foundation.verbose", "true")
88125
}
89126
}
90-
if (propertyBool("is_coremod")) {
91-
systemProperty("fml.coreMods.load", propertyString("coremod_plugin_class_name"))
127+
if (isCoremod) {
128+
systemProperty("fml.coreMods.load", coremod_plugin_class_name)
92129
}
93130
}
94131
}
95132

96133
defaultRemapJar = false
97134

98-
val jarTaskName = if (propertyBool("enable_shadow")) "shadowJar" else "jar"
135+
val jarTaskName = if (enableShadow) "shadowJar" else "jar"
99136

100137
remap(tasks.named(jarTaskName).get()) {
101138
mixinRemap {
@@ -114,11 +151,11 @@ unimined.minecraft {
114151
}
115152

116153
dependencies {
117-
if (propertyBool("use_asset_mover")) {
118-
implementation("com.cleanroommc:assetmover:${propertyString("asset_mover_version")}")
154+
if (useAssetMover) {
155+
implementation("com.cleanroommc:assetmover:$asset_mover_version")
119156
}
120-
if (propertyBool("enable_junit_testing")) {
121-
testImplementation("org.junit.jupiter:junit-jupiter:6.0.2")
157+
if (enableJunitTesting) {
158+
testImplementation("org.junit.jupiter:junit-jupiter:6.0.3")
122159
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
123160
}
124161
}
@@ -133,29 +170,29 @@ sourceSets {
133170
main {
134171
blossom {
135172
kotlinSources {
136-
property("mod_id", propertyString("mod_id"))
137-
property("mod_name", propertyString("mod_name"))
138-
property("mod_version", propertyString("mod_version"))
139-
val rootPackage = propertyString("root_package")
140-
val modId = propertyString("mod_id")
141-
property("package", "$rootPackage.$modId")
173+
property("mod_id", mod_id)
174+
property("mod_name", mod_name)
175+
property("mod_version", mod_version)
176+
property("package", "$root_package.$mod_id")
142177
}
143178
resources {
144-
property("mod_id", propertyString("mod_id"))
145-
property("mod_name", propertyString("mod_name"))
146-
property("mod_version", propertyString("mod_version"))
147-
property("mod_description", propertyString("mod_description"))
148-
property("mod_authors", propertyStringList("mod_authors", ",").joinToString("\", \"") { it.trim() })
149-
property("mod_credits", propertyString("mod_credits"))
150-
property("mod_url", propertyString("mod_url"))
151-
property("mod_update_json", propertyString("mod_update_json"))
152-
property("mod_logo_path", propertyString("mod_logo_path"))
179+
property("mod_id", mod_id)
180+
property("mod_name", mod_name)
181+
property("mod_version", mod_version)
182+
property("mod_description", mod_description)
183+
property("mod_authors", mod_authors.takeIf { it.isNotBlank() }
184+
?.split(",")?.filter { it.isNotBlank() }
185+
?.joinToString("\", \"") { it.trim() } ?: "")
186+
property("mod_credits", mod_credits)
187+
property("mod_url", mod_url)
188+
property("mod_update_json", mod_update_json)
189+
property("mod_logo_path", mod_logo_path)
153190
}
154191
}
155192
}
156193
}
157194

158-
if (!propertyBool("enable_shadow")) {
195+
if (!enableShadow) {
159196
tasks.shadowJar { enabled = false }
160197
}
161198

@@ -186,6 +223,7 @@ idea {
186223
}
187224

188225
tasks.jar {
226+
archiveClassifier = "dev"
189227
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
190228
val contain by configurations.getting
191229
if (!contain.isEmpty) {
@@ -201,14 +239,14 @@ tasks.jar {
201239
attributeMap["ContainedDeps"] = contain.joinToString(" ") { it.name }
202240
attributeMap["NonModDeps"] = true
203241
}
204-
if (propertyBool("is_coremod")) {
205-
attributeMap["FMLCorePlugin"] = propertyString("coremod_plugin_class_name")
206-
if (propertyBool("coremod_includes_mod")) {
242+
if (isCoremod) {
243+
attributeMap["FMLCorePlugin"] = coremod_plugin_class_name
244+
if (coremodIncludesMod) {
207245
attributeMap["FMLCorePluginContainsFMLMod"] = true
208246
}
209247
}
210-
if (propertyBool("use_access_transformer")) {
211-
attributeMap["FMLAT"] = propertyString("access_transformer_locations")
248+
if (useAccessTransformer) {
249+
attributeMap["FMLAT"] = access_transformer_locations
212250
}
213251
attributes(attributeMap)
214252
}
@@ -242,14 +280,14 @@ tasks.test {
242280
languageVersion = JavaLanguageVersion.of(25)
243281
}
244282

245-
if (propertyBool("show_testing_output")) {
283+
if (showTestingOutput) {
246284
testLogging {
247285
showStandardStreams = true
248286
}
249287
}
250288
}
251289

252-
tasks.withType<JavaCompile> {
290+
tasks.withType<JavaCompile>().configureEach {
253291
options.encoding = "UTF-8"
254292
}
255293

buildSrc/src/main/kotlin/dependencies.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ plugins {
22
java
33
}
44

5+
val enable_lwjglx: String by project
6+
val enableLwjglx = enable_lwjglx.toBoolean()
7+
58
repositories {
69
// Other repositories described by default:
710
// CleanroomMC: https://maven.cleanroommc.com
@@ -27,8 +30,8 @@ repositories {
2730
}
2831
dependencies {
2932
compileOnly("com.cleanroommc:sponge-mixin:0.20.13+mixin.0.8.7")
30-
implementation("io.github.chaosunity.forgelin:Forgelin-Continuous:2.3.10.0")
31-
if (propertyBool("enable_lwjglx")) {
33+
implementation("io.github.chaosunity.forgelin:Forgelin-Continuous:2.4.0.0")
34+
if (enableLwjglx) {
3235
compileOnly("com.cleanroommc:lwjglx:1.0.0")
3336
}
3437

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
// You may write any gradle buildscript component in this file
2-
// This file is automatically applied after build.gradle + dependencies.gradle is ran
3-
4-
// If you wish to use the default helper methods, uncomment the line below
5-
// apply from: 'gradle/scripts/helpers.gradle'
2+
// This file is automatically applied after build.gradle.kts + dependencies.gradle is ran

buildSrc/src/main/kotlin/helpers.kt

Lines changed: 0 additions & 64 deletions
This file was deleted.

buildSrc/src/main/kotlin/publishing.gradle.kts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1+
val publish_to_maven: String by project
2+
val publishToMaven = publish_to_maven.toBoolean()
3+
val maven_name: String by project
4+
val maven_url: String by project
5+
val root_package: String by project
6+
val mod_id: String by project
7+
18
plugins {
29
`maven-publish`
310
}
4-
setDefaultProperty("publish_to_maven", true, false)
511

6-
if (propertyBool("publish_to_maven")) {
7-
assertProperty("maven_name")
8-
assertProperty("maven_url")
12+
if (publishToMaven) {
13+
require(maven_name.isNotEmpty()) { "maven_name is empty!" }
14+
require(maven_url.isNotEmpty()) { "maven_url is empty!" }
15+
916
publishing {
1017
repositories {
1118
maven {
12-
name = propertyString("maven_name").replace("\\s", "")
13-
setUrl(propertyString("maven_url"))
19+
name = maven_name.replace("\\s".toRegex(), "")
20+
url = uri(maven_url)
1421
credentials(PasswordCredentials::class.java)
1522
}
1623
}
1724
publications {
1825
create<MavenPublication>("mavenJava") {
1926
from(components["java"]) // Publish with standard artifacts
20-
groupId = (propertyString("root_package")) // Publish with root package as maven group
21-
artifactId = (propertyString("mod_id")) // Publish artifacts with mod id as the artifact id
27+
groupId = root_package
28+
artifactId = mod_id
2229

2330
// Custom artifact:
2431
// If you want to publish a different artifact to the one outputted when building normally
25-
// Create a different gradle task (Jar task), in extra.gradle
32+
// Create a different gradle task (Jar task), in extra.gradle.kts
2633
// Remove the "from components.java" line above
2734
// Add this line (change the task name):
2835
// artifacts task_name

0 commit comments

Comments
 (0)