TomsYaLad

build.gradle file

Nov 17th, 2025
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.19 KB | Help | 0 0
  1. plugins {
  2. id 'eclipse'
  3. id 'idea'
  4. id 'maven-publish'
  5. id 'net.minecraftforge.gradle' version '[6.0,6.2)'
  6. id 'org.parchmentmc.librarian.forgegradle' version '1.+'
  7. }
  8.  
  9. version = mod_version
  10. group = mod_group_id
  11.  
  12. base {
  13. archivesName = mod_id
  14. }
  15.  
  16. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
  17. java.toolchain.languageVersion = JavaLanguageVersion.of(17)
  18.  
  19. println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
  20. minecraft {
  21. // The mappings can be changed at any time and must be in the following format.
  22. // Channel: Version:
  23. // official MCVersion Official field/method names from Mojang mapping files
  24. // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
  25. //
  26. // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
  27. // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  28. //
  29. // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
  30. // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
  31. //
  32. // Use non-default mappings at your own risk. They may not always work.
  33. // Simply re-run your setup task after changing the mappings to update your workspace.
  34. mappings channel: mapping_channel, version: mapping_version
  35.  
  36. // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
  37. // In most cases, it is not necessary to enable.
  38. // enableEclipsePrepareRuns = true
  39. // enableIdeaPrepareRuns = true
  40.  
  41. // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
  42. // It is REQUIRED to be set to true for this template to function.
  43. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  44. copyIdeResources = true
  45.  
  46. // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
  47. // The folder name can be set on a run configuration using the "folderName" property.
  48. // By default, the folder name of a run configuration is the name of the Gradle project containing it.
  49. // generateRunFolders = true
  50.  
  51. // This property enables access transformers for use in development.
  52. // They will be applied to the Minecraft artifact.
  53. // The access transformer file can be anywhere in the project.
  54. // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
  55. // This default location is a best practice to automatically put the file in the right place in the final jar.
  56. // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
  57. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
  58.  
  59. // Default run configurations.
  60. // These can be tweaked, removed, or duplicated as needed.
  61. runs {
  62. // applies to all the run configs below
  63. configureEach {
  64. workingDirectory project.file('run')
  65.  
  66. // Recommended logging data for a userdev environment
  67. // The markers can be added/remove as needed separated by commas.
  68. // "SCAN": For mods scan.
  69. // "REGISTRIES": For firing of registry events.
  70. // "REGISTRYDUMP": For getting the contents of all registries.
  71. property 'forge.logging.markers', 'REGISTRIES'
  72.  
  73. // Recommended logging level for the console
  74. // You can set various levels here.
  75. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  76. property 'forge.logging.console.level', 'debug'
  77.  
  78. mods {
  79. "${mod_id}" {
  80. source sourceSets.main
  81. }
  82. }
  83. }
  84.  
  85. client {
  86. // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  87. property 'forge.enabledGameTestNamespaces', mod_id
  88. }
  89.  
  90. server {
  91. property 'forge.enabledGameTestNamespaces', mod_id
  92. args '--nogui'
  93. }
  94.  
  95. // This run config launches GameTestServer and runs all registered gametests, then exits.
  96. // By default, the server will crash when no gametests are provided.
  97. // The gametest system is also enabled by default for other run configs under the /test command.
  98. gameTestServer {
  99. property 'forge.enabledGameTestNamespaces', mod_id
  100. }
  101.  
  102. data {
  103. // example of overriding the workingDirectory set in configureEach above
  104. workingDirectory project.file('run-data')
  105.  
  106. // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  107. args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  108. }
  109. }
  110. }
  111.  
  112. // Include resources generated by data generators.
  113. sourceSets.main.resources { srcDir 'src/generated/resources' }
  114.  
  115. repositories {
  116. // Put repositories for dependencies here
  117. // ForgeGradle automatically adds the Forge maven and Maven Central for you
  118.  
  119. // If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
  120. // See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
  121. // flatDir {
  122. // dir 'libs'
  123. // }
  124. maven { url "https://www.cursemaven.com" }
  125. maven { url "https://maven.teamabnormals.com" }
  126. maven { url "https://dvs1.progwml6.com/files/maven/" }
  127. maven { url "https://modmaven.k-4u.nl" }
  128. }
  129.  
  130. dependencies {
  131. // Specify the version of Minecraft to use.
  132. // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
  133. // The "userdev" classifier will be requested and setup by ForgeGradle.
  134. // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
  135. // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
  136. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
  137. implementation(fg.deobf("curse.maven:blueprint-382216:6408581"))
  138. implementation(fg.deobf("curse.maven:caverns_and_chasms-438005:6040957"))
  139. // runtimeOnly(fg.deobf("curse.maven:jei-238222:5101366"))
  140.  
  141. // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
  142. // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
  143. // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
  144. // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
  145. // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
  146.  
  147. // Example mod dependency using a mod jar from ./libs with a flat dir repository
  148. // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
  149. // The group id is ignored when searching -- in this case, it is "blank"
  150. // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  151.  
  152. // For more info:
  153. // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  154. // http://www.gradle.org/docs/current/userguide/dependency_management.html
  155. }
  156.  
  157. // This block of code expands all declared replace properties in the specified resource targets.
  158. // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
  159. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
  160. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  161. tasks.named('processResources', ProcessResources).configure {
  162. var replaceProperties = [
  163. minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
  164. forge_version: forge_version, forge_version_range: forge_version_range,
  165. loader_version_range: loader_version_range,
  166. mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
  167. mod_authors: mod_authors, mod_description: mod_description,
  168. ]
  169. inputs.properties replaceProperties
  170.  
  171. filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
  172. expand replaceProperties + [project: project]
  173. }
  174. }
  175.  
  176. // Example for how to get properties into the manifest for reading at runtime.
  177. tasks.named('jar', Jar).configure {
  178. manifest {
  179. attributes([
  180. 'Specification-Title' : mod_id,
  181. 'Specification-Vendor' : mod_authors,
  182. 'Specification-Version' : '1', // We are version 1 of ourselves
  183. 'Implementation-Title' : project.name,
  184. 'Implementation-Version' : project.jar.archiveVersion,
  185. 'Implementation-Vendor' : mod_authors,
  186. 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  187. ])
  188. }
  189.  
  190. // This is the preferred method to reobfuscate your jar file
  191. finalizedBy 'reobfJar'
  192. }
  193.  
  194. // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
  195. // tasks.named('publish').configure {
  196. // dependsOn 'reobfJar'
  197. // }
  198.  
  199. // Example configuration to allow publishing using the maven-publish plugin
  200. publishing {
  201. publications {
  202. register('mavenJava', MavenPublication) {
  203. artifact jar
  204. }
  205. }
  206. repositories {
  207. maven {
  208. url "file://${project.projectDir}/mcmodsrepo"
  209. }
  210. }
  211. }
  212.  
  213. tasks.withType(JavaCompile).configureEach {
  214. options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
  215. }
Add Comment
Please, Sign In to add comment