-
Notifications
You must be signed in to change notification settings - Fork 114
How to build the project with Intellij
This article assumes that you have no prior Java experience but want a working development environment based on the Intellij IDE.
If you're using Windows you'll find much of this software has a standard installer. For OS X I would strongly urge you to install Homebrew and Linux has a variety of standard package managers such as rpm
, yum
and apt-get
.
Assuming you're starting from scratch, you'll need to do the following:
Get the latest JDK7 for your operating system (I'm assuming you're on Windows, I personally work on OS X). Open JDK is an excellent choice for Linux users. Visit Oracle's download site if you're on Windows or OS X and ensure you don't tick any boxes that will install various adware banners or the NetBeans IDE etc.
Next install Maven, which will handle all your build requirements. If you're not familiar with it, the key difference is that Maven builds your project and pulls in all the required dependencies from either a local repository of JARs or off the internet if it can't find them locally.
To verify that Maven is installed and working, do the following at the command line:
mvn --version
You should get a report that looks a bit like this:
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T17:37:52+00:00)
Maven home: /usr/local/Cellar/maven/3.2.1/libexec
Java version: 1.8.0-ea, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"
Git keeps track of all changes to text and binary files so that you can always go back to earlier versions. We use it to keep track of all code changes and to link those changes to Issues that our users report to us.
Now is a good time to register for GitHub account if you haven't already done so. Even if you're not a developer having a GitHub account will allow you to keep track of open source projects that you've contributed to (good for your CV/resume) and you may find Git itself useful for your own day to day work - it's extremely flexible.
Install Git and consider also using the GitHub application that provides a simple user interface to it. You may find that you don't need it (your IDE will handle talking to Git for you) but it's useful to know that GitHub provide dedicated functionality.
To verify that Git is installed and working, do the following at the command line:
git --version
You should get a report that looks a bit like this:
git version 1.8.5.2 (Apple Git-48)
Most open source projects in GitHub provide a README.md file that offers build instructions aimed at developers familiar with the underlying technologies. This section will take you through this process with more detail.
Clone the MultiBit HD repository with the following command:
cd <where you want the code>
git clone https://github.com/bitcoin-solutions/multibit-hd
cd multibit-hd
git checkout develop
Git will provide a lot of information about what is being downloaded and the progress it is making. The repository can take a bit of time to arrive the first time, but subsequent updates are nearly instant. Many open source projects use the develop
branch as their day-to-day working branch with master
being for production releases.
This clone of the project repository is entirely under your control. You can make any changes you like to it. However, you won't have the ability to push those changes back upstream to our repository so don't worry about making breaking changes, you can always revert back to the latest known good position using
git reset --hard HEAD
The above command will wipe out all your local changes and take you back to the last update (pull) you made which should always be a good build.
Verify that the application builds using a terminal (always fall back to the terminal if in doubt):
mvn clean install
You will find that Maven downloads the world during its initial build. Once it has those artifacts (JARs, WARs etc) then it won't download them again, unless you delete them. Typically these files are placed in your user home directory under .m2/repository
which may be a hidden directory on your operating system.
After completion you should see a large "build successful" report. If not you can check the project's README file for an indication of the current build status.
Now that you've got Git and Maven working you can choose an IDE. Personally, I love Intellij and I would strongly urge you to get the community edition.
During installation you'll be asked to install a zillion plugins, make sure you include Git, Maven, JUnit and anything that you recognise. You can always enable/disable these later so just blindly accepting defaults will be fine but might slow down the IDE startup.
After installing fire it up and do the following:
- Use File | Import Project and locate the MultiBit HD pom.xml (it's in the project root on the develop branch).
- Work through the various dialogs just accepting whatever Intellij suggests
- In the bottom right of the screen you'll see the git branch listed ("develop" if you checked it out earlier), you can click to check out another branch
- Use the drop down list just below the Build/Tools menu items to create a runtime configuration.
- Use the green + button (top left) to create a new Maven configuration, then call it "Install" with a working directory of the project top level and a goal of "clean install" (no quotes).
- Click OK then click the green play triangle beside the drop down list.
This will kick off a Maven build - or barf with a "Maven not found" type error - you can fiddle with File | Settings to locate the Maven settings (type "maven" in the filter box on the dialog top left) and point it to your Maven home directory.
If all goes well you'll see the same "build successful" message in the console output screen in the IDE.
Start with mbhd-swing/src/test/java
and use the Project flyout on the left border to locate the MultiBitHDFestTest
.
Right click on the class name and choose "Run Test". This will run the automated user interface tests, so sit back with a cup of coffee and enjoy the show.
Next you'll want to verify that you can update the code from git:
- To the right of the green triangle are some buttons labelled VCS with arrows up and down. Click the down arrow to pull - you won't need the up arrow (you won't commit unless you're on your own fork)
- Intellij will pull down the latest code from the repo and show a green dialog in the bottom left corner
Experiment with the Revert feature:
- Try making a change to the README.md file (double click it then just type something random)
- Notice the blue bar to the left of the editor
- Click it to see a small flyout
- Locate the revert icon and click it - all your changes to that line are reverted
- For changes at the file and directory level use the purple revert icon beside the VCS buttons
Finally you'll want to run up the application for real:
- Locate the
MultiBitHD
main entry point classmbhd-swing/src/main/java/org/multibit/hd/ui/MultiBitHD
- Right click and select Run as before
- Wait for a moment while Intellij compiles and executes the code (you'll see progress in the footer bar of the IDE)
- MultiBit HD will start up and might show the licence/language screens due to a default configuration - if you have an existing wallet just choose to use it and continue as normal
You are now able to keep up to date with changes and see if your Issues are being fixed. If you spot anything that you think is wrong let the developers know by raising an Issue and include a screenshot.