Skip to content

Commit 6d83386

Browse files
authored
Merge pull request #12 from MicrocontrollersDev/twoconfig
2 parents 66ddc1e + 9e328e6 commit 6d83386

35 files changed

+303
-1046
lines changed

build.gradle.kts

Lines changed: 94 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,106 @@
1-
@file:Suppress("UnstableApiUsage", "PropertyName")
2-
3-
import dev.deftu.gradle.utils.GameSide
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
43

54
plugins {
6-
java
7-
kotlin("jvm")
8-
id("dev.deftu.gradle.multiversion") // Applies preprocessing for multiple versions of Minecraft and/or multiple mod loaders.
9-
id("dev.deftu.gradle.tools") // Applies several configurations to things such as the Java version, project name/version, etc.
10-
id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources.
11-
id("dev.deftu.gradle.tools.bloom") // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files.
12-
id("dev.deftu.gradle.tools.shadow") // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those!
13-
id("dev.deftu.gradle.tools.ducks") // Creates a ducks source set, which allows us to use theoretical classes which may not exist at runtime (such as things which are in other mods).
14-
id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you.
15-
id("dev.deftu.gradle.tools.minecraft.releases") // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth.
16-
}
17-
18-
toolkitLoomHelper {
19-
useOneConfig {
20-
version = "1.0.0-alpha.177"
21-
loaderVersion = "1.1.0-alpha.53"
22-
23-
usePolyMixin = true
24-
polyMixinVersion = "0.8.4+build.7"
25-
26-
applyLoaderTweaker = true
27-
28-
for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) {
29-
+module
30-
}
31-
}
5+
id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT"
6+
id("org.jetbrains.kotlin.jvm") version "2.3.0"
7+
id("dev.deftu.gradle.bloom") version "0.2.0"
8+
}
329

33-
// Turns off the server-side run configs, as we're building a client-sided mod.
34-
disableRunConfigs(GameSide.SERVER)
10+
val modid = property("mod.id")
11+
val modname = property("mod.name")
12+
val modversion = property("mod.version")
13+
val mcversion = property("minecraft_version")
3514

36-
// Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes.
37-
if (!mcData.isNeoForge) {
38-
useMixinRefMap(modData.id)
39-
}
15+
base {
16+
archivesName.set(property("mod.id") as String)
17+
}
18+
19+
repositories {
20+
maven("https://maven.parchmentmc.org")
21+
maven("https://repo.polyfrost.org/releases")
22+
maven("https://repo.polyfrost.org/snapshots")
23+
maven("https://maven.gegy.dev/releases")
24+
}
4025

