What is Maven Shading and how do I start?

Discussion in 'Spigot Plugin Development' started by Kingdomity, May 27, 2018.

  1. Hello Developers,

    I am wanting to shade api projects into my maven project, so server owners don't have to download them. But I want to know if thats what maven shading is? For instance what is it? Does it get added to the project so I dont have to add the project jar to the build path? I am new to maven shading and I would like to know if it makes it, so server owners don't have to download a extra plugin to enable features in the plugin. Also, what do I all need to get started? I would like some examples of pom.xml. Therefore, how do I build the jar file. I know its maven build... but what do you put in the goals? Do I type "compile", "package"?? I am on eclipse making my projects. I really would like some help. Thank you
  2. Take a look at this help page from apache. There's literally anything you need.

    Besides, that is not what you should be doing with maven shading. It's not that of an inconvenience to download one or multiple depencies for server owners, if they want to use certain features a plugin offers. It's like writing an advanced tutorial for something, but putting a foreign beginner tutorial in front of yours just for the convenience of the reader of not having to leave your page (if that example makes any sense).

    I personally prefer the includes over the excludes because you have a better overview of what gets shaded into your final jar (in my opinion).
    • Optimistic Optimistic x 1
  3. Didn't you ask exactly the same thing a few days ago and mark the thread as solved? Nevertheless:
    • Your project should ideally be platform independent, especially the IDE you use shouldn't make a difference.
    • Shading does not make any differences to your project, but only to the compiled .jar. That means yes, you wouldn't need to download the dependency separately. In your development environment, dependencies that are to be shaded are treated just like any other dependency.
    • If it makes sense to shade a dependency depends on the respective dependency; there is no general answer to this. Some plugins that are used as libraries might be designed to be loaded in a specific way as a standalone plugin and won't work well if they are shaded.
    • The build command doesn't change (mvn install or mvn clean install)
    • The dependency scope must be set to "compile" (instead of "provided")
    • Add the mvn-shade-plugin and specify the dependencies to shade ("include" in the final jar). This is an example pom.xml: https://github.com/DRE2N/DungeonsXL/blob/master/pom.xml
    • Like Like x 1