订阅所有JSP/Servlet的日志 订阅 | 这是最新一篇日志 上一篇 | 下一篇日志 下一篇 ]
RoboCode

建立Robocode开发向导

Content





Introduction

This page is meant for developers who want to compile and build Robocode. If you just want to browse the sources, you can do it from

here

.


All sources are available from the Robocode CVS Repository on

SourceForge

, and

here

you can read of how to access the CVS for Robocode.



Basically, you can just download the CVS modules for Robocode, and then run the Ant build script provided for each CVS module, or use your favourite IDE for compiling and building Robocode. However, this guide will describe how to set everything up based on the

Eclipse SDK

. The Eclipse SDK is a very popular IDE, which is free of charge, and which contains all necessary tools in order to access the CVS, run the Ant build scripts etc. So if you use Eclipse you don't have to worry too much of how to setup the IDE for building Robocode. If you should rather like to use another IDE, then you'll have to figure out by yourself of how to do it based on the information provided in this guide. If you figure it out, then you could send the description to me, and I will include it in this guide.



Software requirements





Please notice



  • You must install the SDK version Eclipse and JDK version of Java, or else you will not be able to compile the Robocode sources! You also have to install the Java JDK before installing the Eclipse SDK.
  • You must ensure that you have set up the environment variable named JAVA_HOME according to the installation notes for the Java Developer Kit (JDK), e.g. C:\jdk1.5.0_08 (on Windows). In addition, you must add JAVA_HOME/bin to your PATH environment variable, e.g. PATH=%PATH%;JAVA_HOME\bin under Windows, and $PATH=$PATH:$JAVA_HOME/bin under Linux and Mac. This must be done as Apatche Ant, which is used for building Robocode is depending on these environment variables, and will not be able to build Robocode without them.




How to build Robocode in Eclipse step by step

The following steps assume that you have Java and Eclipse up and running, and describe how to create a workspace for Robocode, to extract the sources from the CVS, and how to build Robocode.



  1. In Eclipse, select "Switch Workspace..." from the File menu. Type in a file path to a folder where you want the Robocode workspace to be located, where the name of the workspace could be something like "Robocode-workspace" or anything else you prefer. Eclipse will restart, and your Robocode workspace is ready.
  2. Now you need to add the Java SE 5.0 Runtime Environment (JRE), which is included in the Java SE JDK.

    1. Go to the Window menu and select "Preferences...".
    2. Locate the "Installed JREs" under the "Java" node in the left side of the Preferences window. You will have to click on the plus sign so the "Java" node unfolds in order to see the "Installed JREs".
    3. Check if the JRE for Java 5.0 is listed under "Installed JREs". If so, you don't need to add the JRE 5.0, as it is already added to Eclipse, and you can skip the following. If not, click on "Installed JREs" and press the "Add..." button on the right side of the window in order to add the JRE 5.0. A "Add JRE" window is opened where you:

      1. Click on the "Browse..." button and select the folder where you have installed the Java SE JDK 5.0.
      2. When this is done correctly, the list of "JRE System Libraries" is automatically filled out for you.
      3. Press "OK" to close the window.

    4. Press "OK" to close the Preferences windows.

  3. In order to build Robocode, Ant (build tool) must point at the correct tools.jar in your JDK 5.0.

    1. In the Window menu, select the "Preferences...".
    2. Locate the "Runtime" under the "Ant" node in the left side of the Preferences window, and click on it.
    3. Expand the "Global Entries" by clicking on the plus sign.
    4. Check that Global Entries contains an entry which point to the ../lib/tools.jar file where your JDK 5.0 is installed. If no entry exists which point to the ../lib/tools.jar file in your JDK 5.0 you must add it by pressing the "Add External JARs..." button, and browse to and select the ../lib/tools.jar file from the folder where your JDK 5.0 is installed.
    5. Press "OK" to close the Preferences windows.

  4. Next the sources must be extracted from the Robocode CVS on source forge:

    1. In the File menu, hold the mouse over the first item, "New", and select the last item "Other...".
    2. A "New" window will open, where you must double-click on the "CVS" item and select "Projects from CVS".
    3. Press "Next".
    4. A new "Checkout from CVS" window will open where you make sure the "Create a new repository location" is selected, and press "Next".
    5. The content of the window will change, where you write:

      1. robocode.cvs.sourceforge.net into the text field for "Host".
      2. /cvsroot/robocode into the text field for "Repository path".
      3. anonymous in the text field for "User".

      The "Connection type" must be "pserver" (is default), and "Use default port" must be selected.
    6. Press "Next".
    7. The content of the window will change, where you must select "Use an existing module..".
    8. Now you should be able to see a list of all available CVS modules in the Robocode CVS repository.
    9. Next, you must select these 4 modules and press "Next" afterwards (by holding the Ctrl on the keyboard down while clicking on each needed module):

      1. autoextract
      2. build
      3. robocode
      4. robocodeextract

      The
      1
       CVSROOT 
      

      is used by the CVS only, so you don't need it. The
      1
      installapplet 
      

      is used for installing Robocode from a webpage on the Internet, so you don't need this either, but you are welcome to download it, if you want to inspect it.
    10. After having pressed "Next", a new window occurs ("Check Out As") where you make sure "Check out in the workspace as projects" is selected, and press "Finish".
    11. Now all 4 CVS modules are downloaded from the Robocode CVS repository into your Robocode workspace.
    12. Please notice, that Eclipse will automatically begin compiling/building files in the workspace while the sources are being downloaded from the Robocode CVS. However, you will not be able to run/launch Robocode yet.

  5. When all files have been downloaded from the CVS, and the building of the workspace has finished, you must first run the
    1
    build.xml
    

    files in the
    1
    robocode 
    

    module/project. Right-click on the
    1
    robocode/build.xml
    

    file and select the "1 Ant Build" under "Run As". This will compile all the sources of the Robocode game, and will also extract files from the
    1
    robocodeextract 
    

    into the
    1
    build 
    

    project for running Robocode. Notice, you don't have to run the
    1
    robocode/build.xml 
    

    every time you modify a source files and want to compile Robocode. This is done automatically by Eclipse for you.




Running Robocode from Eclipse


The following assumes that all files have been downloaded and built in your Robocode workspace.



In order to run Robocode from eclipse, you must click on the green play-button from the toolbar in the top of the Eclipse IDE. The first time you try to run Robocode, you must first click on the little arrow on the play-button and select Robocode.




About the Robocode CVS modules


    The Robocode CVS Repository contains the following modules:
  • robocode, which contains:

    • resources, the resources for the game, e.g. image and icon files.
    • robocode, which is the Java package of Robocode containing all source files of the game.

  • robocodeextract, which contains files beside the game itself like:

    • The OS dependent stuff like icon files and batch files
    • The sample robots
    • The template files for creating a robot
    • Template files for battles
    • The Jikes compiler
    • The license file

    These files are necessary when building the installation/setup file for Robocode.
  • autoextract, which is the Java installer of Robocode for installing Robocode.
  • installapplet, which is a Java Applet for installing Robocode from a webpage.
  • build, which contains the main build script for compiling various parts of Robocode, but especially the installation/setup file for Robocode.
  • CVSROOT, which is the root of the Robocode CVS, and which is automatically maintained by CVS.




About the build

All output files of Robocode are created in the
1
build/build 

folder.

The
1
build/build.xml 

script contains various targets for building various parts for the Robocode distribution file. The default target is to build the Robocode setup file necessary for installing Robocode. The Robocode setup file contains all necessary files for installing and running Robocode including files from the
1
robocodeextract 

module. The
1
build/build.xml 

is also responsible of building the Javadoc files of Robocode. So if the Robocode API is changed, the Javadoc is automatically built and put in the distribution/setup file.

平均得分
(0 次评分)





文章来自: SourceForge
标签: Robocode SourceForge 
评论: 0 | 查看次数: 532
发表评论
昵 称:  登录
内 容:
选 项:
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启