TGAM123

build.gradle

Jan 6th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. buildscript {
  2. repositories {
  3. maven { url = 'https://files.minecraftforge.net/maven' }
  4. jcenter()
  5. mavenCentral()
  6. }
  7. dependencies {
  8. classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', 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. repositories {
  17. maven { // TOP
  18. name 'tterrag maven'
  19. url "https://maven.tterrag.com/"
  20. }
  21. maven { // Mantle and JEI
  22. name 'DVS1 Maven FS'
  23. url 'https://dvs1.progwml6.com/files/maven'
  24. }
  25. maven {
  26. name "crafttweaker maven"
  27. url "https://maven.blamejared.com"
  28. }
  29. maven {
  30. name 'davenonymous maven'
  31. url "http://maven.davenonymous.com/repository/maven-releases"
  32. }
  33. maven { // HWYLA, last since it 403s anything not present
  34. name "Tehnut Maven FS"
  35. url "https://maven.tehnut.info"
  36. }
  37. }
  38.  
  39. version = "${mod_version}"
  40. group = 'com.davenonymous.bonsaitrees2' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  41. archivesBaseName = 'bonsaitrees2'
  42.  
  43. sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
  44.  
  45. minecraft {
  46. // The mappings can be changed at any time, and must be in the following format.
  47. // snapshot_YYYYMMDD Snapshot are built nightly.
  48. // stable_# Stables are built at the discretion of the MCP team.
  49. // Use non-default mappings at your own risk. they may not always work.
  50. // Simply re-run your setup task after changing the mappings to update your workspace.
  51. mappings channel: "snapshot", version: "${mappings_version}"
  52. // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
  53.  
  54. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
  55.  
  56. // Default run configurations.
  57. // These can be tweaked, removed, or duplicated as needed.
  58. runs {
  59. client {
  60. workingDirectory project.file('run')
  61.  
  62. // Recommended logging data for a userdev environment
  63. property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  64.  
  65. // Recommended logging level for the console
  66. property 'forge.logging.console.level', 'debug'
  67.  
  68. mods {
  69. bonsaitrees2 {
  70. source sourceSets.main
  71. }
  72. }
  73. }
  74.  
  75. server {
  76. workingDirectory project.file('run')
  77.  
  78. // Recommended logging data for a userdev environment
  79. property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  80.  
  81. // Recommended logging level for the console
  82. property 'forge.logging.console.level', 'debug'
  83.  
  84. mods {
  85. bonsaitrees2 {
  86. source sourceSets.main
  87. }
  88. }
  89. }
  90.  
  91. data {
  92. workingDirectory project.file('run')
  93.  
  94. // Recommended logging data for a userdev environment
  95. property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  96.  
  97. // Recommended logging level for the console
  98. property 'forge.logging.console.level', 'debug'
  99.  
  100. args '--mod', 'bonsaitrees2', '--all', '--output', file('src/generated/resources/')
  101.  
  102. mods {
  103. bonsaitrees2 {
  104. source sourceSets.main
  105. }
  106. }
  107. }
  108. }
  109. }
  110.  
  111. dependencies {
  112. // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
  113. // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
  114. // The userdev artifact is a special name and will get all sorts of transformations applied to it.
  115. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
  116.  
  117. // compile against the JEI API but do not include it at runtime
  118. compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api")
  119. // at runtime, use the full JEI jar
  120. runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
  121.  
  122. compile fg.deobf("mcp.mobius.waila:Hwyla:${hwyla_version}_${minecraft_version}")
  123.  
  124. compile fg.deobf("mcjty.theoneprobe:TheOneProbe-${top_version}") {
  125. transitive = false
  126. }
  127.  
  128. compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.15.1:${crafttweaker_version}")
  129.  
  130. if (findProject(':Libnonymous') != null) {
  131. compile project(':Libnonymous')
  132. } else {
  133. compile fg.deobf ("com.davenonymous.libnonymous:libnonymous-1.15.2:${libnonymous_version}:")
  134. }
  135.  
  136. }
  137.  
  138. allprojects {
  139. if (System.getenv("GITHUB_BUILD") != null) {
  140. version += ".${System.getenv("BUILD_NUMBER")}"
  141. }
  142. }
  143.  
  144. // Example for how to get properties into the manifest for reading by the runtime..
  145. jar {
  146. manifest {
  147. attributes([
  148. "Specification-Title": "bonsaitrees2",
  149. "Specification-Vendor": "Davenonymous",
  150. "Specification-Version": "1", // We are version 1 of ourselves
  151. "Implementation-Title": project.name,
  152. "Implementation-Version": "${version}",
  153. "Implementation-Vendor" :"Davenonymous",
  154. "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  155. ])
  156. }
  157. }
  158.  
  159. task sourcesJar(type: Jar) {
  160. classifier = "sources"
  161. from sourceSets.main.allJava
  162. }
  163.  
  164. task deobfJar(type: Jar) {
  165. classifier = "deobf"
  166. from sourceSets.main.output
  167. }
  168.  
  169. def reobfFile = file("$buildDir/reobfJar/output.jar")
  170. def reobfArtifact = artifacts.add('default', reobfFile) {
  171. type 'jar'
  172. builtBy 'reobfJar'
  173. }
  174. publishing {
  175. publications {
  176. mavenJava(MavenPublication) {
  177. artifact reobfArtifact
  178. artifact sourcesJar
  179. artifact deobfJar
  180. }
  181. }
  182. repositories {
  183. maven {
  184. url "file:///${project.projectDir}/mcmodsrepo"
  185. }
  186. maven {
  187. name = "GitHubPackages"
  188. url = uri("https://maven.pkg.github.com/thraaawn/BonsaiTrees")
  189. credentials {
  190. username = System.getenv("GITHUB_ACTOR")
  191. password = System.getenv("GITHUB_TOKEN")
  192. }
  193. }
  194. maven {
  195. name = "davenonymous maven"
  196. url = uri("http://maven.davenonymous.com/repository/maven-releases")
  197. credentials {
  198. username = "davenonymous"
  199. password = System.getenv("DAVE_MAVEN_PASSWORD")
  200. }
  201. }
  202. }
  203. }
  204.  
  205. import groovy.json.JsonSlurper
  206. import groovy.json.JsonOutput
  207.  
  208. processResources {
  209.  
  210. // Minifies all .json files when building the mod.
  211. // Source files are not minified, only the jar copies.
  212. doLast {
  213.  
  214. def jsonMinifyStart = System.currentTimeMillis()
  215. def jsonMinified = 0
  216. def jsonBytesSaved = 0
  217.  
  218. fileTree(dir: outputs.files.asPath, include: '**/*.json').each {
  219.  
  220. File file = it
  221. jsonMinified++
  222. def oldLength = file.length()
  223. file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
  224. jsonBytesSaved += oldLength - file.length()
  225. }
  226.  
  227. println('Minified ' + jsonMinified + ' json files. Saved ' + jsonBytesSaved + ' bytes. Took ' + (System.currentTimeMillis() - jsonMinifyStart) + 'ms.')
  228. }
  229. }
Advertisement
Add Comment
Please, Sign In to add comment