build.gradle 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import java.util.stream.Collectors
  2. buildscript {
  3. repositories {
  4. maven { url = 'https://maven.minecraftforge.net' }
  5. mavenCentral()
  6. maven { url 'https://maven.parchmentmc.org' }
  7. maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
  8. }
  9. dependencies {
  10. classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
  11. classpath group: 'org.parchmentmc', name: 'librarian', version: '1.+'
  12. classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
  13. }
  14. }
  15. apply plugin: 'net.minecraftforge.gradle'
  16. apply plugin: 'eclipse'
  17. apply plugin: 'org.parchmentmc.librarian.forgegradle'
  18. apply plugin: 'org.spongepowered.mixin'
  19. apply plugin: 'ferritecore.loader-conventions'
  20. def fcMixinConfigs = [
  21. "predicates",
  22. "fastmap",
  23. "mrl",
  24. "dedupmultipart",
  25. "blockstatecache",
  26. "dedupbakedquad",
  27. "threaddetec",
  28. ].stream()
  29. .<String> map({ s -> "ferritecore." + s + ".mixin.json" })
  30. .collect(Collectors.toList())
  31. // Work around what I consider a bug in FG: Common:googleimpl source set is specified as mod source, but FG tries to
  32. // compile it in this project
  33. sourceSets {
  34. googleimpl
  35. }
  36. minecraft {
  37. mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
  38. runs {
  39. client {
  40. workingDirectory project.file('run')
  41. ideaModule "${rootProject.name}.${project.name}.main"
  42. property 'forge.logging.console.level', 'debug'
  43. mods {
  44. ferritecore {
  45. source sourceSets.main
  46. source project(":Common").sourceSets.main
  47. source project(":Common").sourceSets.googleimpl
  48. }
  49. }
  50. }
  51. server {
  52. workingDirectory project.file('run')
  53. ideaModule "${rootProject.name}.${project.name}.main"
  54. property 'forge.logging.console.level', 'debug'
  55. mods {
  56. ferritecore {
  57. source sourceSets.main
  58. source project(":Common").sourceSets.main
  59. source project(":Common").sourceSets.googleimpl
  60. }
  61. }
  62. }
  63. }
  64. }
  65. dependencies {
  66. minecraft group: 'net.minecraftforge', name: 'forge', version: "${minecraft_version}-${forge_version}"
  67. annotationProcessor group: 'org.spongepowered', name: 'mixin', version: '0.8.5', classifier: 'processor'
  68. }
  69. jar.finalizedBy('reobfJar')
  70. mixin {
  71. add project(":Common").sourceSets.main, "${mod_id}.refmap.json"
  72. configNames += fcMixinConfigs
  73. }
  74. jar {
  75. filesMatching("*.mixin.json") {
  76. expand "refmap_target": "${mod_id}."
  77. }
  78. }
  79. task speedUpPreRun {
  80. doLast {
  81. for (String s : new String[]{"Client", "Server"}) {
  82. ant.replace(
  83. file: project.rootDir.toString() + "/.idea/runConfigurations/Forge_run" + s + ".xml",
  84. // prepareRunX is prepareRuns + compile, but compiling is already handled by IntelliJ
  85. // Also (specific to FC), compiling doesn't properly see the googleimpl source set and breaks
  86. token: "prepareRun" + s,
  87. value: "prepareRuns"
  88. )
  89. }
  90. }
  91. }
  92. tasks.withType(Task) {
  93. if (it.name == "genIntellijRuns") {
  94. it.finalizedBy speedUpPreRun
  95. }
  96. }
  97. // For some reason this doesn't work when in the "convention" scripts...
  98. def customGradle = project.file('custom.gradle');
  99. if (customGradle.exists()) {
  100. apply from: customGradle;
  101. }