Sunday 29 January 2017

Haven and Hearth Client

To start doing arcane magic in Haven and Hearth one needs to learn to checkout, change and compile Haven and Hearth client. One of the most advanced clients for Haven and Hearth is developed by romovs and is called Amber, and that's what we would be using in our journey.

First things first

To begin with we need to ensure that we have all basic things that would be needed in future:
  • Java Development Kit (JDK) - make sure to have latest JDK installed, you can download it from http://www.oracle.com/technetwork/java/javase/downloads/index.html 
  • GIT client - GIT is version control system. Since we will be using GitHub to get the source code, we need a client. You can still do without GIT client and download ZIPed snapshots but you won't be able to synchronize your changes to GitHub then. You can get GIT client from https://git-scm.com/downloads
  • Integrated Development Environment (IDE) - we will be using Eclipse IDE, there are multiple other options IDEA, NetBeans to name a few. There is no particular reason why we are going to be using Eclipse, approach would be the same whatever you decide to pick. Eclipse can be downloaded here - https://eclipse.org/downloads/eclipse-packages/
Now we should be ready to get the source...

Use the source

To begin with lets fork Amber on GitHub, you can do so by clicking "Fork" button in the upper right corner of Amber repository page - https://github.com/romovs/amber:
This should create a copy of Amber repository for yourself and you should see something like this on repository page created for your copy:
Congratulations now you have your very own copy of Amber hosted on GitHub! Now lets download it and start using it. Time to start our IDE - after configuring workspace (directory where IDE will store your project files) you get to Welcome screen, where we will select "Check out projects from Git":
This presents us with a choice to use an existing local repository or to clone a URI, since we don't yet have any local repositories second options is what we are after:
You will be presented with the following form to specify Location of your repository and credentials to be used to access it. Once you fill in URI - Host and Repository path will be filled in automatically, authenitcation credentials are ones you use to access your GitHub account:
Next screen allows to select branches we want to check out - we are only interested in "master" branch, so that's what we select:
Now we need to specify where to store the copy localy and which branch is to be used:
Note that we checked "Clone submodules" - this is not really needed currently for Amber, but you never know what will change and perhaps at some point Amber might have external dependencies. Now Eclipse will clone the repository and place a local copy whereever you pointed it to. This gets us to next step - creating a project to work with checked out sources. Since source have no project files we will be importing them as "general project":
Next screen will allow you to set the project name and you are done. Now you have your GitHub repository cloned to your local PC and stored under directory that you specified and "Project Explorer" tab should be looking like the following:
Amber is built using Apache Ant, luckily enough it is integrated into Eclipse IDE and there is no need to download it separately and "build.xml" is configuration file defining build targets (like Makefile for those of you who are more familiar with "make". So we right-click "build.xml" and select "Run As -> Ant Build":
Follow Console tab for any erros, a couple of tasks need to be performed and the line we are looking for is "BUILD SUCCESSFUL":
Yay! Now lets go to workspace and see what we have there:

Note the "build" folder - that is where all the compiled classes went, but before that lets copy "run.bat" from "etc" folder - it contains startup parameters for the client. So here is how the final state of "build" folder should look like from inside:
 
Now lets start "run.bat" and behold our glorious creation.

The Deed is Done

So to recap of what we have done:
  1. We setup our development environment comprised of JDK, Eclipse IDE and Git setup
  2. We forked Amber official repository on GitHub creating a copy for ourselves
  3. We cloned our new repository to a local copy to work on it
  4. We built Amber client using build.xml supplied with the project
  5. We copied run.bat supplied with the project to build directory created during build process
  6. We executed run.bat to get client running

This should get us rolling and set a path for us to expore Artifice and Arcana of Haven and Hearth world.









No comments:

Post a Comment