Using Eclipse

From AzureusWiki

(Redirected from UsingEclipse)
Jump to: navigation, search

This page gives a step by step description of running the Azureus BitTorrent client in the Eclipse IDE. This has been tested with Azureus2.3.0.5 CVS and Eclipse 3.2M2 but should work with Eclipse 3.1.1, too.

Note: If you're familiar with Eclipse and want to do everything your own way the Project and Run chapters will be interesting for you


Contents

Installing Eclipse

  1. Download Eclipse and extract the archive to a directory of your choice
  2. Start the Eclipse launcher (the actual file name depends on the OS) and choose a location for the workspace (the default path should be ok)
  3. Under Window > Preferences, tweak the following settings:
    • Java > Build Path: select Folders and clear the source folder box and make sure "bin" is in the output folder box.
    • Team > CVS > Connection set the timeout to 200 since the sourceforge CVS servers tend to be slow
  4. click on OK and go to the Project Menu and unselect Build Automatically (Eclipse will build the project anyway when you use the Run option)

Set up a CVS Repository and import Azureus sources

To load Azureus into Eclipse for editing, the first thing you should do is set up a CVS repository. That way you can easily get the latest code. Lets walk through those steps.

  1. Open up the CVS Repository perspective in Eclipse. You can do that by going to Window > Open Perspective > CVS Repository Exploring. If the CVS Repositories view is not showing, click on Window > Show View > CVS Repositories.
  2. Right click in the CVS perspective, and choose New > Repository Location. You will be presented with the Add a new CVS Repository dialog. There are three fields you need to fill in:
    • Host: azureus.cvs.sourceforge.net
    • Repository Path: /cvsroot/azureus
    • User: anonymous
    • Password: <leave blank>
    • Connnection type: pserver
  3. When the repository is included open the HEAD branch (that might take a while since the sourceforge servers can be quite slow). Right-click on azureus2 and select Check Out As...
  4. Select Check out as a new project using New Project Wizard and click on Finish
  5. In the new popup window select Java > Java Project, continue, enter a Project name, i.e. "azureus2" and select create seperate source and output folders (the .class files will be placed in a different output folder instead in the same folders as the sourcecode)
  6. Finish both wizards

When the download of the sources is done you can change to the Java Perspective (Window > Open Perspective > Java), adding the Navigator view could be useful to explore the project's file structure.

Configure the Project

Once you're in the java perspective you should do the following things:

  1. Go to the Navigator tab
  2. Right-click on the project > Properties > Java Build Path > Libraries
  3. Now Add JARs..., select your project and go to build > libs, then select all .jar files
  4. Go to the 1st Tab (Source), select the Excluded element and edit it. Then add the bin and build folders to the source exclusion paths
  5. Have a short look at the output folder stated on the bottom, it should be "project_name/bin"
  6. Save everything and and close the popups

Eclipse should be able to compile your project now, you can manually start a build process via Right-click > Build Project'

Configure the Run dialog

  1. Go to the Navigator tab
  2. Right-click on the project > Run AS... > Run
  3. Select Java application, click on New and give it a name (i.e. the same as the project name)
  4. Put "org.gudy.azureus2.ui.swt.Main" into the Main class box.
  5. Go to the Arguments tab and deselect the checkbox on the bottom and put the path of your installed Azureus version in there as the working directory if you want to reuse the installed plugins and/or sub-directories created by plugins.
    • Note: If you don't have a pre-built version of Azureus you'll need to download the swt-libs for your OS from the Eclipse website and put them into the specified working directory. It might be a good idea to create the working directory outside the workspace since the core plugins will be installed in it.
  6. Go to the Classpath tab and remove all user entries
  7. Add the output folder through Advanced > Add Folder to the User Entries (see step 4 of the project configuration)
  8. Add the swt.jar from your installed Azureus version/working directory through Add External JARs... to the User Entries
  9. Go to the Environment tab and add Variable LD_LIBRARY_PATH with the Value of your output folder (see step 4 of the project configuration)
  10. Apply and run Azureus

Synchronizing with the CVS

  1. Go to the Navigator tab
  2. Right-click on the project > Team > Synchronize with Repository... (it should change to the Team perspective now or open the Synchronize tab)
  3. Wait until Eclipse has found all differences (the sourceforge CVS server can be very slow sometimes or even timeout, then you should try again later)
  4. Click on the Incoming Mode button if you want to see what has changed
  5. Click on the Update all incoming changes... button to update
  6. In case you have modified files and the same files have been changed in the CVS too continue with the following steps:
  7. Click on the Conflicts Mode button
  8. Double-click on the conflicting file(s) to open the Compare Editor
  9. Now you can what differs on both sides, since you don't have CVS write access you can only import incoming changes, either do that manually by clicking on the square in the middle bar for each incoming change or simply click on the Copy all non-conflicting changes from the right to the left button, of course that only works for differences on that don't conflict with your own changes. If there are such differences you have to rewrite your code manually.
  10. after you have imported the changes from CVS or modified your own code in a way that matches the CVS changes right-click on the file in the Synchronize tab and select Mark as Merged


Building an Azureus2.jar

  1. Go to the Navigator tab
  2. If you haven't built the project yet: Right-click on the project > Build Project
  3. Right-click on the project > Import/Export
  4. Go to the export tab and select Java > JAR file
  5. In the next step select your Project and in the Select resources to export field
  6. Only these checkboxes should be checked: Export all output folders for checked projects, compress the contents of the jar file and add directory entries (make sure you excluded the right folders from the source tree, see #Configure the Project)
  7. choose a output folder for your Azureus2.jar, i.e. your azureus program/working directory (see #Configure the Run dialog)
  8. If you have to build .jar files frequently you can go to the next page and overwrite the Azureus2.jardesc in your project root folder
    To rebuild the .jar file Right-click on the Azureus2.jarfile in the Package Explorer and select Create jar
  9. Go to the last page and add org.gudy.azureus2.ui.swt.Main as main class
  10. Finish the dialog and wait until the .jar file is build

Developing Plugins

see Plugin development


Additional source files

the following cvs sub-trees are used to create the Beta builds but aren't included in the cvsroot/azureus/azureus2 tree

  • cvsroot/azureus/components/ (thread load monitoring)
  • cvsroot/azureus/uis/ (console UI)
  • cvsroot/azureus/plugins/jpc/ (joltid peer cache plugin)
Personal tools