mysticdrew

Untitled

Oct 28th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1. plugins {
  2. id "net.minecraftforge.gradle.forge" version "2.0.2"
  3. }
  4.  
  5. //apply plugin: 'forge'
  6. //apply plugin: 'java'
  7.  
  8. // Fixes bug in IDEA 14 that wasn't putting resources into build/classes
  9. sourceSets {
  10. main { output.resourcesDir = output.classesDir }
  11. }
  12.  
  13. ext {
  14. configFile = file "project.properties"
  15. srcWebDir = "src/main/resources/assets/journeymap/web/"
  16. implSrc = "build/resources/java/journeymap/feature/impl/"
  17. }
  18.  
  19. configFile.withReader {
  20. def prop = new Properties()
  21. prop.load(it)
  22. project.ext.config = new ConfigSlurper().parse prop
  23. }
  24.  
  25. version = "${config.minecraft_version}-${config.jm_major}.${config.jm_minor}.${config.jm_micro}${config.jm_patch}"
  26. group = "${config.group_id}"
  27. archivesBaseName = "${config.mod_id}".toLowerCase()
  28.  
  29. minecraft {
  30. version = "${config.minecraft_version}-${config.forge_version}"
  31. runDir = "run"
  32.  
  33. replace "@JMVERSION@", "${config.jm_major}.${config.jm_minor}.${config.jm_micro}${config.jm_patch}"
  34. replace "@MCVERSION@", config.minecraft_version
  35. replace "@FORGEVERSION@", config.forge_version
  36. replace "@MAJOR@", config.jm_major
  37. replace "@MINOR@", config.jm_minor
  38. replace "@MICRO@", config.jm_micro
  39. replace "@PATCH@", config.jm_patch
  40. mappings = "${config.snapshot}"
  41. }
  42.  
  43. dependencies {
  44. compile fileTree(dir: 'libs', include: '*.*');
  45. }
  46.  
  47. processResources {
  48. // // this will ensure that this task is redone when the versions change.
  49. // inputs.property "version", project.version
  50. // inputs.property "mcversion", project.minecraft.version
  51. //
  52. // from(sourceSets.main.resources.srcDirs) {
  53. // include 'license.txt'
  54. // expand 'version': project.version, 'mcversion': project.minecraft.version, 'date' : getDate()
  55. // }
  56. // // copy everything else, thats not the mcmod.info
  57. // from(sourceSets.main.resources.srcDirs) {
  58. // exclude 'mcmod.info'
  59. // exclude 'license.txt'
  60. // }
  61. }
  62.  
  63. task copyJs(type: Copy) {
  64. from 'tmp'
  65. into 'build/resources/main/assets/journeymap/web/css'
  66. include 'journeymap.css'
  67. }
  68.  
  69. task copyCss(type: Copy, dependsOn: copyJs) {
  70. from 'tmp'
  71. into 'build/resources/main/assets/journeymap/web/js'
  72. include 'journeymap.js'
  73. }
  74.  
  75. task filter() {
  76. def subdir = new File("tmp")
  77.  
  78. if( !subdir.exists() ) {
  79. subdir.mkdirs()
  80. }
  81. }
  82.  
  83. task minifyJs(type: JavaExec, dependsOn: filter) {
  84. ant.java(jar:"libs/yuicompressor-2.4.7.jar",fork:true)
  85. {
  86. arg(value: "${srcWebDir}js/journeymap.js")
  87. arg(value: "-o")
  88. arg(value: "tmp/journeymap.js")
  89. }
  90. }
  91.  
  92. task minifyCss(type: JavaExec, dependsOn: filter) {
  93. ant.java(jar:"libs/yuicompressor-2.4.7.jar",fork:true)
  94. {
  95. arg(value: "${srcWebDir}css/journeymap.css")
  96. arg(value: "-o")
  97. arg(value: "tmp/journeymap.css")
  98. }
  99. }
  100.  
  101. task deleteNoRadar(type: Delete) {
  102. delete '${implSrc}NoRadar.java'
  103. }
  104.  
  105. task deleteUnlimited(type: Delete) {
  106. delete '${implSrc}Unlimited.java'
  107. }
  108.  
  109. task unlimitedJar(type: Jar, dependsOn: ['copyCss', 'deleteNoRadar']) {
  110. version = "${version}-${config.unlimited}".toLowerCase()
  111.  
  112. from(sourceSets.main.output) {
  113. exclude("journeymap/client/feature/impl/NoRadar.class")
  114. }
  115. from(sourceSets.main.resources.srcDirs) {
  116. include 'mcmod.info'
  117. expand 'version': project.version, 'mcversion': project.minecraft.version, 'forgeversion' : config.forge_version, jmedition : config.unlimited
  118. }
  119. }
  120.  
  121. task fairPlayJar(type: Jar, dependsOn: ['copyCss', 'deleteNoRadar', 'deleteUnlimited']) {
  122. version = "${version}-${config.fairPlay}".toLowerCase()
  123. from(sourceSets.main.output) {
  124. exclude("journeymap/client/feature/impl/Unlimited.class")
  125. exclude("journeymap/client/feature/impl/NoRadar.class")
  126. }
  127.  
  128. from(sourceSets.main.resources.srcDirs) {
  129. include 'mcmod.info'
  130. expand 'version': project.version, 'mcversion': project.minecraft.version, 'forgeversion' : config.forge_version, jmedition : config.fairPlay
  131. }
  132. }
  133.  
  134. artifacts.archives unlimitedJar, fairPlayJar
  135.  
  136. reobf {
  137. unlimitedJar {}
  138. fairPlayJar {}
  139. }
  140. /*
  141. def reobf {
  142. reobf (unlimitedJar) { spec ->
  143. spec.classpath = sourceSets.main.compileClasspath;
  144. }
  145. reobf (fairPlayJar) { spec ->
  146. spec.classpath = sourceSets.main.compileClasspath;
  147. }
  148. }
  149. */
  150.  
  151. task makePretty(type: Delete) {
  152. delete "build/libs/${archivesBaseName}-${version}.jar"
  153. delete '/tmp/'
  154. }
  155.  
  156. def getDate() {
  157. def date = new Date()
  158. def formattedDate = date.format(config.dateFormat)
  159. return formattedDate
  160. }
  161.  
  162. build.dependsOn makePretty
Advertisement
Add Comment
Please, Sign In to add comment