build.gradle 4.1 KB

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