41-
if (mcData.isForge) {
42-
// Configures the Mixin tweaker if we are building for Forge.
43-
useForgeMixin(modData.id)
26+
loom {
27+
runConfigs.all {
28+
ideConfigGenerated(stonecutter.current.isActive)
29+
runDir = "../../run" // This sets the run folder for all mc versions to the same folder. Remove this line if you want individual run folders.
4430
}
31+
32+
runConfigs.remove(runConfigs["server"]) // Removes server run configs
4533
}
4634

4735
dependencies {
48-
// Add Fabric Language Kotlin and (Legacy) Fabric API as dependencies (these are both optional but are particularly useful).
49-
if (mcData.isFabric) {
50-
if (mcData.isLegacyFabric) {
51-
// 1.8.9 - 1.13
52-
modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}")
53-
} else {
54-
// 1.16.5+
55-
modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}")
36+
minecraft("com.mojang:minecraft:${property("minecraft_version")}")
37+
@Suppress("UnstableApiUsage")
38+
mappings(loom.layered {
39+
officialMojangMappings()
40+
optionalProp("${property("parchment_version")}") {
41+
parchment("org.parchmentmc.data:parchment-${property("minecraft_version")}:$it@zip")
5642
}
43+
optionalProp("${property("yalmm_version")}") {
44+
mappings("dev.lambdaurora:yalmm-mojbackward:${property("minecraft_version")}+build.$it")
45+
}
46+
})
47+
modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}")
48+
modImplementation("org.polyfrost.oneconfig:${property("minecraft_version")}-fabric:1.0.0-alpha.181")
49+
modImplementation("org.polyfrost.oneconfig:commands:1.0.0-alpha.181")
50+
modImplementation("org.polyfrost.oneconfig:config:1.0.0-alpha.181")
51+
modImplementation("org.polyfrost.oneconfig:config-impl:1.0.0-alpha.181")
52+
modImplementation("org.polyfrost.oneconfig:events:1.0.0-alpha.181")
53+
modImplementation("org.polyfrost.oneconfig:internal:1.0.0-alpha.181")
54+
modImplementation("org.polyfrost.oneconfig:ui:1.0.0-alpha.181")
55+
modImplementation("org.polyfrost.oneconfig:utils:1.0.0-alpha.181")
56+
modImplementation("org.polyfrost.oneconfig:hud:1.0.0-alpha.181")
57+
58+
modImplementation("net.fabricmc:fabric-language-kotlin:${property("fabric_kotlin_version")}")
59+
}
60+
61+
bloom {
62+
replacement("@MOD_ID@", modid!!)
63+
replacement("@MOD_NAME@", modname!!)
64+
replacement("@MOD_VERSION@", modversion!!)
65+
}
66+
67+
tasks.processResources {
68+
val props = mapOf(
69+
"mod_id" to modid,
70+
"mod_name" to modname,
71+
"mod_version" to modversion,
72+
"mc_version" to mcversion,
73+
"loader_version" to providers.gradleProperty("loader_version").get()
74+
)
75+
76+
inputs.properties(props)
77+
78+
filesMatching("fabric.mod.json") {
79+
expand(props)
80+
}
81+
}
82+
83+
tasks.withType<JavaCompile>().configureEach {
84+
options.release.set(21)
85+
}
86+
87+
tasks.withType<KotlinCompile>().configureEach {
88+
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
89+
}
90+
91+
java {
92+
withSourcesJar()
93+
sourceCompatibility = JavaVersion.VERSION_21
94+
targetCompatibility = JavaVersion.VERSION_21
95+
}
96+
97+
tasks.jar {
98+
inputs.property("archivesName", base.archivesName)
99+
100+
from("LICENSE") {
101+
rename { "${it}_${inputs.properties["archivesName"]}" }
57102
}
58103
}
104+
105+
fun <T> optionalProp(property: String, block: (String) -> T?): T? =
106+
findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block)

gradle.properties

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,20 @@
1-
### Mod Properties ###
2-
# The name used to produce your mod's JAR file, also appearing in Bloom processed files and the mod's metadata.
31
mod.name=PolySprint
4-
# Your mod's ID, which is used in the mod's metadata and for identifying the mod in the game. Must be unique from other mods.
52
mod.id=polysprint
6-
# The version of your mod, which is used in the mod's metadata and for version checks.
73
mod.version=1.1.0-alpha.1
8-
# The Maven group ID for your mod, which is used in the mod's metadata and for dependency management.
94
mod.group=org.polyfrost
10-
######################
115

12-
### DGT Configuration ###
13-
# Switches the mappings for all our versions to use MCP and mojmap.
14-
dgt.loom.mappings=official-like
15-
# Sets the DGT automatic Minecraft dependency list to revision 3. Update this to latest if you want to use the latest recommended versions of libraries.
16-
dgt.minecraft.revision=3
17-
#########################
6+
loom_version=1.14-SNAPSHOT
7+
loader_version=0.18.4
8+
fabric_kotlin_version=1.13.8+kotlin.2.3.0
9+
minecraft_version=[VERSIONED]
10+
parchment_version=[VERSIONED]
11+
yalmm_version=[VERSIONED]
1812

19-
#####################################################################################
20-
### DO NOT EDIT THE PROPERTIES BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ###
21-
#####################################################################################
13+
org.gradle.daemon=true
14+
org.gradle.parallel=true
15+
org.gradle.configureoncommand=true
16+
org.gradle.parallel.threads=4
17+
org.gradle.jvmargs=-Xmx2G
2218

