build.gradle.kts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import net.minecraftforge.gradle.user.UserBaseExtension
  2. import Config.Libs.Sponge.API7 as API7
  3. // Config is located in <root>/buildSrc/src/main/java/Config.kt
  4. // It provides a bunch of constant values we use as dependency
  5. // strings, so we don't have to duplicate a bunch of them in
  6. // various scripts. The import as allows for shorthand.
  7. /*
  8. Special dependency for the buildscript to be able to use ForgeGradle 2.3-SNAPSHOT.
  9. Needs to define the repository where FG exists, and then adds the classpath of the
  10. plugin jar for the buildscript. It's what allows us to import UserBaseExtension
  11. */
  12. buildscript {
  13. repositories {
  14. jcenter()
  15. maven(Repos.forge)
  16. }
  17. dependencies {
  18. classpath(Plugins.FG2_3.classpath)
  19. }
  20. }
  21. // Extension created to set up the minecraft block for ForgeGradle. This will be different for ForgeGradle 3>, but we don't
  22. // use that newer version for 1.12, that will be used for 1.13+
  23. val Project.minecraft: UserBaseExtension
  24. get() = extensions.getByName<UserBaseExtension>(Plugins.FG2_3.extensionName)
  25. plugins {
  26. `java-library`
  27. // Apply the spongegradle plugin to generate the metadata file, these cannot be import shorthanded because
  28. // they need to be resolved at script compilation time to apply the plugin
  29. id(Config.Libs.Sponge.API7.spongeGradleId) version Config.Libs.Sponge.API7.spongeGradleVersion // supplies sponge repo and plugin metadata creation tasks
  30. }
  31. // Apply the FG2.3 plguin the old way, because there's no valid way to do it the new plugins way.
  32. apply(plugin = API7.forgeGradleId)
  33. dependencies {
  34. // Only SpongeAPI needed for the base plugin class, a majority will be api version dependent.
  35. compileOnly(API7.api) // SpongeAPI
  36. }
  37. /*
  38. Now this configures ForgeGradle to set up the Minecraft (NMS) dependency. To use it, one needs to run
  39. `gradlew sDecW` either from root or `gradlew :sponge:api7:sDecW`. The process generates a Minecraft
  40. dependency with forge sources so one can read MCP remapped code. The dependency is not included in
  41. git.
  42. */
  43. configure<UserBaseExtension> {
  44. version = API7.minecraftVersion // The minecraft (forge) version
  45. runDir = "run" // Where the run directory will be placed
  46. mappings = API7.mappings // The MCP mappings version
  47. }
  48. /**
  49. * Some extra information that needs to be included for plugin/mod generation that will be
  50. * parsed by Sponge or Forge (when SpongeForge is involved, Forge loads the plugins for SpongeForge)
  51. */
  52. tasks.withType<Jar> {
  53. inputs.properties += "version" to project.version
  54. inputs.properties += "mcversion" to project.minecraft.version
  55. baseName = "mcmmo"
  56. filesMatching("/mcmod.info") {
  57. expand(mapOf(
  58. "version" to project.version,
  59. "mcversion" to project.minecraft.version
  60. ))
  61. }
  62. }