build.gradle 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. import groovy.json.JsonOutput
  2. buildscript {
  3. repositories {
  4. maven {
  5. url = 'https://files.minecraftforge.net/maven'
  6. }
  7. jcenter()
  8. mavenCentral()
  9. }
  10. dependencies {
  11. classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
  12. }
  13. }
  14. plugins {
  15. id "com.matthewprenger.cursegradle" version "1.4.0"
  16. }
  17. apply plugin: 'net.minecraftforge.gradle'
  18. apply plugin: 'eclipse'
  19. apply plugin: 'maven-publish'
  20. apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
  21. if (project.hasProperty('secretFile')) {
  22. loadSecrets(new File((String) findProperty('secretFile')))
  23. }
  24. version = '7.0.0'
  25. if (System.getenv('BUILD_NUMBER') != null) {
  26. version += "." + System.getenv('BUILD_NUMBER')
  27. }
  28. group = 'com.blamejared.controlling'
  29. archivesBaseName = 'Controlling'
  30. sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
  31. repositories {
  32. maven {
  33. url 'https://dogforce-games.com/maven'
  34. }
  35. }
  36. minecraft {
  37. mappings channel: 'snapshot', version: '20201028-1.16.3'
  38. accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
  39. runs {
  40. client {
  41. workingDirectory project.file('run')
  42. property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  43. property 'forge.logging.console.level', 'debug'
  44. taskName 'ControllingClient'
  45. mods {
  46. examplemod {
  47. source sourceSets.main
  48. }
  49. }
  50. }
  51. server {
  52. workingDirectory project.file('run')
  53. property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  54. property 'forge.logging.console.level', 'debug'
  55. taskName 'ControllingServer'
  56. mods {
  57. examplemod {
  58. source sourceSets.main
  59. }
  60. }
  61. }
  62. }
  63. }
  64. dependencies {
  65. minecraft 'net.minecraftforge:forge:1.16.5-36.0.0'
  66. }
  67. jar {
  68. manifest {
  69. attributes([
  70. "Specification-Title" : "controlling",
  71. "Specification-Vendor" : "BlameJared",
  72. "Specification-Version" : "1",
  73. "Implementation-Title" : project.name,
  74. "Implementation-Version" : "${version}",
  75. "Implementation-Vendor" : "controlling",
  76. "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],)
  77. }
  78. }
  79. task sourcesJar(type: Jar, dependsOn: classes) {
  80. description = 'Creates a JAR containing the source code.'
  81. from sourceSets.main.allSource
  82. classifier = 'sources'
  83. }
  84. task javadocJar(type: Jar, dependsOn: javadoc) {
  85. description = 'Creates a JAR containing the JavaDocs.'
  86. from javadoc.destinationDir
  87. classifier = 'javadoc'
  88. }
  89. task deobfJar(type: Jar) {
  90. description = 'Creates a JAR containing the non-obfuscated compiled code.'
  91. from sourceSets.main.output
  92. classifier = "deobf"
  93. }
  94. artifacts {
  95. archives sourcesJar
  96. archives javadocJar
  97. archives deobfJar
  98. }
  99. publishing {
  100. publications {
  101. mavenJava(MavenPublication) {
  102. groupId project.group
  103. artifactId project.archivesBaseName
  104. version project.version
  105. from components.java
  106. // Allows the maven pom file to be modified.
  107. pom.withXml {
  108. // Go through all the dependencies.
  109. asNode().dependencies.dependency.each { dep ->
  110. println 'Surpressing artifact ' + dep.artifactId.last().value().last() + ' from maven dependencies.'
  111. assert dep.parent().remove(dep)
  112. }
  113. }
  114. artifact sourcesJar {
  115. classifier 'sources'
  116. }
  117. artifact javadocJar {
  118. classifier 'javadoc'
  119. }
  120. artifact deobfJar {
  121. classifier 'deobf'
  122. }
  123. }
  124. }
  125. repositories {
  126. maven {
  127. url "file://" + System.getenv("local_maven")
  128. }
  129. }
  130. }
  131. curseforge {
  132. apiKey = findProperty('curseforge_api_token') ?: 0
  133. project {
  134. id = "250398"
  135. releaseType = 'release'
  136. changelog = file("changelog.md")
  137. changelogType = 'markdown'
  138. // addArtifact(sourcesJar)
  139. // addArtifact(javadocJar)
  140. addArtifact(deobfJar)
  141. }
  142. }
  143. task updateVersionTracker {
  144. onlyIf {
  145. project.hasProperty('versionTrackerAPI')
  146. }
  147. doLast {
  148. def body = [
  149. 'author' : "${project.findProperty('versionTrackerAuthor')}",
  150. 'projectName' : "controlling",
  151. 'gameVersion' : "1.16.5",
  152. 'projectVersion': "${version}",
  153. 'homepage' : "${project.findProperty('versionTrackerHomepage')}",
  154. 'uid' : "${project.findProperty('versionTrackerKey')}"
  155. ]
  156. // Opens a connection to the version tracker API and writes the payload JSON.
  157. def req = new URL(project.findProperty('versionTrackerAPI')).openConnection()
  158. req.setRequestMethod('POST')
  159. req.setRequestProperty('Content-Type', 'application/json; charset=UTF-8')
  160. req.setRequestProperty('User-Agent', "Controlling Tracker Gradle")
  161. req.setDoOutput(true)
  162. req.getOutputStream().write(JsonOutput.toJson(body).getBytes("UTF-8"))
  163. // We need to attempt a read in order to actually send the message.
  164. println "VersionCheck Status code: ${req.getResponseCode()}"
  165. println "VersionCheck Response: ${req.getInputStream().getText()}"
  166. }
  167. }
  168. task genGitChangelog() {
  169. def stdout = new ByteArrayOutputStream()
  170. // first commit to check from, in our case the first commit of the branch
  171. String firstCommit = "efff217f353e51ce43751caf94b1924818b710e8";
  172. String repoLink = "https://github.com/jaredlll08/Controlling/commit/"
  173. // was having issues with grep and spaces in the regex
  174. exec {
  175. commandLine 'git', 'log', '-i', '--grep=version\\spush', '--grep=open\\sbeta\\sspecific\\scode', '--pretty=tformat:%H', '--date=local', firstCommit + '..@{0}'
  176. standardOutput = stdout
  177. }
  178. if (stdout.toString().trim().indexOf("\n") >= 0) {
  179. firstCommit = stdout.toString().split("\n")[0].trim();
  180. }
  181. System.out.println("Last version hash: \"" + firstCommit + "\"");
  182. stdout = new ByteArrayOutputStream()
  183. def test = exec {
  184. commandLine 'git', 'log', '--pretty=tformat:- [%s](' + repoLink + '%H) - %aN - %cd', '--max-parents=1', '--date=local', firstCommit + "..@"
  185. standardOutput = stdout
  186. }
  187. File file = new File("changelog.md")
  188. file.write("### Current version: " + project.version)
  189. file.append("\n" + stdout.toString())
  190. System.out.println("Changelog generated!")
  191. }