Maven?

Discussion in 'Plugin Development' started by bobacadodl, Sep 22, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    bobacadodl

    So, I've been developing bukkit plugins for a pretty long time now, and I keep hearing "Use maven!".

    I've always just been too lazy to set it up, and figure it out :p

    Now that I'm finally giving it a chance, can someone tell me what are the advantages of using maven? A link to a tutorial on setting it up would be nice too. Right now, it seems like its a more work than just creating the plugin normally... typing up those xml files and stuff
     
  2. Offline

    Tirelessly

    If you don't have a need to use maven, don't use it.
     
  3. Offline

    bobacadodl

    Why would you ever use maven in the first place though? Like what are the advantages?
     
  4. Offline

    Tirelessly

    The only time I've ever needed maven is when I was using PlayN, which is basically a game engine that will compile to multiple platforms. You write the source code once, then use maven to compile it multiple times using different compatibility levels for the different softwares (android, windows, chrome.. etc)
     
  5. Offline

    Comphenix

    The primary advantage is its dependency management, and for more complex projects the ability to customize and automatically replicate the build process. Let me explain.

    First, dependency management might not seem like a big deal, especially if you only depend on Bukkit - but even in that case its still more convenient. Whenever you need to upgrade Bukkit, simply bump the version number and recompile. Maven will do the rest, no need to download Bukkit manually. The amount of time saved here multiplies by the number of dependencies (and transitive dependencies) in your project. And if your plugin is a library, you'll certainly save everyone else a lot of work if put it on a Maven repository.

    The important property here is the ability for others to replicate the build - done correctly, Maven allows people and bots to instantly checkout and compile your project. This is necessary if you want to collaborate with people in the open source community, or host your project on a CI server like Jenkins (permitted by BukkitDev incidentally). Storing the dependencies with the project might work, but it's wasteful and may only really work for people that use the same IDE as you (Eclipse, IntelliJ).

    On top of that, Maven also allows you to customize the build process in great detail using a variety of plugins. Do you need a specific Java library in your plugin? Merge it into your final JAR file using maven shading. Would you like to bundle your plugin with its source code and associated JavaDoc? Use maven-source-plugin and maven-javadoc-plugin. Generate plugin.yml automatically from your source code? Execute unit tests? Automatically publish the JAR to a central location? And so on ...

    In short, there are many advantages to automating your build process - how many just depends on your project.
     
Thread Status:
Not open for further replies.

Share This Page