Maven

Discussion in 'Plugin Development' started by Aza24, Jun 23, 2012.

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

    Aza24

    Hi,
    I am looking for some good tutorials or someone to teach me how to use Maven with my current setup (Eclipse and GitHub) to build my plugins.

    Thanks.
     
  2. Offline

    Aza24

    Bump
     
  3. Offline

    Sagacious_Zed Bukkit Docs

    mvn package
     
  4. Offline

    Aza24

    Where do I run this command?
     
  5. Offline

    EnvisionRed

    I use netbeans so I'm not sure, but there is probably some type of addon for eclipse for this.
    Which I think is what Zed was referring to.
     
  6. cmd/bash/... just some kind of shell... Don't like shells? use a maven plugin for your IDE.
     
  7. Offline

    Aza24

    I think im on the right track now... I downloaded Maven and setup the environment variables and im attempting to install m2eclipse.
     
  8. Offline

    desht

    Unfortunately, there doesn't seem to be any "Maven for Dummies" type guides out there. It's very much a case of examining existing projects and doing some research. Here are some pointers though (some apply to Maven in general, some for Eclipse):
    • You will want to structure your project directory into two main subdirectories: src/main/java and src/main/resources. Under src/main/java goes your Java code (in package subdirectories, of course) and under src/main/resources goes your plugin.yml and any other non-Java files you will be distributing in your plugin JAR (e.g. config.yml, other data files)
    • You will have a pom.xml at the very top level which describes how your project is built. Probably the best way of getting an initial working POM is to examine various Maven projects out there, e.g. WorldEdit, or my own projects :) E.g. my Autohop pom.xml: https://github.com/desht/autohop/blob/master/pom.xml (Autohop is a pretty simple plugin with a basic POM)
    • Once you have your plugin structure in place and created your pom.xml, you should be able to create the JAR with "mvn package" from the command-line (I work on Unix/Linux which has a decent command-line - if you're using Windows, then... erm, sorry :) )
    Eclipse tips:
    • You can install m2eclipse, which is nice (although I personally prefer the mvn command-line for most purposes)
    • "mvn eclipse:eclipse" will generate your Eclipse .classpath and .project files for you based on your POM, which is great since you no longer need to manually maintain dependencies etc. in Eclipse, and even better when you copy your project onto another machine - the Eclipse project is basically already set up for you.
    • The maven-eclipse-plugin build target can be used in your POM to automatically add a Maven nature to your Eclipse project, which helps m2eclipse along. See https://github.com/desht/autohop/blob/master/pom.xml for an example of that.
    See also https://github.com/desht/BukkitPluginArchetype - a Maven archetype to generate a skeleton Bukkit plugin as a Maven project. I forked this from https://github.com/keyz182/BukkitPluginArchetype to bring it more up to date & finally just got round to sending a pull request to the author :)
     
  9. Offline

    Aza24

    I have decided to use m2eclipse and have written a pom from other users maven github repos. Does this look alright to you?

    Also what archetype should I be using if I don't want to use the BukkitPlugin one?

    Do I type this command in Command Prompt or somewhere inside Eclipse?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  10. Offline

    desht

    Looks good, yes.

    Don't know.

    Into your Command Prompt.
     
Thread Status:
Not open for further replies.

Share This Page