Raw file

advertisement

TRUSTSTORE DEVELOPER GUIDE

JAVA VERSION

C ONTENTS

1.

Introduction ................................................................................................................................................... 3

2.

Development Tools ........................................................................................................................................ 3

Installing the Tools ............................................................................................................................................. 3

JDK ................................................................................................................................................................. 3

Maven ............................................................................................................................................................ 3

Eclipse ............................................................................................................................................................ 3

TortoiseSVN (Optional) .................................................................................................................................. 6

Apache Tomcat Application Server ................................................................................................................ 6

3.

Getting the Source Code ................................................................................................................................ 6

Installing SCM Connectors for m2e .................................................................................................................... 6

Import SVN project with Maven ...................................................................................................................... 12

4.

Building the Android Client .......................................................................................................................... 19

Installing the Android SDK ................................................................................................................................ 19

Install the Android Eclipse Plugin (ADT) ........................................................................................................... 19

Configuring the Android Eclipse Plugin (ADT) .................................................................................................. 19

Check out the Android Client ........................................................................................................................... 20

Trouble Shooting the Android Built.................................................................................................................. 21

5.

Coding Conventions ..................................................................................................................................... 21

Indentation ....................................................................................................................................................... 21

Building the Client WebStart client and WAR .................................................................................................. 23

Java Coding Convention ................................................................................................................................... 24

6.

Building the iPad Client ................................................................................................................................ 25

Checking Out using Xcode ................................................................................................................................ 25

Checking Out using Cornerstone ...................................................................................................................... 26

Building & Running ........................................................................................................................................... 26

Deploying ......................................................................................................................................................... 27

1.

I NTRODUCTION

This document serves as a guideline for developers working on TrustStore. Instead of rewriting a complete tutorial of each technology being used, it outlines references to external resources for further study and preparation by the developers.

2.

D EVELOPMENT T OOLS

The following is the summary of tools being used for the development (more details about each tool is discussed below):

1.

JDK 1.6 Update 31

2.

Maven 3.0.4

3.

Eclipse IDE for Java EE Developers 3.7.x

Required plugins:

m2e 1.0

Subversive 0.7.9 with SVNKit or JavaHL compatible with SVN 1.5.x

4.

Apache Tomcat 7

5.

(optional) TortoiseSVN 1.5.x

You have the option of either this or Subversive (see below about Subversive). Probably Subversive itself is good enough if you plan to develop with Eclipse only. But occasionally, you need to check out files outside of Eclipse environment. This tool becomes handy for Windows users.

Installing the Tools

JDK

Download from the following page: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Please make sure to choose Java SE 6 JDK version. If you have a 64-bit machine, you might want to install both

32-bit and 64-bit versions together. As of this writing the latest version is Java SE 6 Update 31.

Maven

Download Maven from: http://maven.apache.org/download.html

The recommended version is 3.x. As of this writing, the latest is 3.0.4. So grab this version for your local installation.

Please follow the steps in the above website. Please make sure to do the section “Installation Instructions” so that Maven executable files are accessible in the terminal.

If you are new to Maven and interested in learning more, please read the following document: http://www.sonatype.com/books/mvnref-book/reference/

Eclipse

To install Eclipse, download from the following page: http://www.eclipse.org/downloads/ The recommended package is Eclipse IDE for Java EE Developers. You should grab the latest version 3.7.2.

( http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/indigosr2 )

The following are the required plug-ins:

1.

m2e 1.0

This plug-in is for the integration of Eclipse and Maven. I have tested version 1.0 to work fine with our setup. Go to Help > Install New Software and choose “Indigo – http://... “

2.

Subversive 0.7.9 with SVN Kit or JavaHL compatible with SVN 1.5.x

Having SVN client integrated with Eclipse is easier to work with. Follow the steps below (based on http://www.eclipse.org/subversive/downloads.php

): a.

In your Eclipse IDE, go to the menu Help > Install New Software b.

In the “Work with” field, select:

Indigo - http://download.eclipse.org/releases/indigo c.

Expands the Collaboration list. d.

Check all the Subversive components.

e.

During the installation, it will ask for SVN connectors. Please choose:

