Creating CraftBukkit project - Paul-Schliep/CraftBukkit GitHub Wiki

Install Maven plugin

Before you check out the repo and try to create a repo, you should probably install the Maven plugin in your preferred Eclipse since that's the build tool the CraftBukkit project uses. Maven manages the dependencies on other libraries (such as all the interfaces from the Bukket project) for you, as well as doing things like building the project and running the tests.

Neither the default Eclipse install in the lab or the GGTS that we installed in /usr/local/springsource for the previous project have the Maven plugin installed by default (although it's possible you've installed it yourself for some reason).

"Default" Eclipse installation

If you want to use the default Eclipse installation (in the "Programming" menu) then you want to:

  • Go to "Help -> Install new software...".
  • Choose the "Juno" software site in the "Work with" drop down at the top.
  • Type "Maven" in the "type filter text" text box.
  • Choose either of the "m2e - Maven Integration for Eclipse" entries.
  • Click the "Next >" button, accept the terms, etc.

GGTS

If you want to use the GGTS version of Eclipse (in /usr/local) then you want to:

  • Go to "Help -> Eclipse Marketplace...".
  • Enter "maven integration for eclipse" in the Find box.
  • Scroll down to "Maven Integration for Eclipse (Juno and newer) 1.4". *There will be several things that look really similar before you get to the "right" thing!_ The one you're looking for has an icon that is a square formed out of horizontal blue and black lines with a little space in the upper middle. It also has over 600K installs and over 300 stars.

Creating the project

You should first check out your fork of the repo in eGit as per usual. (This takes a while because it's a large repo with a lot of history.) This will not come with all the Eclipse project & settings files. Most "real" project (including CraftBukkit) don't include such things in their repos because they don't want to clutter those up with things that only make sense for particular users with specific environments. As a result we don't want to commit those kinds of things either. This means that we'll have to create the project and then set up Eclipse accordingly.

Once you have the Maven plugin installed and the repo checked out:

  • Go to the Git perspective if you're not still there.
  • Right click on your "CraftBukkit" repo entry.
  • Choose "Import Projects..."
  • Choose "Import as general project"
  • Choose "Finish"

Now we need to make that into a Java project:

  • Go to the Java Perspective
  • Right click on the CraftBukkit project and choose "Configure -> Convert to Maven project"
    • That should add a little 'M' to the top of your project icon.
    • I think it builds automatically, but you can right click on the project and choose "Maven -> Update project..." to force a build.
    • The first time you do this I think that Maven will download a bunch of dependencies, all of which will take a while. Once you have those libraries, though, things will be much faster in the future. (All the stuff it downloads get put in the .m2 directory in your home directory, e.g., ~/.m2/repository/org/bukkit/bukkit/1.7.5-R0.1-SNAPSHOT
    • On my Eclipse there are over 1,200 warnings, many (but definitely not all) of which are about using raw types for generics, i.e., an ArrayList without specifying a list of what. As I mentioned in class, an interesting refactoring would be to try to fix these, but there are a ton of them, and the fixes wouldn't be terribly interesting, so I wouldn't suggest going down that road. You may in fact want to turn off those warnings so your Eclipse warnings can become useful to you once again. (There are several hundred other warnings that are potentially interesting, and certainly suggest some weird historical oddities in the code.)

You should be able to run all the tests using "Run as -> Maven test" on the project. For me they all succeeded, but you should confirm that they succeed for you as well before doing any work.