1- val forgeVersion = project.properties[" forge_version" ].toString()
2- val kotlinForgeVersion = project.properties[" kotlin_forge_version" ].toString()
3- val mixinExtrasVersion = project.properties[" mixinextras_version" ].toString()
1+ val forgeVersion = property(" forge_version" ).toString()
2+ val kotlinForgeVersion = property(" kotlin_forge_version" ).toString()
3+ val architecturyVersion = property(" architectury_version" ).toString()
4+ val mixinExtrasVersion = property(" mixinextras_version" ).toString()
45
56architectury {
67 platformSetupLoomIde()
@@ -11,20 +12,29 @@ base.archivesName.set("${base.archivesName.get()}-forge")
1112
1213loom {
1314 accessWidenerPath.set(project(" :common" ).loom.accessWidenerPath)
15+
1416 forge {
1517 convertAccessWideners = true
1618 extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
1719 mixinConfig(" lambda.mixins.common.json" )
1820 }
21+
22+ mods {
23+ register(" forge" ) {
24+ sourceSet(" main" , project(" :forge" ))
25+
26+ sourceSets.forEach {
27+ val dir = layout.buildDirectory.dir(" sourcesSets/${it.name} " )
28+ it.output.setResourcesDir(dir)
29+ it.java.destinationDirectory.set(dir)
30+ }
31+ }
32+ }
1933}
2034
2135repositories {
22- maven(" https://thedarkcolour.github.io/KotlinForForge/" ) {
23- name = " KotlinForForge"
24- }
25- maven(" https://cursemaven.com" ) {
26- name = " Curse"
27- }
36+ maven(" https://thedarkcolour.github.io/KotlinForForge/" )
37+ maven(" https://cursemaven.com" )
2838}
2939
3040val common: Configuration by configurations.creating {
@@ -33,18 +43,49 @@ val common: Configuration by configurations.creating {
3343 configurations[" developmentForge" ].extendsFrom(this )
3444}
3545
36- dependencies {
37- forge(" net.minecraftforge:forge:$forgeVersion " )
38- implementation(" thedarkcolour:kotlinforforge:$kotlinForgeVersion " )
39- common(project(" :common" , configuration = " namedElements" )) {
40- isTransitive = false
46+ val includeLib: Configuration by configurations.creating
47+ val includeMod: Configuration by configurations.creating
48+
49+ fun DependencyHandlerScope.setupConfigurations () {
50+ includeLib.dependencies.forEach {
51+ implementation(it)
52+ include(it)
4153 }
42- shadowCommon(project(path = " :common" , configuration = " transformProductionForge" )) {
43- isTransitive = false
54+
55+ // Please look at this before yelling at me
56+ // https://docs.architectury.dev/loom/using_libraries/
57+ includeMod.dependencies.forEach {
58+ implementation(it)
59+ forgeRuntimeLibrary(it)
4460 }
45- implementation(annotationProcessor(" io.github.llamalad7:mixinextras-common:$mixinExtrasVersion " )!! )
46- implementation(include(" io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion " )!! )
47- implementation(" org.reflections:reflections:0.10.2" )
61+ }
62+
63+ dependencies {
64+ // Forge API
65+ forge(" net.minecraftforge:forge:$forgeVersion " )
66+
67+ // Architectury API
68+ modApi(" dev.architectury:architectury-forge:$architecturyVersion " )
69+
70+ // Add dependencies on the required Kotlin modules.
71+ includeLib(" org.reflections:reflections:0.10.2" )
72+ includeLib(" org.javassist:javassist:3.27.0-GA" )
73+
74+ implementation(" io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion " )
75+ compileOnly(annotationProcessor(" io.github.llamalad7:mixinextras-common:$mixinExtrasVersion " )!! )
76+
77+ // Add mods to the mod jar
78+ includeMod(" thedarkcolour:kotlinforforge:$kotlinForgeVersion " )
79+
80+ // Bugfixes
81+ compileOnly(kotlin(" stdlib" )) // Hack https://github.com/thedarkcolour/KotlinForForge/issues/93
82+
83+ // Common (Do not touch)
84+ common(project(" :common" , configuration = " namedElements" )) { isTransitive = false } // We cannot common here because it is treated as a different mod and forge will panic
85+ shadowCommon(project(path = " :common" , configuration = " transformProductionForge" )) { isTransitive = false }
86+
87+ // Finish the configuration
88+ setupConfigurations()
4889}
4990
5091tasks {
0 commit comments