Search code examples
javaantminecraftbukkit

Incrementing version number on build in my plugin.yml


I'm currently working on a Spigot plugin and have never bothered updating the version number as my plugins have always been private. However I've been wondering if there was a way that does this for me automagically.

I know it's possible using Ant but the answers I've seen so far require an external file in which the actual version is stored, and still requires manual actions.

For those not familiar with Bukkit/Spigot, a plugin.yml looks like this:

name: PluginName
author: Author
version: 1.0
main: path.to.main.Class

So I'm looking for a solution which gets the current version from the file and increments the minor version by 1 and if possible the major by 1 if minor is > 9.


Solution

  • Update the plugin.yml for many reasons (i have many private plugins)

    1. Get into the habit of version-ing your work. What is there to differ your old "changes" to your new ones? Not only that but, that version number can be used through the plugin manager.
    2. Lets say you need to get that version (or some other plugin does) in the future. The ONLY way (besides an MD5 check) to get the version of your plugin, which 9 times out of 10 is to differentiate it from another version of that same plugin.
    3. If your adding it to a server, how do you know which version you are running? For example version 1.1 contains a new command, but version 1.0 does not. You cannot check that if the version was never changed.

    You dont HAVE to change it. There is no reason to be required to, but its good to practice development with version numbers like almost all other developers.

    However, to answer the automated incremental version, no. You cant modify that compiled jar (unless you get down and dirty with another plugin BEFORE your plugin is loaded). Possibly, you could make some sort of plugin to your IDE to automatically increment it? But do you see where this ends up? Just change it when you feel that you have made progress towards some feature.