23-
### Gradle Configuration ###
24-
# Sets JVM arguments for Gradle to improve performance and stability.
25-
# Adjust memory settings as needed based on your system's capabilities.
26-
# If you're supporting the template's full version range, do not reduce these values any further, they're already quite low.
27-
org.gradle.jvmargs=-Xmx6144m -Dfile.encoding=UTF-8
28-
############################
29-
30-
### Loom Configuration ###
31-
# Allows us to use dependencies built with newer Loom by ignoring that it was built against a differing Loom version.
32-
# This is absolutely necessary because we use an older fork of Loom to enable Legacy Forge support.
33-
# As far as can be seen, there are absolutely no negative side effects to doing this. If you encounter any,
34-
# feel free to report them to the template's issue tracker and comment this line out to see if it resolves them.
35-
# You won't be able to use any dependencies built by newer Loom without this line, however.
36-
loom.ignoreDependencyLoomVersionValidation=true
37-
##########################
19+
# Fix YALMM
20+
fabric.loom.dropNonIntermediateRootMethods=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.11.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

root.gradle.kts

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

settings.gradle.kts

Lines changed: 22 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,35 @@
1-
@file:Suppress("PropertyName")
2-
3-
import groovy.lang.MissingPropertyException
4-
51
pluginManagement {
62
repositories {
7-
// Releases
8-
maven("https://maven.deftu.dev/releases")
3+
mavenCentral()
4+
gradlePluginPortal()
95
maven("https://maven.fabricmc.net")
10-
maven("https://maven.architectury.dev/")
11-
maven("https://maven.minecraftforge.net")
12-
maven("https://repo.essential.gg/repository/maven-public")
13-
maven("https://server.bbkr.space/artifactory/libs-release/")
6+
maven("https://maven.kikugie.dev/snapshots")
7+
maven("https://maven.kikugie.dev/releases")
148
maven("https://jitpack.io/")
15-
16-
// Snapshots
9+
maven("https://maven.deftu.dev/releases")
1710
maven("https://maven.deftu.dev/snapshots")
18-
mavenLocal()
19-
20-
// Default
21-
gradlePluginPortal()
22-
mavenCentral()
23-
}
24-
25-
plugins {
26-
kotlin("jvm") version("2.2.10")
27-
id("dev.deftu.gradle.multiversion-root") version("2.64.0")
11+
maven("https://maven.architectury.dev")
12+
maven("https://repo.polyfrost.org/releases")
13+
maven("https://repo.polyfrost.org/snapshots")
2814
}
2915
}
3016

31-
val projectName: String = extra["mod.name"]?.toString()
32-
?: throw MissingPropertyException("mod.name has not been set.")
33-
34-
// Configures the root project Gradle name based on the value in `gradle.properties`
35-
rootProject.name = projectName
36-
rootProject.buildFileName = "root.gradle.kts"
37-
38-
// Adds all of our build target versions to the classpath if we need to add version-specific code.
39-
// Update this list if you want to remove/add a version and/or mod loader.
40-
// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc)
41-
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` AND `build.gradle.kts` FILES WITH THE NEW VERSION(S).
42-
listOf(
43-
"1.8.9-forge",
44-
"1.8.9-fabric",
45-
46-
"1.12.2-forge",
47-
"1.12.2-fabric",
48-
49-
"1.16.5-forge",
50-
"1.16.5-fabric",
51-
52-
"1.20.1-forge",
53-
"1.20.1-fabric",
54-
55-
"1.20.4-forge",
56-
"1.20.4-neoforge",
57-
"1.20.4-fabric",
58-
59-
"1.21.1-neoforge",
60-
"1.21.1-fabric",
17+
plugins {
18+
id("dev.kikugie.stonecutter") version "0.7.10"
19+
}
6120

62-
"1.21.4-neoforge",
63-
"1.21.4-fabric",
21+
stonecutter {
22+
create(rootProject) {
23+
versions("1.21.1")
6424

65-
"1.21.5-neoforge",
66-
"1.21.5-fabric",
25+
vcsVersion = "1.21.1"
26+
}
27+
}
6728

68-
"1.21.8-neoforge",
69-
"1.21.8-fabric",
70-
).forEach { version ->
71-
include(":$version")
72-
project(":$version").apply {
73-
projectDir = file("versions/$version")
74-
buildFileName = "../../build.gradle.kts"
29+
dependencyResolutionManagement {
30+
versionCatalogs {
31+
create("libs")
7532
}
7633
}
34+
35+
rootProject.name = "PolySprint"

0 commit comments

Comments
 (0)