build.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. plugins {
  2. id "architectury-plugin" version "2.0.65"
  3. id "forgified-fabric-loom" version "0.6.54" apply false
  4. id "org.cadixdev.licenser" version "0.5.0"
  5. id "com.jfrog.bintray" version "1.8.4"
  6. id "com.matthewprenger.cursegradle" version "1.4.0" apply false
  7. id "maven-publish"
  8. }
  9. architectury {
  10. minecraft = rootProject.minecraft_version
  11. }
  12. subprojects {
  13. apply plugin: "forgified-fabric-loom"
  14. loom {
  15. silentMojangMappingsLicense()
  16. useFabricMixin = true
  17. }
  18. }
  19. allprojects {
  20. apply plugin: "java"
  21. apply plugin: "architectury-plugin"
  22. apply plugin: "org.cadixdev.licenser"
  23. ext {
  24. isSnapshot = System.getenv("PR_NUM") != null
  25. }
  26. def runNumber = (System.getenv("GITHUB_RUN_NUMBER") == null ? "9999" : System.getenv("GITHUB_RUN_NUMBER"))
  27. if (!ext.isSnapshot) {
  28. version = rootProject.base_version + "." + runNumber
  29. archivesBaseName = rootProject.archives_base_name
  30. } else {
  31. version = rootProject.base_version + "-PR." + System.getenv("PR_NUM") + "." + runNumber
  32. archivesBaseName = rootProject.archives_base_name_snapshot
  33. }
  34. group = rootProject.maven_group
  35. tasks.withType(JavaCompile) {
  36. options.encoding = "UTF-8"
  37. // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
  38. // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
  39. // We'll use that if it's available, but otherwise we'll use the older option.
  40. def targetVersion = 8
  41. if (JavaVersion.current().isJava9Compatible()) {
  42. options.release = targetVersion
  43. }
  44. }
  45. license {
  46. header = rootProject.file("HEADER")
  47. ext {
  48. name = "shedaniel"
  49. year = "2020, 2021"
  50. }
  51. include "**/*.java"
  52. exclude "**/NbtType.java"
  53. ignoreFailures = true
  54. }
  55. ext {
  56. releaseChangelog = {
  57. def dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm")
  58. dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"))
  59. def branch
  60. if (System.env.BRANCH_NAME) {
  61. branch = System.env.BRANCH_NAME
  62. branch = branch.substring(branch.lastIndexOf("/") + 1)
  63. } else {
  64. branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
  65. }
  66. if (branch == "HEAD") {
  67. branch = "git rev-parse --short HEAD".execute().in.text.trim()
  68. }
  69. def time = dateFormat.format(new Date())
  70. def changes = new StringBuilder()
  71. changes << "<h2>Architectury v$project.version for $project.supported_version</h2>Updated at <b>$time</b>.<br><a href=\"https://www.github.com/architectury/architectury/commits/$branch\">Click here for changelog</a>"
  72. def proc = "git log --max-count=200 --pretty=format:%s".execute()
  73. proc.in.eachLine { line ->
  74. def processedLine = line.toString()
  75. if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
  76. changes << "<br>- ${processedLine.capitalize()}"
  77. }
  78. }
  79. proc.waitFor()
  80. return changes.toString()
  81. }
  82. }
  83. }
  84. task licenseFormatAll
  85. subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") }
  86. bintray {
  87. user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
  88. key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY')
  89. publications = ["mavenCommon", "mavenFabric", "mavenForge"]
  90. publish = true
  91. pkg {
  92. repo = "cloth"
  93. name = "architectury"
  94. userOrg = "shedaniel"
  95. licenses = ["Apache-2.0"]
  96. version {
  97. vcsUrl = "https://github.com/shedaniel/architectury.git"
  98. }
  99. }
  100. }
  101. task curseforgePublish