|
| 1 | +plugins { |
| 2 | + id 'java-library' |
| 3 | + id 'maven-publish' |
| 4 | + id 'idea' |
| 5 | + id 'net.neoforged.moddev' version '2.0.92' |
| 6 | +} |
| 7 | + |
| 8 | +version = mod_version |
| 9 | +group = mod_group_id |
| 10 | + |
| 11 | +repositories { |
| 12 | + mavenLocal() |
| 13 | +} |
| 14 | + |
| 15 | +base { |
| 16 | + archivesName = mod_id + "-neoforge" |
| 17 | +} |
| 18 | + |
| 19 | +java.toolchain.languageVersion = JavaLanguageVersion.of(21) |
| 20 | + |
| 21 | +jarJar.enabled = true |
| 22 | + |
| 23 | +neoForge { |
| 24 | + // Specify the version of NeoForge to use. |
| 25 | + version = project.neo_version |
| 26 | + |
| 27 | + parchment { |
| 28 | + mappingsVersion = project.parchment_mappings_version |
| 29 | + minecraftVersion = project.parchment_minecraft_version |
| 30 | + } |
| 31 | + |
| 32 | + // This line is optional. Access Transformers are automatically detected |
| 33 | + // accessTransformers.add('src/main/resources/META-INF/accesstransformer.cfg') |
| 34 | + |
| 35 | + // Default run configurations. |
| 36 | + // These can be tweaked, removed, or duplicated as needed. |
| 37 | + runs { |
| 38 | + client { |
| 39 | + client() |
| 40 | + |
| 41 | + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. |
| 42 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 43 | + } |
| 44 | + |
| 45 | + server { |
| 46 | + server() |
| 47 | + programArgument '--nogui' |
| 48 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 49 | + } |
| 50 | + |
| 51 | + // This run config launches GameTestServer and runs all registered gametests, then exits. |
| 52 | + // By default, the server will crash when no gametests are provided. |
| 53 | + // The gametest system is also enabled by default for other run configs under the /test command. |
| 54 | + gameTestServer { |
| 55 | + type = "gameTestServer" |
| 56 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 57 | + } |
| 58 | + |
| 59 | + data { |
| 60 | + data() |
| 61 | + |
| 62 | + // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it |
| 63 | + // gameDirectory = project.file('run-data') |
| 64 | + |
| 65 | + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. |
| 66 | + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() |
| 67 | + } |
| 68 | + |
| 69 | + // applies to all the run configs above |
| 70 | + configureEach { |
| 71 | + // Recommended logging data for a userdev environment |
| 72 | + // The markers can be added/remove as needed separated by commas. |
| 73 | + // "SCAN": For mods scan. |
| 74 | + // "REGISTRIES": For firing of registry events. |
| 75 | + // "REGISTRYDUMP": For getting the contents of all registries. |
| 76 | + systemProperty 'forge.logging.markers', 'REGISTRIES' |
| 77 | + |
| 78 | + // Recommended logging level for the console |
| 79 | + // You can set various levels here. |
| 80 | + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels |
| 81 | + logLevel = org.slf4j.event.Level.DEBUG |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + mods { |
| 86 | + // define mod <-> source bindings |
| 87 | + // these are used to tell the game which sources are for which mod |
| 88 | + // mostly optional in a single mod project |
| 89 | + // but multi mod projects should define one per mod |
| 90 | + "${mod_id}" { |
| 91 | + sourceSet(sourceSets.main) |
| 92 | + sourceSet(project(":common").sourceSets.main) |
| 93 | + } |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +// Include resources generated by data generators. |
| 98 | +sourceSets.main.resources { srcDir 'src/generated/resources' } |
| 99 | + |
| 100 | +compileJava { |
| 101 | + options.compilerArgs += "-g" |
| 102 | +} |
| 103 | + |
| 104 | +dependencies { |
| 105 | + // Example mod dependency with JEI |
| 106 | + // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime |
| 107 | + // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}" |
| 108 | + // compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}" |
| 109 | + // runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}" |
| 110 | + |
| 111 | + // Example mod dependency using a mod jar from ./libs with a flat dir repository |
| 112 | + // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar |
| 113 | + // The group id is ignored when searching -- in this case, it is "blank" |
| 114 | + // implementation "blank:coolmod-${mc_version}:${coolmod_version}" |
| 115 | + |
| 116 | + // Example mod dependency using a file as dependency |
| 117 | + // implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar") |
| 118 | + |
| 119 | + // Example project dependency using a sister or child project: |
| 120 | + // implementation project(":myproject") |
| 121 | + |
| 122 | + // For more info: |
| 123 | + // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html |
| 124 | + // http://www.gradle.org/docs/current/userguide/dependency_management.html |
| 125 | + |
| 126 | + // implementation "net.neoforged:neoforge:${neo_version}" |
| 127 | + |
| 128 | + /* compileOnly(jarJar("net.kyori:adventure-api:4.17.0")) { |
| 129 | + exclude(module: "adventure-bom") |
| 130 | + exclude(module: "annotations") |
| 131 | + } |
| 132 | + compileOnly(jarJar("net.kyori:adventure-text-serializer-gson:4.17.0")) { |
| 133 | + exclude(module: "adventure-bom") |
| 134 | + exclude(module: "adventure-api") |
| 135 | + exclude(module: "annotations") |
| 136 | + exclude(module: "auto-service-annotations") |
| 137 | + exclude(module: "gson") |
| 138 | + } */ |
| 139 | + |
| 140 | + jarJar(implementation(group: "net.kyori", name: "adventure-platform-neoforge", version: "6.0.0") { |
| 141 | + exclude(module: "annotations") |
| 142 | + exclude(module: "auto-service-annotations") |
| 143 | + exclude(module: "gson") |
| 144 | + }) |
| 145 | + jarJar(implementation ("net.dv8tion:JDA:5.0.2") { |
| 146 | + exclude(module: "opus-java") |
| 147 | + exclude(module: "annotations") |
| 148 | + exclude(module: "slf4j-api") |
| 149 | + }) |
| 150 | + jarJar(implementation ("club.minnced:discord-webhooks:0.8.4") { |
| 151 | + exclude(module: "slf4j-api") |
| 152 | + }) |
| 153 | + jarJar(implementation("org.yaml:snakeyaml:2.2")) |
| 154 | + jarJar(implementation("com.neovisionaries:nv-websocket-client:2.14")) |
| 155 | + jarJar(implementation("com.squareup.okhttp3:okhttp:4.12.0")) |
| 156 | + jarJar(implementation("org.apache.commons:commons-collections4:4.4")) |
| 157 | + jarJar(implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10")) |
| 158 | + jarJar(implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10")) |
| 159 | + jarJar(implementation("org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10")) |
| 160 | + jarJar(implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.10")) |
| 161 | + jarJar(implementation("com.squareup.okio:okio:3.6.0")) |
| 162 | + jarJar(implementation("net.sf.trove4j:core:3.1.0")) |
| 163 | + jarJar(implementation("com.fasterxml.jackson.core:jackson-core:2.17.2")) |
| 164 | + jarJar(implementation("com.fasterxml.jackson:jackson-bom:2.17.2")) |
| 165 | + jarJar(implementation("com.fasterxml.jackson.core:jackson-annotations:2.17.2")) |
| 166 | + jarJar(implementation("com.fasterxml.jackson.core:jackson-databind:2.17.2")) |
| 167 | + jarJar(implementation("org.json:json:20230618")) |
| 168 | + |
| 169 | + shadow(compileOnly(project(path: ":common"))) { |
| 170 | + transitive(false) |
| 171 | + } |
| 172 | + // additionalRuntimeClasspath("org.yaml:snakeyaml:2.2") |
| 173 | + // additionalRuntimeClasspath("net.dv8tion:JDA:5.0.2") |
| 174 | + // additionalRuntimeClasspath("club.minnced:discord-webhooks:0.8.4") |
| 175 | + // additionalRuntimeClasspath("com.cssbham:common:1.0.0") |
| 176 | + // additionalRuntimeClasspath("net.kyori:adventure-api:4.17.0") |
| 177 | + // additionalRuntimeClasspath("net.kyori:adventure-platform-neoforge:6.0.0") |
| 178 | + // additionalRuntimeClasspath("net.kyori:adventure-text-serializer-gson:4.17.0") |
| 179 | +} |
| 180 | + |
| 181 | +// tasks.shadowJar.enabled = false |
| 182 | + |
| 183 | +// This block of code expands all declared replace properties in the specified resource targets. |
| 184 | +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. |
| 185 | +var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { |
| 186 | + var replaceProperties = [ |
| 187 | + minecraft_version : minecraft_version, |
| 188 | + minecraft_version_range: minecraft_version_range, |
| 189 | + neo_version : neo_version, |
| 190 | + neo_version_range : neo_version_range, |
| 191 | + loader_version_range : loader_version_range, |
| 192 | + mod_id : mod_id, |
| 193 | + mod_name : mod_name, |
| 194 | + mod_license : mod_license, |
| 195 | + mod_version : mod_version, |
| 196 | + mod_authors : mod_authors, |
| 197 | + mod_description : mod_description |
| 198 | + ] |
| 199 | + inputs.properties replaceProperties |
| 200 | + expand replaceProperties |
| 201 | + from "src/main/templates" |
| 202 | + into "build/generated/sources/modMetadata" |
| 203 | +} |
| 204 | + |
| 205 | +// Include the output of "generateModMetadata" as an input directory for the build |
| 206 | +// this works with both building through Gradle and the IDE. |
| 207 | +sourceSets.main.resources.srcDir generateModMetadata |
| 208 | +// To avoid having to run "generateModMetadata" manually, make it run on every project reload |
| 209 | +neoForge.ideSyncTask generateModMetadata |
| 210 | + |
| 211 | +// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. |
| 212 | +idea { |
| 213 | + module { |
| 214 | + downloadSources = true |
| 215 | + downloadJavadoc = true |
| 216 | + } |
| 217 | +} |
| 218 | +/* |
| 219 | +tasks.shadowJar { |
| 220 | + configurations = [project.configurations.shadow] |
| 221 | +
|
| 222 | + dependencies { |
| 223 | + exclude(dependency("net.kyori:adventure-platform-neoforge:6.0.0")) |
| 224 | + } |
| 225 | +
|
| 226 | + doLast { |
| 227 | + copy { |
| 228 | + from("build/generated/jarjar/META-INF/jarjar") |
| 229 | + into("META-INF/jarjar") |
| 230 | + } |
| 231 | + } |
| 232 | +
|
| 233 | + // exclude("net/**") |
| 234 | + // exclude("META-INF/services/*") |
| 235 | + // minimize() |
| 236 | +
|
| 237 | + archiveFileName = "cssminecraft-neoforge-${project.version}.jar" |
| 238 | +} |
| 239 | +
|
| 240 | + */ |
| 241 | + |
| 242 | +tasks.shadowJar.enabled = false |
| 243 | +/* |
| 244 | +tasks.register("shadeCommon") { |
| 245 | + copy { |
| 246 | + from("../common/build/classes/main/com/cssbham/cssminecraft/common") |
| 247 | + into("build/classes/") |
| 248 | + } |
| 249 | +} */ |
| 250 | + |
| 251 | +tasks.jar { |
| 252 | + from("../common/build/classes/java/main/com/cssbham/cssminecraft/common") { |
| 253 | + into("com/cssbham/cssminecraft/common") |
| 254 | + } |
| 255 | +} |
| 256 | +/* |
| 257 | +tasks.register("copyJarJar") { |
| 258 | + copy { |
| 259 | + from ("build/generated/jarjar/META-INF/jarjar") |
| 260 | + into("META-INF/jarjar") |
| 261 | + } |
| 262 | +} |
| 263 | +
|
| 264 | +tasks.copyJarJar.dependsOn(jarJar) |
| 265 | +*/ |
| 266 | + |
0 commit comments