SVN Kit or JavaHL that is compatible with SVN 1.5. In the below screenshot, SVN Kit 1.2.3 and

JavaHL 1.5.4.

TortoiseSVN (Optional)

Currently, both SWIM/UNSDI projects are checked in to SVN repository version 1.5. This requires you to have a compatible client that works with version 1.5. The recommended version of TortoiseSVN is 1.5. If you have an existing TortoiseSVN with different version, I would highly recommend you to reinstall. Follow the links below to download:

For 32-bit: http://sourceforge.net/projects/tortoisesvn/files/Application/1.5.10/

For 64-bit: http://sourceforge.net/projects/tortoisesvn/files/Application%20x64/1.5.10/

Apache Tomcat Application Server

Download from http://tomcat.apache.org/download-70.cgi

. Unpack at location of your choice.

3.

G ETTING THE S OURCE C ODE

Installing SCM Connectors for m2e

Right click on the Package Explorer view.

Click on Import and navigate to Maven > Check out Maven Projects from SCM

Next, you need to install SCM connectors. Click on m2e Marketplace.

Next, choose m2e-subversive.

You will be prompted to restart Eclipse. Restart the Eclipse now for the plug-in to take effect.

Import SVN project with Maven

Right click on the Package Explorer. Click on Import and navigate to Maven > Check out Maven Projects from

SCM

In SCM URL dropdown, select svn.

Enter the location of the project in the svn: https://svnserv.csiro.au/svn/ict_projects/SOSy/CloudComputing/TrustStoreProject/trunk

Click Next and then click Finish. On the next step you will be prompted with Authentication details. Enter your

User and Password and then click Ok.

You will see the projects are checked out.

The red icons indicate that compilation has failed. Open the ‘Markers’ Tab to see the error messages:

Select one of the red error lines, right-click and select “Quick Fix”.

Select “Create a new runtime environment” and click “Finish”

Click “Add”.

Select “Apache Tomcat v7.0” and click “Next”

Select you tomcat installation directory (i.e. the directory where you unpack tomcat) and click “Finish”.

On the next screen press “OK”.

Rebuild all projects by selecting “Project -> Clean….” From the Eclipse menu.

All projects should build without errors now.

4.

B UILDING THE A NDROID C LIENT

Installing the Android SDK

Download from http://developer.android.com/sdk/index.html

and install. Note the installation path, you will need it below.

Install the Android Eclipse Plugin (ADT)

From http://developer.android.com/sdk/eclipse-adt.html#installing :

1.

Start Eclipse, then select Help > Install New Software....

2.

Click Add, in the top-right corner.

3.

In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/

4.

Click OK

Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

5.

In the Available Software dialog, select the checkbox next to Developer Tools and click Next.

6.

In the next window, you'll see a list of the tools to be downloaded. Click Next.

7.

Read and accept the license agreements, then click Finish.

Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.

8.

When the installation completes, restart Eclipse.

Configuring the Android Eclipse Plugin (ADT)

From http://developer.android.com/sdk/eclipse-adt.html#installing :

After you've successfully downloaded the ADT as described above, the next step is to modify your ADT preferences in Eclipse to point to the Android SDK directory:

1.

Select Window > Preferences... to open the Preferences panel (Mac OS X: Eclipse > Preferences).

2.

Select Android from the left panel.

You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and click Proceed. You cannot continue with this procedure until you click Proceed.

3.

For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory.

4.

Click Apply, then OK.

Done! If you haven't encountered any problems, then the installation is complete. If you're installing the

Android SDK for the first time you will get the following warning:

Select “Open SDK Manager”.

Select the latest API, all tools, as well as the extras “Android Support” and “Intel Hardware Accelerated

Execution Manager”:

Click on “Install XX packages …”. Accept all licenses. Wait for installation to finish.

SDK Manager might ask you to check for updates for the plugin, do so if asked.

Check out the Android Client

You should already have the TrustStore repository in Eclipse through the previous steps. If not add it in the

SVN repository Perspective. Navigate to “trunk->TSSAndroidClient”.

Right click on TSSAndroidClient and select “Check Out”.

Trouble Shooting the Android Built

Eclipse might run out of memory when building / deploying the Android client. In this case, give Eclipse more memory. The process is described here: http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F

