Guest User

build.gradle

a guest
Feb 10th, 2025
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | Source Code | 0 0
  1. plugins {
  2. id 'eclipse'
  3. id 'idea'
  4. id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
  5. }
  6.  
  7.  
  8. group = mod_group_id
  9. version = mod_version
  10.  
  11. base {
  12. archivesName = mod_id
  13. }
  14.  
  15. java {
  16. toolchain.languageVersion = JavaLanguageVersion.of(17)
  17. }
  18.  
  19. minecraft {
  20. // The mappings can be changed at any time and must be in the following format.
  21. // Channel: Version:
  22. // official MCVersion Official field/method names from Mojang mapping files
  23. // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
  24. //
  25. // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
  26. // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  27. //
  28. // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
  29. // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
  30. //
  31. // Use non-default mappings at your own risk. They may not always work.
  32. // Simply re-run your setup task after changing the mappings to update your workspace.
  33. mappings channel: mapping_channel, version: mapping_version
  34.  
  35. // 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.
  36. // In most cases, it is not necessary to enable.
  37. // enableEclipsePrepareRuns = true
  38. // enableIdeaPrepareRuns = true
  39.  
  40. // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
  41. // It is REQUIRED to be set to true for this template to function.
  42. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  43. copyIdeResources = true
  44.  
  45. // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
  46. // The folder name can be set on a run configuration using the "folderName" property.
  47. // By default, the folder name of a run configuration is the name of the Gradle project containing it.
  48. // generateRunFolders = true
  49.  
  50. // This property enables access transformers for use in development.
  51. // They will be applied to the Minecraft artifact.
  52. // The access transformer file can be anywhere in the project.
  53. // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
  54. // This default location is a best practice to automatically put the file in the right place in the final jar.
  55. // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
  56. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
  57.  
  58. // Default run configurations.
  59. // These can be tweaked, removed, or duplicated as needed.
  60. runs {
  61. // applies to all the run configs below
  62. configureEach {
  63. workingDirectory project.file('run')
  64.  
  65. // Recommended logging data for a userdev environment
  66. // The markers can be added/remove as needed separated by commas.
  67. // "SCAN": For mods scan.
  68. // "REGISTRIES": For firing of registry events.
  69. // "REGISTRYDUMP": For getting the contents of all registries.
  70. property 'forge.logging.markers', 'REGISTRIES'
  71.  
  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.  
  117. mavenCentral()
  118.  
  119. }
  120.  
  121. dependencies {
  122.  
  123.  
  124.  
  125. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
  126.  
  127.  
  128.  
  129. }
  130.  
  131. // This block of code expands all declared replace properties in the specified resource targets.
  132. // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
  133. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
  134. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  135. tasks.named('processResources', ProcessResources).configure {
  136. var replaceProperties = [minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
  137. forge_version : forge_version, forge_version_range: forge_version_range,
  138. loader_version_range: loader_version_range,
  139. mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
  140. mod_authors : mod_authors, mod_description: mod_description,]
  141.  
  142. inputs.properties replaceProperties
  143.  
  144. filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
  145. expand replaceProperties + [project: project]
  146. }
  147. }
  148.  
  149. // Example for how to get properties into the manifest for reading at runtime.
  150. tasks.named('jar', Jar).configure {
  151. manifest {
  152. attributes(["Specification-Title" : mod_id,
  153. "Specification-Vendor" : mod_authors,
  154. "Specification-Version" : "1", // We are version 1 of ourselves
  155. "Implementation-Title" : project.name,
  156. "Implementation-Version" : project.jar.archiveVersion,
  157. "Implementation-Vendor" : mod_authors,
  158. "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
  159. }
  160.  
  161. // This is the preferred method to reobfuscate your jar file
  162. finalizedBy 'reobfJar'
  163. }
  164.  
  165. tasks.withType(JavaCompile).configureEach {
  166. options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
  167. }
  168.  
Add Comment
Please, Sign In to add comment