Advertisement
Guest User

build.gradle

a guest
Jul 24th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 KB | None | 0 0
  1. buildscript {
  2. repositories {
  3. // These repositories are only for Gradle plugins, put any other repositories in the repository block further below
  4. maven { url = 'https://maven.minecraftforge.net' }
  5. mavenCentral()
  6. }
  7. dependencies {
  8. classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
  9. }
  10. }
  11. apply plugin: 'net.minecraftforge.gradle'
  12. // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
  13. apply plugin: 'eclipse'
  14. apply plugin: 'maven-publish'
  15.  
  16. version = '1.0'
  17. group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  18. archivesBaseName = 'modid'
  19.  
  20. // Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16.
  21. java.toolchain.languageVersion = JavaLanguageVersion.of(16)
  22.  
  23. println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
  24. minecraft {
  25. // The mappings can be changed at any time and must be in the following format.
  26. // Channel: Version:
  27. // snapshot YYYYMMDD Snapshot are built nightly.
  28. // stable # Stables are built at the discretion of the MCP team.
  29. // official MCVersion Official field/method names from Mojang mapping files
  30. //
  31. // You must be aware of the Mojang license when using the 'official' mappings.
  32. // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  33. //
  34. // Use non-default mappings at your own risk. They may not always work.
  35. // Simply re-run your setup task after changing the mappings to update your workspace.
  36. mappings channel: 'official', version: '1.17.1'
  37.  
  38. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
  39.  
  40. // Default run configurations.
  41. // These can be tweaked, removed, or duplicated as needed.
  42. runs {
  43. client {
  44. workingDirectory project.file('run')
  45.  
  46. // Recommended logging data for a userdev environment
  47. // The markers can be added/remove as needed separated by commas.
  48. // "SCAN": For mods scan.
  49. // "REGISTRIES": For firing of registry events.
  50. // "REGISTRYDUMP": For getting the contents of all registries.
  51. property 'forge.logging.markers', 'REGISTRIES'
  52.  
  53. // Recommended logging level for the console
  54. // You can set various levels here.
  55. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  56. property 'forge.logging.console.level', 'debug'
  57.  
  58. mods {
  59. examplemod {
  60. source sourceSets.main
  61. }
  62. }
  63. }
  64.  
  65. server {
  66. workingDirectory project.file('run')
  67.  
  68. // Recommended logging data for a userdev environment
  69. // The markers can be added/remove as needed separated by commas.
  70. // "SCAN": For mods scan.
  71. // "REGISTRIES": For firing of registry events.
  72. // "REGISTRYDUMP": For getting the contents of all registries.
  73. property 'forge.logging.markers', 'REGISTRIES'
  74.  
  75. // Recommended logging level for the console
  76. // You can set various levels here.
  77. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  78. property 'forge.logging.console.level', 'debug'
  79.  
  80. mods {
  81. examplemod {
  82. source sourceSets.main
  83. }
  84. }
  85. }
  86.  
  87. data {
  88. workingDirectory project.file('run')
  89.  
  90. // Recommended logging data for a userdev environment
  91. // The markers can be added/remove as needed separated by commas.
  92. // "SCAN": For mods scan.
  93. // "REGISTRIES": For firing of registry events.
  94. // "REGISTRYDUMP": For getting the contents of all registries.
  95. property 'forge.logging.markers', 'REGISTRIES'
  96.  
  97. // Recommended logging level for the console
  98. // You can set various levels here.
  99. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  100. property 'forge.logging.console.level', 'debug'
  101.  
  102. // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  103. args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  104.  
  105. mods {
  106. examplemod {
  107. source sourceSets.main
  108. }
  109. }
  110. }
  111. }
  112. }
  113.  
  114. // Include resources generated by data generators.
  115. sourceSets.main.resources { srcDir 'src/generated/resources' }
  116.  
  117. repositories {
  118. // Put repositories for dependencies here
  119. // ForgeGradle automatically adds the Forge maven and Maven Central for you
  120.  
  121. // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
  122. // flatDir {
  123. // dir 'libs'
  124. // }
  125. }
  126.  
  127. dependencies {
  128. // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
  129. // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
  130. // The userdev artifact is a special name and will get all sorts of transformations applied to it.
  131. minecraft 'net.minecraftforge:forge:1.17.1-37.0.2'
  132.  
  133. // Real mod deobf dependency examples - these get remapped to your current mappings
  134. // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
  135. // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
  136. // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
  137.  
  138. // Examples using mod jars from ./libs
  139. // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  140.  
  141. // For more info...
  142. // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  143. // http://www.gradle.org/docs/current/userguide/dependency_management.html
  144. }
  145.  
  146. // Example for how to get properties into the manifest for reading at runtime.
  147. jar {
  148. manifest {
  149. attributes([
  150. "Specification-Title" : "examplemod",
  151. "Specification-Vendor" : "examplemodsareus",
  152. "Specification-Version" : "1", // We are version 1 of ourselves
  153. "Implementation-Title" : project.name,
  154. "Implementation-Version" : project.jar.archiveVersion,
  155. "Implementation-Vendor" : "examplemodsareus",
  156. "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  157. ])
  158. }
  159. }
  160.  
  161. // Example configuration to allow publishing using the maven-publish plugin
  162. // This is the preferred method to reobfuscate your jar file
  163. jar.finalizedBy('reobfJar')
  164. // 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
  165. // publish.dependsOn('reobfJar')
  166.  
  167. publishing {
  168. publications {
  169. mavenJava(MavenPublication) {
  170. artifact jar
  171. }
  172. }
  173. repositories {
  174. maven {
  175. url "file://${project.projectDir}/mcmodsrepo"
  176. }
  177. }
  178. }
  179.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement