|
| 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 |
| 17 | +} |
| 18 | + |
| 19 | +java.toolchain.languageVersion = JavaLanguageVersion.of(21) |
| 20 | + |
| 21 | +neoForge { |
| 22 | + // Specify the version of NeoForge to use. |
| 23 | + version = project.neo_version |
| 24 | + |
| 25 | + parchment { |
| 26 | + mappingsVersion = project.parchment_mappings_version |
| 27 | + minecraftVersion = project.parchment_minecraft_version |
| 28 | + } |
| 29 | + |
| 30 | + // This line is optional. Access Transformers are automatically detected |
| 31 | + // accessTransformers.add('src/main/resources/META-INF/accesstransformer.cfg') |
| 32 | + |
| 33 | + // Default run configurations. |
| 34 | + // These can be tweaked, removed, or duplicated as needed. |
| 35 | + runs { |
| 36 | + client { |
| 37 | + client() |
| 38 | + |
| 39 | + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. |
| 40 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 41 | + } |
| 42 | + |
| 43 | + server { |
| 44 | + server() |
| 45 | + programArgument '--nogui' |
| 46 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 47 | + } |
| 48 | + |
| 49 | + // This run config launches GameTestServer and runs all registered gametests, then exits. |
| 50 | + // By default, the server will crash when no gametests are provided. |
| 51 | + // The gametest system is also enabled by default for other run configs under the /test command. |
| 52 | + gameTestServer { |
| 53 | + type = "gameTestServer" |
| 54 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 55 | + } |
| 56 | + |
| 57 | + data { |
| 58 | + data() |
| 59 | + |
| 60 | + // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it |
| 61 | + // gameDirectory = project.file('run-data') |
| 62 | + |
| 63 | + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. |
| 64 | + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() |
| 65 | + } |
| 66 | + |
| 67 | + // applies to all the run configs above |
| 68 | + configureEach { |
| 69 | + // Recommended logging data for a userdev environment |
| 70 | + // The markers can be added/remove as needed separated by commas. |
| 71 | + // "SCAN": For mods scan. |
| 72 | + // "REGISTRIES": For firing of registry events. |
| 73 | + // "REGISTRYDUMP": For getting the contents of all registries. |
| 74 | + systemProperty 'forge.logging.markers', 'REGISTRIES' |
| 75 | + |
| 76 | + // Recommended logging level for the console |
| 77 | + // You can set various levels here. |
| 78 | + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels |
| 79 | + logLevel = org.slf4j.event.Level.DEBUG |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + mods { |
| 84 | + // define mod <-> source bindings |
| 85 | + // these are used to tell the game which sources are for which mod |
| 86 | + // mostly optional in a single mod project |
| 87 | + // but multi mod projects should define one per mod |
| 88 | + "${mod_id}" { |
| 89 | + sourceSet(sourceSets.main) |
| 90 | + } |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +// Include resources generated by data generators. |
| 95 | +sourceSets.main.resources { srcDir 'src/generated/resources' } |
| 96 | + |
| 97 | + |
| 98 | +dependencies { |
| 99 | + // Example mod dependency with JEI |
| 100 | + // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime |
| 101 | + // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}" |
| 102 | + // compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}" |
| 103 | + // runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}" |
| 104 | + |
| 105 | + // Example mod dependency using a mod jar from ./libs with a flat dir repository |
| 106 | + // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar |
| 107 | + // The group id is ignored when searching -- in this case, it is "blank" |
| 108 | + // implementation "blank:coolmod-${mc_version}:${coolmod_version}" |
| 109 | + |
| 110 | + // Example mod dependency using a file as dependency |
| 111 | + // implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar") |
| 112 | + |
| 113 | + // Example project dependency using a sister or child project: |
| 114 | + // implementation project(":myproject") |
| 115 | + |
| 116 | + // For more info: |
| 117 | + // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html |
| 118 | + // http://www.gradle.org/docs/current/userguide/dependency_management.html |
| 119 | + |
| 120 | + // implementation "net.neoforged:neoforge:${neo_version}" |
| 121 | + |
| 122 | + implementation ("net.kyori:adventure-api:4.17.0") { |
| 123 | + exclude(module: "adventure-bom") |
| 124 | + exclude(module: "annotations") |
| 125 | + } |
| 126 | + implementation ("net.kyori:adventure-text-serializer-gson:4.17.0") { |
| 127 | + exclude(module: "adventure-bom") |
| 128 | + exclude(module: "adventure-api") |
| 129 | + exclude(module: "annotations") |
| 130 | + exclude(module: "auto-service-annotations") |
| 131 | + exclude(module: "gson") |
| 132 | + } |
| 133 | + |
| 134 | + implementation project(path: ":common", configuration: "shadow") |
| 135 | +} |
| 136 | + |
| 137 | +// This block of code expands all declared replace properties in the specified resource targets. |
| 138 | +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. |
| 139 | +var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { |
| 140 | + var replaceProperties = [ |
| 141 | + minecraft_version : minecraft_version, |
| 142 | + minecraft_version_range: minecraft_version_range, |
| 143 | + neo_version : neo_version, |
| 144 | + neo_version_range : neo_version_range, |
| 145 | + loader_version_range : loader_version_range, |
| 146 | + mod_id : mod_id, |
| 147 | + mod_name : mod_name, |
| 148 | + mod_license : mod_license, |
| 149 | + mod_version : mod_version, |
| 150 | + mod_authors : mod_authors, |
| 151 | + mod_description : mod_description |
| 152 | + ] |
| 153 | + inputs.properties replaceProperties |
| 154 | + expand replaceProperties |
| 155 | + from "src/main/templates" |
| 156 | + into "build/generated/sources/modMetadata" |
| 157 | +} |
| 158 | + |
| 159 | +// Include the output of "generateModMetadata" as an input directory for the build |
| 160 | +// this works with both building through Gradle and the IDE. |
| 161 | +sourceSets.main.resources.srcDir generateModMetadata |
| 162 | +// To avoid having to run "generateModMetadata" manually, make it run on every project reload |
| 163 | +neoForge.ideSyncTask generateModMetadata |
| 164 | + |
| 165 | +// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. |
| 166 | +idea { |
| 167 | + module { |
| 168 | + downloadSources = true |
| 169 | + downloadJavadoc = true |
| 170 | + } |
| 171 | +} |
| 172 | + |
| 173 | +shadowJar { |
| 174 | + dependencies { |
| 175 | + include(project(":common")) |
| 176 | + include(dependency("net.kyori:.*")) |
| 177 | + exclude(dependency("net.neoforged:.*")) |
| 178 | + exclude(dependency("io.github.llamalad7:mixinextras-neoforge:.*")) |
| 179 | + } |
| 180 | + |
| 181 | + relocate "net.kyori", "com.cssbham.cssminecraft.lib.adventure" |
| 182 | + |
| 183 | + archiveFileName = "cssminecraft-neoforge-${project.version}.jar" |
| 184 | + |
| 185 | + minimize() |
| 186 | +} |
0 commit comments