build.gradle 3.4 KB

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