Build

From mgo: The Game of Go on Mobile Phones

Jump to: navigation, search

Contents

How to build mgo from scratch

A word before we start

This manual is intended for building mgo from scratch with the Eclipse tool. In general, it is really hard even with J2ME to have some general code that works on every device for such small devices like mobilphones. Devices have different capabilities, different screen resolutions, different restrictions. On one hand, writing code for every supported devices would result in perfect aligned programs for these devices, but it is to cost intensive (in terms of man power). On the other hand writing some general code that fits for every device, would result in programs that do not use the specific capabilities of that device. In the mgo project we want to have the advantages of both approaches. In practical that means that were possible general code is written. Specific capabilties of devices are made available through some kind of plugin infrastructure. Plugin may not be the correct term, because the J2ME environment does not allow to dynamically load code from the filesystem (but everything what's in the jar file is accessable and can be loaded), but the general design paradigma of mgo makes use of a simple plugin infrastructure design.

Prerequisites

  • Installed Java Development Kit. Recommended: JDK 6 Update 12.
  • Installed Eclipse in version 3.3.2 or higher.
  • Installed Wireless toolkit. Recommended: Sun Java Wireless Toolkit 2.5.2_01 for CLDC Wireless toolkit.
  • Installed Subclipse for subversion integration in Eclipse. This is recommended. But you can also use some other subversion software.
  • Installed EclipseMe.
  • Installed Obfuscator ProGuard. Recommend: ProGuard Version 4.3.

Components of the mgo project

As reasons described above mgo itself consists of several projects:

Essential components

The following components are the minimum requirement to sucessfully build mgo.

  • mgoMain

This is the main program that contains all essential parts. Dependencies are: PluginCommon, PluginManager

  • PluginCommon

This component has all the essential parts for the plugins. Plugin Interface is defined here and also some useful parts for plugin development should be placed here.

  • PluginManager

The PluginManager is first a own Midlet that gives the user the ability to activate, deactivate and test plugins. Second it does all the Plugin loading stuff. In fact the mgoMain component uses the plugin loading mechanism that was defined here. Dependency: PluginCommon

Additional components

These components here add some extra stuff and are not necessarly needed. Every component here has a dependency to PluginCommon.

  • PluginFileConnection

Enables the filesystem of the device as defined in JSR-75 for mgo.

  • PluginSound

Enables the sound of the device. E.g. with this plugin enabled a short sound is played everytime a stone is placed.

  • PluginBoardGraphics

Gives mgo a more nice board graphic. May not be used on every device.

Debug components

The following components are just incomplete or only for demonstration. All have a dependency to PluginCommon.

  • PluginSelfTest

Just a Plugin to demonstrate Plugin development.

  • PluginSimple

Just a Plugin to demonstrate Plugin development.

  • PluginBluetooth

The Plugin is not ready yet, but it will make it possible to use bluetooth for example to exchange files.

Getting the sources

Current sources are in a subversion repository. The repository is available under https://mgo.svn.sourceforge.net/svnroot/mgo

The pattern for subversion repository access (trunk) is

https://mgo.svn.sourceforge.net/svnroot/mgo/trunk/ + Projectname

As you can see here:

PluginBluetooth: https://mgo.svn.sourceforge.net/svnroot/mgo/trunk/PluginBluetooth/

PluginBoardGraphics: https://mgo.svn.sourceforge.net/svnroot/mgo/trunk/PluginBoardGraphics/

PluginCommon: https://mgo.svn.sourceforge.net/svnroot/mgo/trunk/PluginCommon/

PluginFileConnection: https://mgo.svn.sourceforge.net/svnroot/mgo/trunk/PluginFileConnection/

PluginManager: https://mgo.svn.sourceforge.net/svnroot/mgo/trunk/PluginManager/

PluginSound: https://mgo.svn.sourceforge.net/svnroot/mgo/trunk/PluginSound/

Main Mgo: https://mgo.svn.sourceforge.net/svnroot/mgo/trunk/mgoMain/


In general you check out the whole project (with all tags, etc ...) with some command line tool like this (if you have installed some command line svn tool:

    svn co https://mgo.svn.sourceforge.net/svnroot/mgo mgo

See here for further information

Importing the sources to eclipse

  • 1) Go to "Package explorer"
  • 2) Right-click there and select "Import"

Image:import.jpg

  • 3) Select "SVN" and there "Checkout projects from SVN"

Image:import2.jpg

  • 4) Create new repository location

Image:checkout.jpg

  • 5) Input one location according to the project (see above for the correct link) and wait a litte ;-)

Image:checkout2.jpg

  • 6) Select the root folder

Image:selectRoot.jpg

  • 7) Checkout the HEAD revision through "New project wizard"

Image:selectRoot2.jpg

  • 8) Select "J2ME Midlet Suite" under "J2ME"

Image:newProject1.jpg

  • 9) As project name use the subversion name (like PluginCommon, PluginManager, ...) and enable preprocessing

Image:newProject2.jpg

  • 10) Select your WTK and your device profile. If everything is empty here, you should first import the device configurations to your eclipse. You can do this immediatly with "Manage devices".

See EclipseMe and WTK manual for further instructions. Image:newProject3.jpg

  • 11) Click finish and ignore the warning that the resource contains non standard project files.

Image:confirmOverwrite.jpg

Settings to set for build process

To generate most compatibility you should force Java 1.1 Compliance in the build settings.

Image:BuildSettings1.jpg

At least Java 1.3 Compiler Compliance should be set:

Image:BuildSettings2.jpg

Build path should be set as mentioned above. For example for Project mgo at least projects PluginCommon and PluginManager must be included. As optional you should also include all plugins you want to use like the sound plugin. All this Projects (also PluginCommon and PluginManager) must be exported if you want to use the Obfuscator (if you don't export them, the obfuscator will fail). If you don't want to use the obfuscator PluginCommon and PluginManager can be but don't have to be exported.

Image:ExportSettings1.jpg

Image:ExportSettings2.jpg

Preprocessing

The whole project uses Preprocessing. This has more historical reasons and was used to generate different package versions of the program for different devices. As with the plugin architecture Preprocessing should not be needed, anymore. But - better safe than sorry - we want to have this feature activated for a while. If problems with the plugin architecture and some devices occur, we can easily switch back.

  • Activate Preprocessing for all the mgo projects (if not done already)

Image:PreProc1.jpg

  • Define the symbol set All as in this picture:

Image:PreProc2.jpg

  • Activate this symbol set for all the projects

Image:PreProc3.jpg

Obfuscation

For internal development an obfuscator is not necessary, but making the final jar file smaller in size is important for deployment. Some devices have specific restrictions for jar file size. An Obfuscator like Proguard is used mainly to make the final jar size smaller (it just renames classnames like "org.mobilego.mgo.gui.forms.menu.ingameMenu.InGameMenuController" to "A" and save some space) Also Proguard omits classes that are never used.

To activate proguard, please go to Window->Preferences->J2ME->Packaging->Obfuscation (you can also set this settings per project, but then you have to do this for every project)

Image:ObfuscationSettings.jpg

Set the Proguard settings to:

Specific arguments

  • -dontusemixedcaseclassnames -dontnote -defaultpackage

Keep Extension

  • public class * extends javax.microedition.midlet.MIDlet
  • public class * extends org.mobilego.mgo.plugins.common.IPlugin
  • public class * extends org.mobilego.mgo.plugins.PluginSample
Personal tools