-
Notifications
You must be signed in to change notification settings - Fork 0
Using Eclipse for ten.java
A number of developers have only ever used Eclipse to write their plugins and the concept of using version control (git) and dependency management tools (e.g. Maven) may seem a little daunting. This guide aims to explain how to setup your IDE in an optimal way for taking part in the ten.java contest.
For a lot of people, Eclipse will already be installed but it's important that you have the correct plugins installed to take advantage of git and maven. You don't need to use your IDE for git or Maven - you can simply use the command line if you prefer, but for the purposes of this contest it might be best to make use of your IDE's built-in tools.
I installed the "IDE for Java Developers" version of Eclipse from this page. It's worth noting this version of Eclipse ships with the git and Maven plugins already. If you're relying on your own installed version, you might have to add the git and Maven plugins manually.
Once Eclipse and the necessary plugins are installed, you can proceed to the next step!
Now that all the prerequisites are installed we can clone your GitHub repository. First go to the tenjava user profile and search for your repository. It should be in the form of {username}-t{1/2/3}. If you can't find it, refer to this FAQ entry.
In Eclipse, find the package explorer sidebar and right click to open the context menu. Select New -> Other... as per the screenshot below:
In the dialog that appears, select the Maven -> Check out Maven Projects from SCM option and click Next > per the screenshot below:
In your browser, find the clone URL section of your GitHub repository (in the sidebar) and copy the URL. You'll probably want to use the HTTPS URL for this.
You'll probably need to install the Git connector plugin at this point. If the SCM URL dropdown has an option for 'git' (see screenshot below), you already have the plugin installed.
If you see this, you're all set:
If you see this, you're missing the git connector:
If you're missing the connector, and you are running Eclipse Kepler, check the following link. If you are runner an older version of Eclipse, click the "m2e Marketplace" link and tick the "m2e-egit" option and click Finish:
Accept the license agreements and content signing warning and allow Eclipse to restart. Repeat the above process until you get to the same wizard and you can see "git" in the SCM URL dropdown.
Next, paste the HTTPS clone URL into the SCM URL textbox in Eclipse:
Hit the Finish button and wait for the import to complete.
At this stage your project should be imported and you should be able to see it in the "Package Explorer" sidebar. Now it's time for us to setup the run configuration so we can easily compile the plugin from inside of eclipse. Hit the run button in the toolbar as shown in the screenshot below and select "Run Configurations...":
Next, right click the "Maven build" entry in the dialog that appears and select "New..." per the screenshot below:
Set the name of the configuration to something like "Build":
Now, click the "Browse workspace..." button under the "Base directory" text:
)
Select the only available item and click OK:
Finally, click Apply and Run. If everything went to plan, you should see a success message at the bottom of the screen:
It's no use setting up Eclipse if you don't know how to make use of Maven and Git! In this section, I'll cover the things you'll be doing throughout the contest.
You can find the Java source in the src/main/java
folder in the Package Explorer. The plugin.yml (and any configs you need) go in the src/main/resources
folder. The resources will be put in the JAR for you by Maven.
After writing some code, you'll probably want to test your plugin. To build it, click the build button in the toolbar. Note: if you prefer, you can run the 'mvn' command at the command line instead.
Once the project has built, Maven will create a JAR in the target directory for you. To find the JAR, right click on the project in the Eclipse sidebar and select Show In -> System Explorer. Open the target folder and you should see something like this:
You can now copy this JAR to your testing server and get started with testing!
During the contest, you'll need to commit and push at least every 15 minutes so we can effectively verify the work is yours.
Eclipse's git plugin allows us to commit and push directly from Eclipse. To get started, right click on the project and find the Team... option:
Choose the commit item to commit. You'll see a dialog appear where you can type in a message. It's good practice to enter a short (about 50 chars) first line explaining what you've done though given the nature of the contest and frequent commits we don't expect anything substantial or really descriptive.
Next, hit the "Commit and Push" button. This will send your changes to GitHub. They'll be announced in our IRC channel, featured on the website (along with the most recent changes) and our build server will automatically build your latest code.
We strongly recommend you stay in our IRC channel throughout the contest if you can. We'll ping you (notify you by saying your username in chat) if a build fails so you can figure out why and fix it. You can also chat and ask for help if you need it.
Remember, if your project doesn't compile at all throughout the contest we cannot judge it. If a later build fails, we'll end up using the last successful build.
Note: There's no obligation to use Eclipse's EGit plugin and some developers prefer other options. You're free to use GitHub for Windows, SourceTree, the command line or any other client if you prefer.
Visit the site at tenjava.com
If you have any questions (about the contest, git, Maven etc), please don't hesitate to send us a tweet @tenjava or ask in our IRC channel.