Iltotore / ManaDrop

A Gradle plugin for Minecraft development
Apache License 2.0
32 stars 5 forks source link

added apiVersionForMcVersion #16

Closed PhoenixmitX closed 1 year ago

PhoenixmitX commented 1 year ago

I have defined the version as a variable and reuse it on multiple lines. This makes it easier to always update to the newest Minecraft version.

However, the apiVersion takes a different input, so I have to manually change it or write some extra logic (which I don't want to have in the build.gradle, especially if I need to think of legacy versions).

My current build.gradle looks something like this:

ext {
  MC_VERSION = "1.19.3"
  API_VERSION = MC_VERSION.replaceFirst("(\\d+\\.\\d+)(\\.\\d+)?", "$1")
}

spigot {
  desc {
    // Stuff in your plugin.yml
    apiVersion API_VERSION
  }
}

buildTools {
  versions MC_VERSION
  workDir = file('build/spigot')
}

processResources.finalizedBy(spigotPlugin)

dependencies {
  compileOnly MinecraftDependencyHelper.paperApi(MC_VERSION)
  compileOnly MinecraftDependencyHelper.spigot(MC_VERSION)
}

With this change, I am able to remove the need for the extra variable API_VERSION and I can just write apiVersionForMcVersion MC_VERSION:

ext {
  MC_VERSION = "1.19.3"
}

spigot {
  desc {
    // Stuff in your plugin.yml
    apiVersionForMcVersion MC_VERSION
  }
}