For Max OS the eclipse.ini file is inside the eclipse.app package.

5.

C ODING C ONVENTIONS

The following are coding guidelines that can be configured in Eclipse.

Indentation

By default, Eclipse indentation is using tab character. This is not portable and the width is different between different IDE’s and operating systems. To have a consistent view of a tab, we must configure Eclipse to use whitespaces for the tab. To do so, follow the below steps:

1.

Go to Window > Preferences

2.

Search for whitespace

3.

Click on Text Editors

4.

Check the checkbox Insert spaces for tabs

5.

Displayed tab width set to 2

My preference is to use two spaces for indentation.

There is another place we need to configure to complete this indentation setting. This is for the Java formatter configuration that automatically styles our code:

1.

Go to Window > Preferences

2.

Search for formatter

3.

Click on Java > Code Style > Formatter

4.

Click New button.

5.

For Profile name, enter My Style or any name you prefer.

6.

From the Initialize settings with the following profile, choose Java Conventions

7.

Update the values to: a.

Tab policy: Spaces only b.

Indentation size: 2 c.

Tab size: 2

8.

Click Ok.

Building the Client WebStart client and WAR

In project ‘TrustStore’ run the maven tarket ‘webstart:jnlp’. This will create a war file and a zip file in folder

‘target’.

Copy the war file to the tomcat server.

Once expanded go into the subdirectory ‘jnlp’ and extract the contents of the zip file there.

Edit the file ‘truststore.jnlp’ so the parameter ‘codebase’ points to jnlp directory (e.g. http://myhost.com/TrustStore/jnlp).

Java Coding Convention

TODO

6.

B UILDING THE I P AD C LIENT

The iPad client can only be built on an Apple computer running Mac OS 10.7 or later. You will also need to install Xcode from the App Store, and get a free Apple Developer account from developer.apple.com. Then you will be able to use Xcode to build the iPad client, and run it in the Simulator.

To build the iPad client, and run it on a CSIRO iPad, you will need to talk to the CSIRO iOS Developer Program manager in IM&T. Before you do, get a free Apple Developer account.

We recommend you try the SVN client call Cornerstone. There is SCM build into Xcode, but it is more focused on git than SVN. However, we will describe both methods here, and I’m sure you’ll see why we recommend

Cornerstone. Cornerstone is available in the Mac App Store also.

As of the writing of this document, the iPad client has not been built under Xcode 4.4 or 4.5 yet, or Mountain

Lion, or for iOS 6.

Checking Out using Xcode

Choose “Connect to a repository” from the Welcome to Xcode screen. Put the URL of the repository

(https://svnserv.csiro.au/svn/ict_projects/SOSy/CloudComputing/TrustStoreProject) in the dialog that appears and choose “Next”. Give it a nicer name than ict_projects, and then choose “Next”. The paths for trunk, branches and tags are inside TrustStoreProject. Then choose “Checkout”.

Note that because Xcode is not very bright, this will check out all the TrustStore projects, including the Java bits. You don’t need them: you can just ignore them.

Checking Out using Cornerstone

Add a new Repository (HTTP Server), with the following settings:

Protocol: HTTPS

Server: svnserv.csiro.au

Repository path: svn/ict_projects

Leave the other fields as given, but make sure you enter your Nexus username and password in the Account

Information fields.

Navigate in the tree to SOSy/CloudComputing/TrustStoreProject/trunk

Select TSiPadClient and GenericiOSS3SDK, and choose Check Out from the toolbar. Pick a nice sensible location for your local copy. The name you gave the working copy will then appear on the left at the top, under

Working Copies. Choose it from there.

Building & Running

First, open

GenericS3iOSSDK/GenericS3iOSSDK.xcodeproj and then go Product > Build in Xcode (or ⌘

(this could take a while) you can close that project. Then open TSiPadClient/TSiPadWorkspace.xcworkspace.

From the build target popup:

Choose atmos-ios, and then build. Then go back to TSiPadClient and build. To run on the Simulator, choose the target Simulator under the TSiPadClient popup menu.

Deploying

We don’t have the authority to package new versions for deployment. Contact the CSIRO iOS Developer

Program manager to do this.

Download