1+ import dev.compactmachines.GanderConstants
2+ import gradle.kotlin.dsl.accessors._53f21c2e2286c58eadab8fd2d7f5601a.*
3+ import org.slf4j.event.Level
4+
5+ var envVersion: String = System .getenv(" VERSION" ) ? : " 9.9.9"
6+ if (envVersion.startsWith(" v" ))
7+ envVersion = envVersion.trimStart(' v' )
8+
19plugins {
2- id(" gander-convention" )
10+ id(" java-library" )
11+ id(" idea" )
12+ id(" org.jetbrains.gradle.plugin.idea-ext" )
13+ id(" net.neoforged.moddev.legacyforge" )
14+ id(" maven-publish" )
15+ }
16+
17+ // main convention script which sets up a basic MDG workspace
18+ // pulling in version data from GanderConstants since version catalogs
19+ // from the main outer project are not accessible here
20+
21+ base {
22+ archivesName = project.name
23+ group = " dev.compactmods.gander"
24+ version = envVersion
25+
26+ libsDirectory.convention(rootProject.layout.projectDirectory.dir(" libs/${project.name} " ))
27+ }
28+
29+ javaToolchains.compilerFor {
30+ languageVersion.convention(GanderConstants .JAVA_VERSION )
31+ vendor.convention(GanderConstants .JAVA_VENDOR )
332}
433
534// sets up MDG workspace and includes all other gander modules
@@ -13,6 +42,27 @@ val gModules = listOf(
1342gModules.map { it.path }.forEach(::evaluationDependsOn)
1443
1544neoForge {
45+ version = GanderConstants .FORGE_VERSION
46+ // not currently usable since the AT included in legacy forge
47+ // does not itself validate, many unused/nonexistent AT entries exist in it
48+ // validateAccessTransformers.convention(true)
49+
50+ parchment {
51+ minecraftVersion = GanderConstants .PARCHMENT_VERSION
52+ mappingsVersion = GanderConstants .PARCHMENT_MAPPINGS
53+ }
54+
55+ // apply this modules AT file if it exists
56+ // also mark for publishing with maven publication
57+ val atFile = file(" src/main/resources/META-INF/accesstransformer.cfg" )
58+
59+ if (atFile.exists()) {
60+ accessTransformers {
61+ from(atFile)
62+ publish(atFile)
63+ }
64+ }
65+
1666 mods {
1767 create(SourceSet .MAIN_SOURCE_SET_NAME ) {
1868 sourceSet(sourceSets[SourceSet .MAIN_SOURCE_SET_NAME ])
@@ -33,6 +83,31 @@ neoForge {
3383 }
3484
3585 runs {
86+ configureEach {
87+ // set up basic common run config properties
88+ // due to using convention this can be override in each run config
89+ logLevel = Level .DEBUG
90+ sourceSet = sourceSets[SourceSet .MAIN_SOURCE_SET_NAME ]
91+ loadedMods = mods // all registered mod
92+ gameDirectory = type.map { layout.projectDirectory.dir(" run/$it " ) }
93+
94+ // using '.map' adds args as a 'provider'
95+ // making them lazily evaluated later
96+ // when 'type' actually exists
97+ //
98+ // adds jbr jvm args only for client/server run types
99+ jvmArguments.addAll(type.map {
100+ if (GanderConstants .IS_CI || (it != " client" && it != " server" ))
101+ return @map emptyList<String >()
102+
103+ return @map listOf (
104+ " -XX:+AllowEnhancedClassRedefinition" ,
105+ " -XX:+IgnoreUnrecognizedVMOptions" ,
106+ " -XX:+AllowRedefinitionToAddDeleteMethods"
107+ )
108+ })
109+ }
110+
36111 create(" client" ) {
37112 client()
38113 }
@@ -61,3 +136,24 @@ mixin {
61136 config(" gander_render.mixins.json" )
62137 config(" gander_levels.mixins.json" )
63138}
139+
140+ tasks.jar {
141+ manifest.from(file(" src/main/resources/META-INF/MANIFEST.MF" ))
142+ }
143+
144+
145+ dependencies {
146+ // not included with MDG currently
147+ // does not affect runtime or production
148+ // safe to have at compile time with no issues
149+ compileOnly(" org.jetbrains:annotations:26.0.1" )
150+ annotationProcessor(" org.spongepowered:mixin:0.8.5:processor" )
151+ }
152+
153+ tasks.withType<JavaCompile > {
154+ options.encoding = " UTF-8"
155+
156+ if (! GanderConstants .IS_CI ) {
157+ options.compilerArgs.addAll(arrayOf(" -Xmaxerrs" , " 9000" ))
158+ }
159+ }
0 commit comments