build.gradle 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. "modelsides",
  29. ].stream()
  30. .<String> map({ s -> "ferritecore." + s + ".mixin.json" })
  31. .collect(Collectors.toList())
  32. // Work around what I consider a bug in FG: Common:googleimpl source set is specified as mod source, but FG tries to
  33. // compile it in this project
  34. sourceSets {
  35. googleimpl
  36. }
  37. minecraft {
  38. //mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
  39. mappings channel: 'official', version: "${minecraft_version}"
  40. runs {
  41. client {
  42. workingDirectory project.file('run')
  43. ideaModule "${rootProject.name}.${project.name}.main"
  44. property 'forge.logging.console.level', 'debug'
  45. mods {
  46. ferritecore {
  47. source sourceSets.main
  48. source project(":Common").sourceSets.main
  49. source project(":Common").sourceSets.googleimpl
  50. }
  51. }
  52. }
  53. server {
  54. workingDirectory project.file('run')
  55. ideaModule "${rootProject.name}.${project.name}.main"
  56. property 'forge.logging.console.level', 'debug'
  57. mods {
  58. ferritecore {
  59. source sourceSets.main
  60. source project(":Common").sourceSets.main
  61. source project(":Common").sourceSets.googleimpl
  62. }
  63. }
  64. }
  65. }
  66. }
  67. dependencies {
  68. minecraft group: 'net.minecraftforge', name: 'forge', version: "${minecraft_version}-${forge_version}"
  69. annotationProcessor group: 'org.spongepowered', name: 'mixin', version: '0.8.5', classifier: 'processor'
  70. }
  71. jar.finalizedBy('reobfJar')
  72. mixin {
  73. add project(":Common").sourceSets.main, "${mod_id}.refmap.json"
  74. configNames += fcMixinConfigs
  75. }
  76. jar {
  77. filesMatching("*.mixin.json") {
  78. expand "refmap_target": "${mod_id}."
  79. }
  80. }
  81. task speedUpPreRun {
  82. doLast {
  83. for (String s : new String[]{"Client", "Server"}) {
  84. ant.replace(
  85. file: project.rootDir.toString() + "/.idea/runConfigurations/Forge_run" + s + ".xml",
  86. // prepareRunX is prepareRuns + compile, but compiling is already handled by IntelliJ
  87. // Also (specific to FC), compiling doesn't properly see the googleimpl source set and breaks
  88. token: "prepareRun" + s,
  89. value: "prepareRuns"
  90. )
  91. }
  92. }
  93. }
  94. tasks.withType(Task) {
  95. if (it.name == "genIntellijRuns") {
  96. it.finalizedBy speedUpPreRun
  97. }
  98. }
  99. // For some reason this doesn't work when in the "convention" scripts...
  100. def customGradle = project.file('custom.gradle');
  101. if (customGradle.exists()) {
  102. apply from: customGradle;
  103. }