Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.98 KB | None | 0 0
  1. buildscript {
  2. repositories {
  3. jcenter()
  4. maven {
  5. name = "forge"
  6. url = "http://files.minecraftforge.net/maven"
  7. }
  8. }
  9. dependencies {
  10. classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
  11. }
  12. }
  13.  
  14. plugins {
  15. id "org.sonarqube" version "2.3"
  16. id "com.matthewprenger.cursegradle" version "1.0.7"
  17. }
  18.  
  19. repositories {
  20. maven {
  21. name 'DVS1 Maven FS'
  22. url 'http://dvs1.progwml6.com/files/maven'
  23. }
  24. maven {
  25. url 'http://dogforce-games.com/maven'
  26. }
  27. }
  28.  
  29. sonarqube {
  30. properties{
  31. property "sonar.host.url", "http://home.kk-sc.de:9000"
  32. property "sonar.sourceEncoding", "UTF-8"
  33. property "sonar.projectName", "Minecolonies"
  34. property "sonar.branch", System.getenv()['TEAMCITY_BRANCH'] != null ? System.getenv()['TEAMCITY_BRANCH'] : System.getenv()['TRAVIS_BRANCH']
  35. }
  36. }
  37.  
  38. apply plugin: 'idea'
  39. apply plugin: 'net.minecraftforge.gradle.forge'
  40. apply plugin: 'jacoco'
  41.  
  42. jacocoTestReport {
  43. reports {
  44. xml.enabled true
  45. }
  46. }
  47.  
  48. sourceSets {
  49. api {
  50. java {
  51. srcDir 'src/api/java'
  52. }
  53. resources {
  54. srcDir 'src/api/resources'
  55. }
  56. }
  57. blockOut {
  58. java {
  59. srcDir 'src/blockout/java'
  60. }
  61. resources {
  62. srcDir 'src/blockout/resources'
  63. }
  64. compileClasspath += sourceSets.api.compileClasspath
  65. }
  66. structures {
  67. java {
  68. srcDir 'src/structures/java'
  69. }
  70. resources {
  71. srcDir 'src/structures/resources'
  72. }
  73. compileClasspath += sourceSets.api.compileClasspath
  74. }
  75. main {
  76. java {
  77. srcDir 'src/main/java'
  78. }
  79. resources {
  80. srcDir 'src/main/resources'
  81. }
  82. compileClasspath += sourceSets.structures.output
  83. compileClasspath += sourceSets.blockOut.output
  84. compileClasspath += sourceSets.api.output
  85. }
  86. test {
  87. java {
  88. srcDir 'src/test/java'
  89. }
  90. resources {
  91. srcDir 'src/test/resources'
  92. }
  93. }
  94. }
  95.  
  96.  
  97. ext.configFile = file "build.properties"
  98.  
  99. configFile.withReader {
  100. def prop = new Properties()
  101. prop.load(it)
  102. ext.config = new ConfigSlurper().parse prop
  103. }
  104.  
  105. dependencies {
  106. deobfCompile "slimeknights.mantle:Mantle:${config.minecraft_version}-${config.mantle_version}"
  107. deobfCompile "slimeknights:TConstruct:${config.minecraft_version}-${config.tconstruct_version}"
  108.  
  109. structuresCompile sourceSets.api.output
  110. //blockOutCompile sourceSets.api.output
  111.  
  112. deobfCompile "gigaherz.guidebook:Guidebook-${config.minecraft_version}:${config.guidebook_version}"
  113.  
  114. testCompile sourceSets.structures.output
  115. testCompile sourceSets.blockOut.output
  116.  
  117. testCompile 'junit:junit:4.11'
  118. testCompile "org.mockito:mockito-core:1.+"
  119. testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.6.5'
  120. testCompile group: 'org.powermock', name: 'powermock-api-mockito', version: '1.6.5'
  121. testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
  122.  
  123. compile 'com.intellij:annotations:+@jar'
  124. }
  125.  
  126. group = "com.minecolonies"
  127. config.buildnumber = System.getenv()['BUILD_NUMBER'] != null ? System.getenv()['BUILD_NUMBER'] : System.getenv()['TRAVIS_BUILD_NUMBER']
  128.  
  129. if (project.hasProperty("teamcity")) {
  130. config.buildnumber = project.teamcity["teamcity.build.id"]
  131. }
  132.  
  133. version = "${config.minecraft_version}-${config.minecolonies_major}.${config.minecolonies_minor}.${config.buildnumber}"
  134.  
  135. sourceCompatibility = '1.8'
  136. targetCompatibility = '1.8'
  137.  
  138. minecraft {
  139.  
  140. version = config.minecraft_version + "-" + config.forge_version
  141. runDir = "run"
  142.  
  143. mappings = "${config.minecolonies_mappings}"
  144.  
  145. replaceIn "lib/Constants.java"
  146. replace "@VERSION@", project.version
  147.  
  148. // Set the jar signature in code prior to compilation, if it exists as a build property
  149. if (project.hasProperty("signature")) {
  150. replace "@FINGERPRINT@", project.signature
  151. }
  152. }
  153.  
  154. processResources {
  155.  
  156. inputs.property "version", project.version
  157. inputs.property "mcversion", project.minecraft.version
  158.  
  159. from(sourceSets.main.resources.srcDirs) {
  160. include 'mcmod.info'
  161. expand 'version': project.version, 'mcversion': project.minecraft.version
  162. }
  163.  
  164. from(sourceSets.main.resources.srcDirs) {
  165. exclude 'mcmod.info'
  166. }
  167. }
  168.  
  169. compileJava {
  170. options.encoding = 'UTF-8'
  171. options.compilerArgs << "-Xlint"
  172. }
  173.  
  174. task apiJar(type: Jar) {
  175. from sourceSets.api.output
  176. classifier 'api'
  177. }
  178.  
  179. task blockOutJar(type: Jar) {
  180. from sourceSets.blockOut.output
  181. classifier 'blockOut'
  182. }
  183.  
  184. task structuresJar(type: Jar){
  185. from sourceSets.structures.output
  186. classifier 'structures'
  187. }
  188.  
  189. task deobfJar(type: Jar) {
  190. from sourceSets.main.output
  191. appendix = 'deobf'
  192. }
  193.  
  194. task incrementBuildNumber() {
  195. dependsOn "reobf"
  196. doLast {
  197. config.minecolonies_build = (config.minecolonies_build.toString().toInteger()) + 1
  198.  
  199. configFile.withWriter {
  200. config.toProperties().store(it, "")
  201. }
  202. }
  203. }
  204.  
  205. jar {
  206. from sourceSets.api.output
  207. from sourceSets.blockOut.output
  208. from sourceSets.structures.output
  209. from sourceSets.main.output
  210.  
  211. dependsOn apiJar
  212. dependsOn blockOutJar
  213. dependsOn structuresJar
  214. dependsOn deobfJar
  215. appendix = 'universal'
  216. archiveName = "minecolonies-universal-" + project.version + ".jar"
  217.  
  218. manifest {
  219. attributes 'FMLAT': "minecolonies_at.cfg"
  220. }
  221. }
  222.  
  223. javadoc {
  224. source += sourceSets.api.allSource
  225. source += sourceSets.blockOut.allSource
  226. source += sourceSets.structures.allSource
  227. }
  228.  
  229. idea {
  230. module {
  231. inheritOutputDirs = true
  232. }
  233. }
  234.  
  235. task copyToLib(type: Copy) {
  236. // into "build/lib"
  237. into "lib"
  238. from configurations.runtime
  239. }
  240.  
  241. task runCheckStyle(type: Checkstyle) {
  242. description 'Runs Checkstyle inspection against Minecolonies sourcesets.'
  243. group = 'Code Quality'
  244.  
  245. ignoreFailures = true
  246. showViolations = false
  247.  
  248. source 'src/main/java'
  249.  
  250. include '**/*.java'
  251.  
  252. exclude '**/com/minecolonies/blockout/**'
  253.  
  254. classpath = files()
  255. }
  256.  
  257. task runPMD(type: Pmd) {
  258. description 'Runs PMD inspection against Minecolonies sourcesets.'
  259. group = 'Code Quality'
  260.  
  261. ignoreFailures = true
  262.  
  263. source 'src/main/java'
  264.  
  265. include '**/*.java'
  266.  
  267. exclude '**/com/minecolonies/blockout/**'
  268.  
  269. classpath = files()
  270. }
  271.  
  272. task runSonar() {
  273. dependsOn runCheckStyle, runPMD
  274. description 'Runs the equivalent of a SonarQube analysis directly in the build process. Calls runCheckStyle and runPMD'
  275. group = 'Code Quality'
  276. }
  277.  
  278. task signJar(type: SignJar, dependsOn: reobfJar) {
  279. onlyIf { // Skip the task if our secret data isn't available
  280. project.hasProperty('keyStore')
  281. }
  282.  
  283. if (project.hasProperty('keyStore')) {
  284. keyStore = project.keyStore // This needs to be a path to the keystore file
  285. alias = project.keyStoreAlias
  286. storePass = project.keyStorePass
  287. keyPass = project.keyStoreKeyPass
  288. inputFile = jar.archivePath
  289. outputFile = jar.archivePath
  290. }
  291. }
  292.  
  293. build.dependsOn signJar
  294.  
  295. curseforge {
  296. if (System.getenv().CURSEAPIKEY != null && System.getenv().CURSERELEASETYPE != null)
  297. {
  298. apiKey = System.getenv().CURSEAPIKEY
  299.  
  300. project {
  301. id = '245506'
  302.  
  303. changelog = file('build/changelog.md')
  304. changelogType = 'markdown'
  305. releaseType = System.getenv().CURSERELEASETYPE
  306.  
  307. addArtifact deobfJar
  308. }
  309. }
  310. else
  311. {
  312. logger.lifecycle("Cannot run the CurseUpload sequence. No API-Key or release type has been provided.")
  313. }
  314. }
  315.  
  316. task("createChangelog") {
  317. group = 'upload'
  318.  
  319. doLast {
  320. def teamCityURL = "http://teamcity.minecolonies.com/"
  321. def file = new FileOutputStream("build/changelog.md")
  322. def out = new BufferedOutputStream(file)
  323. def changesXML = new XmlSlurper().parse(teamCityURL + "guestAuth/app/rest/changes?locator=build:(id:" + teamcity["teamcity.build.id"] + ")")
  324.  
  325. def changes = changesXML.change
  326. println("createChangelog: Identified " + changes.size() + " changes to be written into the changelog.")
  327.  
  328. out << "# Minecolonies Changelog \n"
  329. out << "## Version: _" + version + "_ \n"
  330.  
  331. if (changes.size() > 0) {
  332. for (int i = 0; i < changes.size(); i++) {
  333. def changeDetailsURL = teamCityURL + "guestAuth/app/rest/changes/id:" + changes[i][email protected]()
  334. def changeDetailsXml = new XmlSlurper().parse(changeDetailsURL)
  335. def changeComment = changeDetailsXml.comment.text().trim()
  336.  
  337. out << "* " + changeComment + "\n"
  338. }
  339. } else {
  340. out << "No Changes detected!"
  341. }
  342.  
  343. out.close()
  344. }
  345. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement