Stendhal on Eclipse: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>AntumDeluge |
imported>Hendrik Brummermann |
||
| (85 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
{{Navigation for Stendhal Top|Building & Hosting}} |
{{Navigation for Stendhal Top|Building & Hosting}} |
||
This guide describes how to setup a development environment in Eclipse for Stendhal. |
|||
== New Project from CVS == |
|||
== Get Java == |
|||
<ol> |
|||
<li>Open the view called "Package Explorer".</li> |
|||
<li>Go to the menu bar and select "File -> New Project".</li> |
|||
<li>In the "New Project" window select "CVS -> Project from CVS" and click "Next".</li> |
|||
<li>Select "Create a new repository location" and click "Next".</li> |
|||
<li>Fill in the following information: |
|||
* If you can play Stendhal, you already have Java and can skip this step. |
|||
<pre> |
|||
* If you do not have java installed, please download it https://java.com<br> (if you are on Linux, use your packet manager) |
|||
Host: arianne.cvs.sourceforge.net |
|||
Repository: /cvsroot/arianne |
|||
User: "anonymous" or Sourceforge username (for privileged checkout). |
|||
Password: Leave blank for anonymous checkout. |
|||
Connection type: pserver (for anonymous checkout) or extssh (for privileged checkout). |
|||
Select "Use default port". |
|||
</pre> |
|||
== Get Node.js == |
|||
<li>Click "Next".</li> |
|||
<li>Use specified module name: "stendhal" (or select "stendhal" from "Use an existing module).</li> |
|||
<li>Click "Finish" and checkout will begin.</li> |
|||
<li>Select "Checkout as a project configured using the new project wizard" and click "Finish".</li> |
|||
</ol> |
|||
* https://nodejs.org (optional: for building & using web client) |
|||
== New Project from Git == |
|||
== Get Eclipse== |
|||
<span style="font-style:italic;"><span style="color:red;">NOTE:</span> There are plans to move Stendhal from CVS to Git. But, there is not yet an official Git repository. For now it is recommended to checkout the source from CVS.</span><br> |
|||
<span style="font-style:italic;"><span style="color:red;">NOTE:</span> Eclipse does not come installed with a Git plugin. You will need to install EGit.</span> |
|||
<ol> |
|||
<li>Open the Eclipse Marketplace (Help -> Eclipse Marketplace).</li> |
|||
<li>Find and install EGit.</li> |
|||
<li>Restart Eclipse.</li> |
|||
<li>Open package explorer view.</li> |
|||
<li>Select "File -> Import -> Git -> Projects from Git" and click "Next".</li> |
|||
<li>Select "Clone URI" and click "Next".</li> |
|||
<li>Fill in the following information:</li> |
|||
* Go to https://www.eclipse.org/downloads/ |
|||
<pre> |
|||
* Download: "Eclipse IDE for Java Developers" |
|||
NOTE: These Git URIs are for testing and not the official Stendhal repository. |
|||
* Unzip the download and run Eclipse |
|||
They may not contain updated source code. When an official repository |
|||
* In Eclipse, close the "Welcome" window |
|||
has been established it will be shown here. |
|||
You can click on the following images to see them in large. |
|||
For anonymous checkout: |
|||
URI: git://git.code.sf.net/p/delugebuilds/stendhal-git |
|||
For privileged checkout: |
|||
URI: ssh://username@git.code.sf.net/p/delugebuilds/stendhal-git |
|||
<gallery> |
|||
Host: git.code.sf.net |
|||
File:Eclipse_00.png|On the first run of Eclipse, this "Welcome" window is shown. Please close it. |
|||
Repository path: /p/delugebuilds/stendhal-git |
|||
File:Eclipse_00a.png|Typical window layout with the Package Explorer on the left hand side and an empty area for editors in the middle |
|||
Protocol: "git" (for anonymous) or "ssh" (for privileged). |
|||
</gallery> |
|||
Port: Can be left blank. |
|||
Note: If you installed Eclipse in Ubuntu via a package manager, also install: "eclipse-egit" |
|||
Username: Only required for privileged checkout. |
|||
Password: Will be prompted for if left blank on privileged checkout. |
|||
</pre> |
|||
== New Project from Git == |
|||
<li>Click "Next".</li> |
|||
<li>Check "master" and click "Next".</li> |
|||
<li>Under "Destination" choose the directory where you want to download the source code and select "Next". The other options can be left at their defaults. |
|||
<li>After cloning has finished select "Use the New Project wizard" and click "Finish".</li> |
|||
</ol> |
|||
In Eclipse: |
|||
== Configure Project == |
|||
* Open menu "File -> Import |
|||
<ol> |
|||
* In the dialog select: "Git -> Projects from Git" and click "Next". |
|||
* Select "Clone URI" and click "Next". |
|||
<li>Project name: stendhal ( or whatever you like to call it ). |
|||
* Fill in the following information: |
|||
<li>Under the section named "JRE" make sure a Java version 1.5 or higher is selected and click "Finish".</li> |
|||
** '''URI''': |
|||
<li>Right click on your project folder and select "Properties" in the context menu.</li> |
|||
*** GitHub readonly: <code><nowiki>https://github.com/arianne/stendhal.git</nowiki></code><br>(if you have a github account, please go to https://github.com/arianne/stendhal and click on "Fork" to create you own copy of the repository and then use that in Eclipse instead) |
|||
<li>Then select "Java Build Path" on the left side of the dialog box.</li> |
|||
*** GitHub read/write (SSH): <code><nowiki>git@github.com:arianne/stendhal.git</nowiki></code> |
|||
<li>Now remove all existing folders from source path and add the two source folders 'src' and 'tests' by clicking on the "Add Folder..." button</li> |
|||
* The result of the fields are filled in automatically, click "Next" |
|||
* On the Branch selection page, keep everything selected and click "Next" |
|||
* Under "Destination" choose the directory where you want to download the source code and select "Next". |
|||
* Eclipse will now download Stendhal from git, this may take a while |
|||
* "Import existing projects" and select "Next" |
|||
* "Finish" import of project Stendhal |
|||
Click on the screenshots to enlarge them, if you need help with any of the steps: |
|||
<pre> |
|||
source folder #1: |
|||
stendhal/src |
|||
Included:(All) |
|||
Excluded:(None) |
|||
Native library location: (None) |
|||
<gallery> |
|||
source folder #2: |
|||
Eclipse 01.png|Open File | Import |
|||
stendhal/tests |
|||
Eclipse 02.png|Import from Git |
|||
Included:(All) |
|||
Eclipse 03.png|Clone URI |
|||
Excluded:(None) |
|||
Eclipse 04.png|Fill in URI and watch the remaining fields to be filled automatically |
|||
Native library location: (None) |
|||
Eclipse 05.png|Just click "next" on branch selection |
|||
Eclipse 06.png|Just click "next" on destination |
|||
Eclipse 07.png|Wait for the download to complete. This may take quite a while |
|||
Eclipse 08.png|Import existing project |
|||
Eclipse 09.png|Confirm import of project "Stendhal" by clicking finish |
|||
</gallery> |
|||
==Trouble Shooting== |
|||
default output folder: stendhal/bin |
|||
After completing the import wizard, Eclipse should look like the following screenshot: |
|||
</pre> |
|||
[[File:Eclipse 10.png]] |
|||
<i><span style="color:red;">NOTE:</span> For newer versions of eclipse an asterix (*) may need to be added manually to "Included". If the project is already checked out just right-click "src" & "tests" in the Package Explorer panel & select <span style="color:blue;">Build Path > Configure Inclusion / Exclusion Filters...</span> Under "Inclusion patterns" select "Add" then input "*" and select "OK" then "Finish". Updated screenshots to be added.</i> |
|||
There is a project called "stendhal" listed in the Package Explorer view. There may be a tiny yellow triangle in front of the blue project icon. But if you see a red circle or a red exclamation mark, something went wrong. In this case there will be an error in the "Problems" view at the bottom. |
|||
<li> On the "Libraries" tab: click on the "Add JARs" button and select all the *.jar-files in stendhal/libs (some versions of eclipse may automatically import the .jar files).</li> |
|||
<i><span style="color:red;">NOTE:</span> If project checkout did not complete before the Create New Project Wizard starts you may have to add the .jar files later. To get to the project properties page either select "Project" from the menu bar then select "Properties" or right-click the root folder in the Package Explorer panel then select "Properties" from the drop-down menu. Updated screenshots to be added.</i> |
|||
<li> Check the text encoding at Project -> Properties -> Resource -> Text Encoding. Set it to UTF-8 unless it is that already.</li> |
|||
</ol> |
|||
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 ?) |
|||
== Start StendhalServer == |
|||
==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. |
* 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. |
||
[[File:Eclipse_debug_configurations_menu.png]] |
[[File:Eclipse_debug_configurations_menu.png]] |
||
| Line 108: | Line 76: | ||
[[File:Eclipse_new_debug_configuration.png]] |
[[File:Eclipse_new_debug_configuration.png]] |
||
Name: StendhalServer |
|||
Main class: games.stendhal.server.StendhalServer |
Main class: games.stendhal.server.StendhalServer |
||
* All other settings ("include system libries", "Stop in main", ... can be left at their default value. |
* 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 "stendhal" project root folder | OK |
|||
* button [Debug] |
|||
And then the server should be started. |
|||
on the [Arguments] tab: |
|||
VM arguments: -Xmx128M |
|||
NOTE: On newer Eclipse versions, the [Classpath Entries] are under Dependencies tab. |
|||
click UserEntries |
|||
button "Advanced" |
|||
(*) add folder | OK |
|||
and select the project root folder | OK |
|||
</pre> |
|||
== Start Stendhal Client == |
|||
* button [Debug] |
|||
And then the server should be started. |
|||
==To make the client run== |
|||
# Open games.stendhal.client.update.Starter.java in the editor |
# Open games.stendhal.client.update.Starter.java in the editor |
||
# Then again the small black arrow on the right side of the green bug. |
# Then again the small black arrow on the right side of the green bug. |
||
# Select "Debug Configurations" (or "Run Configurations..."). |
# Select "Debug Configurations" (or "Run Configurations..."). |
||
# Select Java Application and click the "New" button in upper-left corner. |
# 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 |
# 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 == |
== Making patches == |
||
| Line 140: | Line 100: | ||
==Running JUnit Tests in Eclipse== |
==Running JUnit Tests in Eclipse== |
||
This is an advanced topic. If you make changes to the Java code, it is a good idea to run the automatic test. |
|||
Setting up JUnit tests in Eclipse: |
Setting up JUnit tests in Eclipse: |
||
# Click the arrow next to either the green "Run" or "Debug" button. |
# Click the arrow next to either the green "Run" or "Debug" button. |
||
| Line 157: | Line 120: | ||
# Under the Stendhal root folder select all the .jar files in libs and press OK. |
# Under the Stendhal root folder select all the .jar files in libs and press OK. |
||
# Now press "Apply" to save the configuration or "Run" to save and run it. |
# Now press "Apply" to save the configuration or "Run" to save and run it. |
||
==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. |
|||