|
| 1 | +plugins { |
| 2 | + id 'idea' |
| 3 | + id 'java-library' |
| 4 | + id 'maven-publish' |
| 5 | + id 'net.neoforged.moddev.legacyforge' version '2.0.134' |
| 6 | +} |
| 7 | + |
| 8 | +tasks.named('wrapper', Wrapper).configure { |
| 9 | + // Define wrapper values here so as to not have to always do so when updating gradlew.properties. |
| 10 | + // Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with |
| 11 | + // documentation attached on cursor hover of gradle classes and methods. However, this comes with increased |
| 12 | + // file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards. |
| 13 | + // (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`) |
| 14 | + distributionType = Wrapper.DistributionType.BIN |
| 15 | +} |
| 16 | + |
| 17 | +version = mod_version |
| 18 | +group = mod_group_id |
| 19 | + |
| 20 | +repositories { |
| 21 | + mavenLocal() |
| 22 | +} |
| 23 | + |
| 24 | +base { |
| 25 | + archivesName = "TerraCurio" |
| 26 | +} |
| 27 | + |
| 28 | +// Mojang ships Java 17 to end users in 1.20.1, so mods should target Java 17. |
| 29 | +java.toolchain.languageVersion = JavaLanguageVersion.of(17) |
| 30 | +boolean isRunningInIdea = System.getProperty("idea.active") == "true" |
| 31 | + |
| 32 | +legacyForge { |
| 33 | + // Specify the version of MinecraftForge to use. |
| 34 | + version = project.minecraft_version + '-' + project.forge_version |
| 35 | + |
| 36 | + parchment { |
| 37 | + mappingsVersion = project.parchment_mappings_version |
| 38 | + minecraftVersion = project.parchment_minecraft_version |
| 39 | + } |
| 40 | + |
| 41 | + // This line is optional. Access Transformers are automatically detected |
| 42 | + accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg') |
| 43 | + |
| 44 | + // Default run configurations. |
| 45 | + // These can be tweaked, removed, or duplicated as needed. |
| 46 | + runs { |
| 47 | + client { |
| 48 | + client() |
| 49 | + |
| 50 | + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. |
| 51 | + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id |
| 52 | + } |
| 53 | + |
| 54 | + server { |
| 55 | + server() |
| 56 | +// programArgument '--nogui' |
| 57 | + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id |
| 58 | + } |
| 59 | + |
| 60 | + // This run config launches GameTestServer and runs all registered gametests, then exits. |
| 61 | + // By default, the server will crash when no gametests are provided. |
| 62 | + // The gametest system is also enabled by default for other run configs under the /test command. |
| 63 | + gameTestServer { |
| 64 | + type = "gameTestServer" |
| 65 | + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id |
| 66 | + } |
| 67 | + |
| 68 | + data { |
| 69 | + data() |
| 70 | + |
| 71 | + // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it |
| 72 | + // gameDirectory = project.file('run-data') |
| 73 | + |
| 74 | + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. |
| 75 | + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() |
| 76 | + } |
| 77 | + |
| 78 | + // applies to all the run configs above |
| 79 | + configureEach { |
| 80 | + // Recommended logging data for a userdev environment |
| 81 | + // The markers can be added/remove as needed separated by commas. |
| 82 | + // "SCAN": For mods scan. |
| 83 | + // "REGISTRIES": For firing of registry events. |
| 84 | + // "REGISTRYDUMP": For getting the contents of all registries. |
| 85 | + systemProperty 'forge.logging.markers', 'REGISTRIES' |
| 86 | + |
| 87 | + // Recommended logging level for the console |
| 88 | + // You can set various levels here. |
| 89 | + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels |
| 90 | + logLevel = org.slf4j.event.Level.DEBUG |
| 91 | + |
| 92 | + jvmArguments.addAll([ |
| 93 | + // 忽略无效指令,避免有的人没安装 JetBrain Runtime 无法启动游戏 |
| 94 | + "-XX:+IgnoreUnrecognizedVMOptions", |
| 95 | + // 启用 JetBrain Runtime 热重载功能 |
| 96 | + "-XX:+AllowEnhancedClassRedefinition" |
| 97 | + ]) |
| 98 | + if (isRunningInIdea) { |
| 99 | + systemProperty "terminal.jline", "true" |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + mods { |
| 105 | + // define mod <-> source bindings |
| 106 | + // these are used to tell the game which sources are for which mod |
| 107 | + // mostly optional in a single mod project |
| 108 | + // but multi mod projects should define one per mod |
| 109 | + "${mod_id}" { |
| 110 | + sourceSet(sourceSets.main) |
| 111 | + } |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | +// Include resources generated by data generators. |
| 116 | +sourceSets.main.resources { srcDir 'src/generated/resources' } |
| 117 | + |
| 118 | +// Sets up a dependency configuration called 'localRuntime' and a deobfuscating one called 'modLocalRuntime' |
| 119 | +// These configurations should be used instead of 'runtimeOnly' to declare |
| 120 | +// a dependency that will be present for runtime testing but that is |
| 121 | +// "optional", meaning it will not be pulled by dependents of this mod. |
| 122 | +configurations { |
| 123 | + runtimeClasspath.extendsFrom localRuntime |
| 124 | +} |
| 125 | +obfuscation { |
| 126 | + createRemappingConfiguration(configurations.localRuntime) |
| 127 | +} |
| 128 | + |
| 129 | +repositories { |
| 130 | + maven { |
| 131 | + url "https://maven.theillusivec4.top/" |
| 132 | + } |
| 133 | + maven { |
| 134 | + // location of the maven that hosts JEI files |
| 135 | + name = "Jared's maven" |
| 136 | + url = "https://maven.blamejared.com/" |
| 137 | + } |
| 138 | + maven { |
| 139 | + name = "Modrinth" |
| 140 | + url = uri("https://api.modrinth.com/maven") |
| 141 | + content { |
| 142 | + includeGroup("maven.modrinth") |
| 143 | + } |
| 144 | + } |
| 145 | + exclusiveContent { |
| 146 | + forRepository { |
| 147 | + maven { |
| 148 | + url "https://cursemaven.com" |
| 149 | + } |
| 150 | + } |
| 151 | + filter { |
| 152 | + includeGroup "curse.maven" |
| 153 | + } |
| 154 | + } |
| 155 | +} |
| 156 | + |
| 157 | +dependencies { |
| 158 | + modCompileOnly "top.theillusivec4.curios:curios-forge:${curios_version}:api" |
| 159 | + modImplementation "top.theillusivec4.curios:curios-forge:${curios_version}" |
| 160 | + |
| 161 | + modCompileOnly "mezz.jei:jei-1.20.1-common-api:${jei_version}" |
| 162 | + modCompileOnly "mezz.jei:jei-1.20.1-forge-api:${jei_version}" |
| 163 | + modLocalRuntime "mezz.jei:jei-1.20.1-forge:${jei_version}" |
| 164 | + |
| 165 | + modCompileOnly "maven.modrinth:tetra:v6cyAXIJ" |
| 166 | + |
| 167 | + modCompileOnly "maven.modrinth:spartan-weaponry:1.20.1-3.2.1" |
| 168 | +} |
| 169 | + |
| 170 | +// Uncomment the lines below if you wish to configure mixin. The mixin file should be named modid.mixins.json. |
| 171 | +mixin { |
| 172 | + add sourceSets.main, "${mod_id}.refmap.json" |
| 173 | + config "${mod_id}.mixins.json" |
| 174 | +} |
| 175 | + |
| 176 | +dependencies { |
| 177 | + compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.5.0")) |
| 178 | + implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.5.0")) |
| 179 | + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' |
| 180 | +} |
| 181 | + |
| 182 | +jar { |
| 183 | + manifest.attributes([ |
| 184 | + "MixinConfigs": "${mod_id}.mixins.json" |
| 185 | + ]) |
| 186 | +} |
| 187 | + |
| 188 | +// This block of code expands all declared replace properties in the specified resource targets. |
| 189 | +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. |
| 190 | +tasks.withType(ProcessResources).configureEach { |
| 191 | + var replaceProperties = [ |
| 192 | + minecraft_version : minecraft_version, |
| 193 | + minecraft_version_range: minecraft_version_range, |
| 194 | + forge_version : forge_version, |
| 195 | + forge_version_range : forge_version_range, |
| 196 | + loader_version_range : loader_version_range, |
| 197 | + mod_id : mod_id, |
| 198 | + mod_name : mod_name, |
| 199 | + mod_license : mod_license, |
| 200 | + mod_version : mod_version, |
| 201 | + mod_authors : mod_authors, |
| 202 | + mod_description : mod_description |
| 203 | + ] |
| 204 | + inputs.properties replaceProperties |
| 205 | + |
| 206 | + filesMatching(['META-INF/mods.toml']) { |
| 207 | + expand replaceProperties |
| 208 | + } |
| 209 | +} |
| 210 | +java.withSourcesJar() |
| 211 | + |
| 212 | +// Example configuration to allow publishing using the maven-publish plugin |
| 213 | +publishing { |
| 214 | + publications { |
| 215 | + register('mavenJava', MavenPublication) { |
| 216 | + from components.java |
| 217 | + } |
| 218 | + } |
| 219 | + repositories { |
| 220 | + maven { |
| 221 | + url "file://${project.projectDir}/repo" |
| 222 | + } |
| 223 | + } |
| 224 | +} |
| 225 | + |
| 226 | +tasks.withType(JavaCompile).configureEach { |
| 227 | + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation |
| 228 | +} |
| 229 | + |
| 230 | +// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. |
| 231 | +idea { |
| 232 | + module { |
| 233 | + downloadSources = true |
| 234 | + downloadJavadoc = true |
| 235 | + } |
| 236 | +} |
0 commit comments