build.gradle 3.8 KB

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