Advertisement
Guest User

Untitled

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