|
| 1 | +plugins { |
| 2 | + id 'java-library' |
| 3 | + id 'maven-publish' |
| 4 | + id 'net.neoforged.moddev' version '2.0.105' |
| 5 | + id 'idea' |
| 6 | +} |
| 7 | + |
| 8 | +tasks.named('wrapper', Wrapper).configure { |
| 9 | + distributionType = Wrapper.DistributionType.BIN |
| 10 | +} |
| 11 | + |
| 12 | +version = mod_version |
| 13 | +group = mod_group_id |
| 14 | + |
| 15 | +repositories { |
| 16 | + mavenLocal() |
| 17 | + mavenCentral() |
| 18 | +} |
| 19 | + |
| 20 | +base { |
| 21 | + archivesName = mod_name |
| 22 | +} |
| 23 | + |
| 24 | +java.toolchain.languageVersion = JavaLanguageVersion.of(21) |
| 25 | + |
| 26 | +neoForge { |
| 27 | + version = project.neo_version |
| 28 | + |
| 29 | + parchment { |
| 30 | + mappingsVersion = project.parchment_mappings_version |
| 31 | + minecraftVersion = project.parchment_minecraft_version |
| 32 | + } |
| 33 | + |
| 34 | + accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg') |
| 35 | + |
| 36 | + runs { |
| 37 | + client { |
| 38 | + client() |
| 39 | + |
| 40 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 41 | + } |
| 42 | + |
| 43 | + server { |
| 44 | + server() |
| 45 | + |
| 46 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 47 | + } |
| 48 | + |
| 49 | + gameTestServer { |
| 50 | + type = "gameTestServer" |
| 51 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 52 | + } |
| 53 | + |
| 54 | + data { |
| 55 | + data() |
| 56 | + |
| 57 | + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() |
| 58 | + } |
| 59 | + |
| 60 | + configureEach { |
| 61 | + systemProperty 'forge.logging.markers', 'REGISTRIES' |
| 62 | + logLevel = org.slf4j.event.Level.DEBUG |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + mods { |
| 67 | + // define mod <-> source bindings |
| 68 | + // these are used to tell the game which sources are for which mod |
| 69 | + // multi mod projects should define one per mod |
| 70 | + "${mod_id}" { |
| 71 | + sourceSet(sourceSets.main) |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +// Include resources generated by data generators. |
| 77 | +sourceSets.main.resources { srcDir 'src/generated/resources' } |
| 78 | + |
| 79 | +// Sets up a dependency configuration called 'localRuntime'. |
| 80 | +// This configuration should be used instead of 'runtimeOnly' to declare |
| 81 | +// a dependency that will be present for runtime testing but that is |
| 82 | +// "optional", meaning it will not be pulled by dependents of this mod. |
| 83 | +configurations { |
| 84 | + runtimeClasspath.extendsFrom localRuntime |
| 85 | +} |
| 86 | + |
| 87 | +repositories { |
| 88 | + maven { |
| 89 | + name "Unofficial RotP Maven" |
| 90 | + url "https://raw.githubusercontent.com/BestOrganizationOfCreatingROTPContent/1.21-maven/main" |
| 91 | + |
| 92 | + metadataSources { |
| 93 | + mavenPom() |
| 94 | + artifact() |
| 95 | + } |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +dependencies { |
| 100 | + implementation "net.neoforged:neoforge:${neo_version}" |
| 101 | + implementation "com.github.standobyte.jojo_ripples:RipplesOfThePast-NeoForge-1.21.1:1.21.1-0.4-251119-b" |
| 102 | +} |
| 103 | + |
| 104 | +var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { |
| 105 | + var replaceProperties = [ |
| 106 | + minecraft_version : minecraft_version, |
| 107 | + minecraft_version_range: minecraft_version_range, |
| 108 | + neo_version : neo_version, |
| 109 | + neo_version_range : neo_version_range, |
| 110 | + loader_version_range : loader_version_range, |
| 111 | + mod_id : mod_id, |
| 112 | + mod_version : mod_version, |
| 113 | + mod_name : mod_name |
| 114 | + ] |
| 115 | + inputs.properties replaceProperties |
| 116 | + expand replaceProperties |
| 117 | + from "src/main/templates" |
| 118 | + into "build/generated/sources/modMetadata" |
| 119 | +} |
| 120 | +// Include the output of "generateModMetadata" as an input directory for the build |
| 121 | +// this works with both building through Gradle and the IDE. |
| 122 | +sourceSets.main.resources.srcDir generateModMetadata |
| 123 | +// To avoid having to run "generateModMetadata" manually, make it run on every project reload |
| 124 | +neoForge.ideSyncTask generateModMetadata |
| 125 | + |
| 126 | +// Example configuration to allow publishing using the maven-publish plugin |
| 127 | +publishing { |
| 128 | + publications { |
| 129 | + register('mavenJava', MavenPublication) { |
| 130 | + from components.java |
| 131 | + } |
| 132 | + } |
| 133 | + repositories { |
| 134 | + maven { |
| 135 | + url "file://${project.projectDir}/repo" |
| 136 | + } |
| 137 | + } |
| 138 | +} |
| 139 | + |
| 140 | +tasks.withType(JavaCompile).configureEach { |
| 141 | + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation |
| 142 | +} |
| 143 | + |
| 144 | +// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. |
| 145 | +idea { |
| 146 | + module { |
| 147 | + downloadSources = true |
| 148 | + downloadJavadoc = true |
| 149 | + } |
| 150 | +} |
0 commit comments