Stendhal on Eclipse
First Steps
- First of all open the view called Package Explorer.
- "New Project..."
- "CVS" -> "Project from CVS"
- Get stendhal from CVS. (Connection type: pserver, User: anonymous, Password - leave blank, Host:arianne.cvs.sourceforge.net, Repository: /cvsroot/arianne)
- Right click on your project folder and select "Properties" in the context menu.
- Then select "Java Build Path" on the left side of the dialog box.
- Now remove all existing folders from source path and add the two source folders 'src' and 'tests' by clicking on the "Add Folder..." button
- On the "Libraries" tab: click on the "Add JARs" button and select all the *.jar-files in stendhal/libs
- Check the text encoding at Project -> Properties -> Resource -> Text Encoding. Set it to UTF-8 unless it is that already.
file-> new -> project -> project-> from cvs click next check "create new repository" click next host : arianne.cvs.sourceforge.net repository path : /cvsroot/arianne user : anonymous connection Type: pserver click next check "use an existing module" click directory: stendhal click next checkout as a project configured using the new project wizard click next click finish select a wizard: java project (do not select a simple "general" project!) project Name: stendhal ( or whatever you like to call it ) make sure in jre a java version 1.5 or higher is selected click finish
source folder #1:
stendhal/src
Included:(All)
Excluded:(None)
Native library location: (None)
source folder #2:
stendhal/tests
Included:(All)
Excluded:(None)
Native library location: (None)
default output folder: stendhal/bin
Eclipse should be able to compile the source code now. There could be a little yellow sign (signalling warning messages) before your project folder but there must not be red X (error messages). The package explorer should now display the "src" folder below the root folder with a different icon, the icon is like a small grid.
Trouble Shooting
menu Windows | Preferences | Java | Installed JREs
- there should be at least one entry with a valid JAVA_HOME path (make it so so JDK compliance is 5.0 ?)
To make it run the server in Debug mode
- In the toolbar there is the "Debug" button, which looks like a little, green bug. There is a little black arrow on the right side of it.
- This will open a menu, please choose "Debug configurations ..." ("Open Debug Dialog..." on older versions)
- Then in the dialog select "Java Application" and click on the "new" icon in the top left corner.
Name: StendhalServer
Main class: games.stendhal.server.StendhalServer
* All other settings ("include system libries", "Stop in main", ... can be left at their default value.
on the [Arguments] tab:
VM arguments: -Xmx128M
on the [Classpath] tab:
click UserEntries
button "Advanced"
(*) add folder | OK
and select the project root folder | OK
- button [Debug]
And then the server should be started.
To make the client run
- Open games.stendhal.client.update.Starter.java in the editor
- Then again the small black arrow on the right side of the green bug. (Or you may also choose to use the "Run" command instead of "Debug" in case you only want to debug the server component.)
- Select "Debug Configurations" (or "Run Configurations...").
- Select Java Application and click the "New" button in upper-left corner.
- On the [Classpath] tab select "User Entries" - button "Advanced" - (*) add folder | OK - and select the project root folder. | OK
yay shiny new client, shiny server
Making patches
If you have modified and tested the code and want to send us a patch, please see How To Create Patch For Stendhal.
Running JUnit Tests in Eclipse
If you are runing JUnit tests in Eclipse, there are some additional things to be taken into account:
- Eclipse always automatically sets up a new run configuration for you if you invoke the "Run As" -> "JUnitTest" context command on a class or folder. It creates a default classpath configuration derived from the project settings in this run configurations. So there is missing the 'Stendhal' root folder in the classpath, which results in failures running some test cases. To fix this, open the run configurations and add the 'Stendhal' root folder like described above for the client configuration:
- On the [Classpath] tab - button "Advanced" - (*) add folder | OK - and select the project root folder. | OK
- After adding project-root to your classpath, Eclipse should automatically exclude the folders "src/" and "tests/". If not, exclude them together with "tools/" and "tiled/src/".
Setting up JUnit tests in Eclipse:
- Click the arrow next to either the green "Run" or "Debug" button.
- Select "Run/Debug Configurations...".
- Select "JUnit" in the left column and press the "New launch configuration" at the top of left column.
- Give it a unique name, like "Stendhal Tests".
- Select "Run all tests in the selected project, package or source folder".
- OPTIONAL:
- Press "Search".
- Select "tests" folder under Stendhal root directory and press "OK".
- Under "Test runner" select "JUnit 4".
- Under "Classpath" tab select "User Entries" and press "Advanced" on the right panel.
- Select "Add Folders" and press "OK".
- Select the Stendhal root folder and press "OK".
Switching from pserver to extssh
If you need to switch from anonymous read-only access to read/write, follow these instructions. (based on clues at http://blog.maestropublishing.com/changing-cvs-username-and-password-in-an-ecli)
- Window -> Show View -> Other
- Open up CVS, and double click on "CVS Repositories". A new tab will show up, named CVS Repositories
- Right click on the arianne line, and select Properties
- Change Connection Type to extssh
- Set User and Password to your sourceforge user id and password
- Click Apply. Eclipse will take a few minutes to update attributes.
After that, test by trying another CVS Synchronize. The first time, you will probably get a dialog about the server certificate.