build.gradle 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. plugins {
  2. id "architectury-plugin" version "3.4-SNAPSHOT"
  3. id "dev.architectury.loom" version "0.7.3-SNAPSHOT" apply false
  4. id "org.cadixdev.licenser" version "0.6.1"
  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: "dev.architectury.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. javadoc {
  45. // Architectury's common javadoc has references to platform code, which cannot be resolved normally.
  46. // Let's just skip the errors!
  47. failOnError = false
  48. }
  49. license {
  50. header = rootProject.file("HEADER")
  51. ext {
  52. name = "architectury"
  53. year = "2020, 2021"
  54. }
  55. include "**/*.java"
  56. exclude "**/NbtType.java"
  57. ignoreFailures = true
  58. }
  59. ext {
  60. releaseChangelog = {
  61. def dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm")
  62. dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"))
  63. def branch
  64. if (System.env.BRANCH_NAME) {
  65. branch = System.env.BRANCH_NAME
  66. branch = branch.substring(branch.lastIndexOf("/") + 1)
  67. } else {
  68. branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
  69. }
  70. if (branch == "HEAD") {
  71. branch = "git rev-parse --short HEAD".execute().in.text.trim()
  72. }
  73. def time = dateFormat.format(new Date())
  74. def changes = new StringBuilder()
  75. 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>"
  76. def proc = "git log --max-count=200 --pretty=format:%s".execute()
  77. proc.in.eachLine { line ->
  78. def processedLine = line.toString()
  79. if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
  80. changes << "<br>- ${processedLine.capitalize()}"
  81. }
  82. }
  83. proc.waitFor()
  84. return changes.toString()
  85. }
  86. }
  87. }
  88. task licenseFormatAll
  89. subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") }
  90. task curseforgePublish