Is it a good idea to have a different package name for each version of a shaded library?

Discussion in 'Plugin Development' started by AlvinB, Aug 11, 2017.

Thread Status:
Not open for further replies.
  1. I'm thinking about how I should add functionality and updates to a resource of mine which you shade into a jar (more specifically this).

    Because all of the code to this library is in the com.bringholm.nametagchanger package, only one instance of it will be loaded at a time, even if there are several plugins containing the loaded lib at runtime. What I'm thinking about is when I update this resource and it no longer behaves like previous versions (no real concrete changes at the moment, I'm just thinking on how to implement it), a plugin that contains the old version might get served the new version of the lib from another plugin which has it shaded, which might cause errors because both plugins expect different functionality from the same code.

    My idea to get around this is to include the version in the package, so the class loader would be forced to load both versions of the lib if they require different ones (ie have com.bringholm.nametagchanger.v1_0 and com.bringholm.nametagchanger.v1_1) and all plugins will get the version they expect to have. My only question is, does anybody see any potential downsides to this?
     
  2. Offline

    Zombie_Striker

    @AlvinB
    Since it is unlikely that there will be more than one plugin on a server that uses the API, since having multiples may cause conflicts, I doubt you will have to worry about version changes.

    The only reason for having different packages would be to throw errors to prevent developers from just assuming they will work with the newest version, (which is the reason why the NMS packages change every update), so unless you are going to change the return types for methods, or plan on re-naming methods in the class, or making massive changes that devs should worry about, I don't think you need to change the packages.
     
  3. @Zombie_Striker
    The idea of versioning the packages was not to throw errors, only to force the ClassLoader to load two versions of the lib. Mind you, It's not an external lib, it has to be shaded in the jar together with the plugin. This basically forces me to to support multiple instances of the lib at the same time, which I currently do. I'm just thinking about what will happen when plugins get a version they're not expecting.
     
    Last edited: Aug 13, 2017
Thread Status:
Not open for further replies.

Share This Page