|
| 1 | +plugins { |
| 2 | + id 'java-library' |
| 3 | + id 'maven-publish' |
| 4 | + id 'idea' |
| 5 | + id 'net.neoforged.moddev' version '2.0.140' |
| 6 | +} |
| 7 | + |
| 8 | +version = mod_version |
| 9 | +group = mod_group_id |
| 10 | + |
| 11 | +repositories { |
| 12 | + mavenLocal() |
| 13 | + mavenCentral() |
| 14 | + maven { |
| 15 | + name = "TerraformersMC" |
| 16 | + url = "https://maven.terraformersmc.com/" |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +base { |
| 21 | + archivesName = mod_id |
| 22 | +} |
| 23 | + |
| 24 | +java.toolchain.languageVersion = JavaLanguageVersion.of(21) |
| 25 | + |
| 26 | +neoForge { |
| 27 | + // Specify the version of NeoForge to use. |
| 28 | + version = project.neo_version |
| 29 | + |
| 30 | + parchment { |
| 31 | + mappingsVersion = project.parchment_mappings_version |
| 32 | + minecraftVersion = project.parchment_minecraft_version |
| 33 | + } |
| 34 | + |
| 35 | + // This line is optional. Access Transformers are automatically detected |
| 36 | + // accessTransformers.add('src/main/resources/META-INF/accesstransformer.cfg') |
| 37 | + |
| 38 | + // Default run configurations. |
| 39 | + // These can be tweaked, removed, or duplicated as needed. |
| 40 | + runs { |
| 41 | + client { |
| 42 | + client() |
| 43 | + |
| 44 | + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. |
| 45 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 46 | + } |
| 47 | + |
| 48 | + server { |
| 49 | + server() |
| 50 | + programArgument '--nogui' |
| 51 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 52 | + } |
| 53 | + |
| 54 | + // This run config launches GameTestServer and runs all registered gametests, then exits. |
| 55 | + // By default, the server will crash when no gametests are provided. |
| 56 | + // The gametest system is also enabled by default for other run configs under the /test command. |
| 57 | + gameTestServer { |
| 58 | + type = "gameTestServer" |
| 59 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 60 | + } |
| 61 | + |
| 62 | + data { |
| 63 | + data() |
| 64 | + |
| 65 | + // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it |
| 66 | + // gameDirectory = project.file('run-data') |
| 67 | + |
| 68 | + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. |
| 69 | + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() |
| 70 | + } |
| 71 | + |
| 72 | + // applies to all the run configs above |
| 73 | + configureEach { |
| 74 | + // Recommended logging data for a userdev environment |
| 75 | + // The markers can be added/remove as needed separated by commas. |
| 76 | + // "SCAN": For mods scan. |
| 77 | + // "REGISTRIES": For firing of registry events. |
| 78 | + // "REGISTRYDUMP": For getting the contents of all registries. |
| 79 | + systemProperty 'forge.logging.markers', 'REGISTRIES' |
| 80 | + |
| 81 | + // Recommended logging level for the console |
| 82 | + // You can set various levels here. |
| 83 | + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels |
| 84 | + logLevel = org.slf4j.event.Level.DEBUG |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + mods { |
| 89 | + // define mod <-> source bindings |
| 90 | + // these are used to tell the game which sources are for which mod |
| 91 | + // mostly optional in a single mod project |
| 92 | + // but multi mod projects should define one per mod |
| 93 | + "${mod_id}" { |
| 94 | + sourceSet(sourceSets.main) |
| 95 | + } |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +// Include resources generated by data generators. |
| 100 | +sourceSets.main.resources { srcDir 'src/generated/resources' } |
| 101 | + |
| 102 | + |
| 103 | +dependencies { |
| 104 | + implementation "org.appliedenergistics:appliedenergistics2:${ae2_version}" |
| 105 | + implementation "dev.emi:emi-neoforge:${emi_version}" |
| 106 | +} |
| 107 | + |
| 108 | +// This block of code expands all declared replace properties in the specified resource targets. |
| 109 | +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. |
| 110 | +var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { |
| 111 | + var replaceProperties = [minecraft_version : minecraft_version, |
| 112 | + minecraft_version_range: minecraft_version_range, |
| 113 | + neo_version : neo_version, |
| 114 | + neo_version_range : neo_version_range, |
| 115 | + loader_version_range : loader_version_range, |
| 116 | + mod_id : mod_id, |
| 117 | + mod_name : mod_name, |
| 118 | + mod_license : mod_license, |
| 119 | + mod_version : mod_version, |
| 120 | + mod_authors : mod_authors, |
| 121 | + mod_description : mod_description, |
| 122 | + ae2_version : ae2_version, |
| 123 | + emi_version : emi_version, |
| 124 | + ] |
| 125 | + inputs.properties replaceProperties |
| 126 | + expand replaceProperties |
| 127 | + from "src/main/templates" |
| 128 | + into "build/generated/sources/modMetadata" |
| 129 | +} |
| 130 | + |
| 131 | +// Include the output of "generateModMetadata" as an input directory for the build |
| 132 | +// this works with both building through Gradle and the IDE. |
| 133 | +sourceSets.main.resources.srcDir generateModMetadata |
| 134 | +// To avoid having to run "generateModMetadata" manually, make it run on every project reload |
| 135 | +neoForge.ideSyncTask generateModMetadata |
| 136 | + |
| 137 | +// Example configuration to allow publishing using the maven-publish plugin |
| 138 | +publishing { |
| 139 | + publications { |
| 140 | + register('mavenJava', MavenPublication) { |
| 141 | + from components.java |
| 142 | + } |
| 143 | + } |
| 144 | + repositories { |
| 145 | + maven { |
| 146 | + url "file://${project.projectDir}/repo" |
| 147 | + } |
| 148 | + } |
| 149 | +} |
| 150 | + |
| 151 | +// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. |
| 152 | +idea { |
| 153 | + module { |
| 154 | + downloadSources = true |
| 155 | + downloadJavadoc = true |
| 156 | + } |
| 157 | +} |
0 commit comments