build.gradle 3.5 KB

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