|
| 1 | +plugins { |
| 2 | + id 'java-library' |
| 3 | + id 'idea' |
| 4 | + id 'maven-publish' |
| 5 | + id 'net.neoforged.moddev' version '2.0.78' |
| 6 | + id "me.modmuss50.mod-publish-plugin" version "0.8.3" |
| 7 | +} |
| 8 | + |
| 9 | +tasks.named('wrapper', Wrapper).configure { |
| 10 | + distributionType = Wrapper.DistributionType.BIN |
| 11 | +} |
| 12 | + |
| 13 | +def mcMinorAndPatch = getMinorAndPatchFromMc() |
| 14 | + |
| 15 | +version = "${mcMinorAndPatch}.${mod_version}" |
| 16 | +group = project.maven_group |
| 17 | + |
| 18 | +base { |
| 19 | + archivesName = project.archives_base_name |
| 20 | +} |
| 21 | + |
| 22 | +apply from: 'https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/changelog.gradle' |
| 23 | +apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/publishing.gradle" |
| 24 | + |
| 25 | +java.toolchain.languageVersion = JavaLanguageVersion.of(21) |
| 26 | + |
| 27 | +neoForge { |
| 28 | + version = "${mcMinorAndPatch}.${neo_version}" |
| 29 | + |
| 30 | + parchment { |
| 31 | + mappingsVersion = project.parchment_mappings_version |
| 32 | + minecraftVersion = project.parchment_minecraft_version.replace("\${mc_version}", minecraft_version) |
| 33 | + } |
| 34 | + |
| 35 | + runs { |
| 36 | + configureEach { |
| 37 | + systemProperty 'forge.logging.markers', 'REGISTRIES' |
| 38 | + logLevel = org.slf4j.event.Level.DEBUG |
| 39 | + } |
| 40 | + |
| 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 | + gameTestServer { |
| 55 | + type = "gameTestServer" |
| 56 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 57 | + } |
| 58 | + |
| 59 | + data { |
| 60 | + data() |
| 61 | + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + mods { |
| 66 | + "${mod_id}" { |
| 67 | + sourceSet(sourceSets.main) |
| 68 | + } |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +sourceSets.main.resources { srcDir 'src/generated/resources' } |
| 73 | + |
| 74 | +// Sets up a dependency configuration called 'localRuntime'. |
| 75 | +// This configuration should be used instead of 'runtimeOnly' to declare |
| 76 | +// a dependency that will be present for runtime testing but that is |
| 77 | +// "optional", meaning it will not be pulled by dependents of this mod. |
| 78 | +configurations { |
| 79 | + runtimeClasspath.extendsFrom localRuntime |
| 80 | +} |
| 81 | + |
| 82 | +repositories { |
| 83 | + maven { |
| 84 | + url = "https://maven.ftb.dev/releases" |
| 85 | + content = { |
| 86 | + includeGroup("dev.ftb.mods") |
| 87 | + } |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +dependencies { |
| 92 | + implementation "dev.ftb.mods:ftb-library-neoforge:${ftb_library_version}" |
| 93 | +} |
| 94 | + |
| 95 | +tasks.register("sourcesJar", Jar) { |
| 96 | + archiveClassifier.set("sources") |
| 97 | + from sourceSets.main.allJava |
| 98 | +} |
| 99 | + |
| 100 | +// Uncomment this if you want to create an API jar |
| 101 | +// tasks.register("apiJar", Jar) { |
| 102 | +// archiveClassifier.set("api") |
| 103 | + |
| 104 | +// from sourceSets.main.output |
| 105 | + |
| 106 | +// include 'dev/ftb/mods/{package_name}/api/**' |
| 107 | +// } |
| 108 | + |
| 109 | +tasks.named("jar") { |
| 110 | + dependsOn("sourcesJar") |
| 111 | + // Uncomment this if you want to create an API jar |
| 112 | + // dependsOn("apiJar") |
| 113 | +} |
| 114 | + |
| 115 | +tasks.withType(ProcessResources).configureEach { |
| 116 | + var replaceProperties = [ |
| 117 | + version: version, |
| 118 | + mod_id: mod_id, |
| 119 | + mod_name: mod_name, |
| 120 | + pack_format: pack_format, |
| 121 | + loader_version_range: loader_version_range, |
| 122 | + // 99.9% of the time we're only going to target a very vague version of neoforge so this is fine. |
| 123 | + mod_loader_range: mod_loader_range.replace("\${mc_base}", mcMinorAndPatch), // Replace the version in the mod loader range |
| 124 | + ] |
| 125 | + |
| 126 | + inputs.properties replaceProperties |
| 127 | + |
| 128 | + filesMatching(['META-INF/neoforge.mods.toml', 'pack.mcmeta']) { |
| 129 | + expand replaceProperties |
| 130 | + } |
| 131 | + |
| 132 | + // Copy in the repos license file |
| 133 | + from(project.rootDir) { |
| 134 | + include 'LICENSE.md' |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | +tasks.withType(JavaCompile).configureEach { |
| 139 | + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation |
| 140 | +} |
| 141 | + |
| 142 | +idea { |
| 143 | + module { |
| 144 | + downloadSources = true |
| 145 | + downloadJavadoc = true |
| 146 | + } |
| 147 | +} |
| 148 | + |
| 149 | +def getMinorAndPatchFromMc() { |
| 150 | + String mcVersion = project.minecraft_version |
| 151 | + String[] split = mcVersion.split("\\.") |
| 152 | + return split[1] + "." + (split[2] ?: "0") |
| 153 | +} |
| 154 | + |
| 155 | +publishMods { |
| 156 | + def CFToken = providers.environmentVariable("CURSEFORGE_KEY"); |
| 157 | + |
| 158 | + dryRun = !CFToken.isPresent() |
| 159 | + displayName = "[NEOFORGE] ${mod_name} ${version}" |
| 160 | + modLoaders.add("neoforge") |
| 161 | + |
| 162 | + changelog = createChangelog(project) |
| 163 | + file = jar.archiveFile |
| 164 | + version = project.version // Pretty sure it defaults to this |
| 165 | + |
| 166 | + def tag = providers.environmentVariable("TAG").getOrElse("release") |
| 167 | + type = tag.endsWith("-beta") ? BETA : (tag.endsWith("-alpha") ? ALPHA : STABLE) |
| 168 | + |
| 169 | + curseforge { |
| 170 | + accessToken = CFToken.orElse("missing") |
| 171 | + projectId = project.curseforge_id |
| 172 | + minecraftVersions.add(project.minecraft_version) |
| 173 | + javaVersions.add(JavaVersion.VERSION_21) |
| 174 | + } |
| 175 | +} |
| 176 | + |
| 177 | +publishing { |
| 178 | + publications { |
| 179 | + register('mavenJava', MavenPublication) { |
| 180 | + from components.java |
| 181 | + artifact sourcesJar |
| 182 | + // Uncomment this if you want to create an API jar |
| 183 | + // artifact apiJar |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + repositories { |
| 188 | + if (ftbPublishing.ftbToken) { |
| 189 | + maven { |
| 190 | + url ftbPublishing.ftbURL |
| 191 | + credentials { |
| 192 | + username = ftbPublishing.ftbUser |
| 193 | + password = ftbPublishing.ftbToken |
| 194 | + } |
| 195 | + } |
| 196 | + } |
| 197 | + } |
| 198 | +} |
0 commit comments