build.gradle 3.9 KB

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