# How do I setup an AJDT development environment in Eclipse?

There are several stages to this: building AJDT, running the correctness tests, running the performance tests, and creating an Eclipse update site. The first two stages are probably sufficient for most purposes. Note that the steps required for the first stage depend on whether you are using Eclipse 3.0 or 3.1.

#### Building AJDT

Note first of all that in order to build AJDT you may need to increase the memory available to Eclipse. This is typically done by passing something like `"-vmargs -Xmx256m"` to the Eclipse launcher.

Start with a clean workspace under Eclipse 3.0.1 or the latest milestone build of Eclipse 3.1. Now open the CVS Repository Exploring perspective. Right-click on the CVS Repositories view, then click "New" > "Repository Location". Host = dev.eclipse.org, Repository path = /home/technology, Username = anonymous, password should be left blank. Connection type = pserver. Click "Finish". Use the CVS Repositories view to navigate to org.eclipse.ajdt/AJDT_src. Select the following projects, right-click and select "Check out" from the context menu:

- org.aspectj.ajde,
- org.aspectj.runtime,
- org.eclipse.ajdt.core,
- org.eclipse.ajdt.examples,
- org.eclipse.ajdt.ui,
- org.eclipse.contribution.visualiser,
- org.eclipse.contribution.xref.core,
- org.eclipse.contribution.xref.ui.

Eclipse will build the projects as you import them. Some projects contain source code for both Eclipse 3.0 and 3.1, so the next step is to ensure the correct build configurations are being used:

- Expand each of the following projects in the package explorer in turn: org.eclipse.ajdt.core, and org.eclipse.ajdt.ui.
- Eclipse 3.0: Locate the build30.ajproperties file in each project, then right-click and select "Activate this configuration", if it is not the active configuration already. This will ensure that the 3.0.x versions of all files are being built. If you installed a recent version of AJDT, the build30.ajproperties files should be activated by default.
- Eclipse 3.1: Locate the build31.ajproperties file in each project, then right-click and select "Activate this configuration", if it is not the active configuration already. This will ensure that the 3.1 versions of all files are being built. If you installed a recent version of AJDT, you will need to activate all of the build31.ajproperties files, because the Eclipse 3.0 versions will be chosen as the default ones.

Now you're ready to run the plugins inside Eclipse:

- Switch to the Java Perspective if you're not already in it...
- From the run menu select "Run..."
- Select "Run-time workbench" (this is called "Eclipse Application" on Eclipse 3.1) and click new
- Give your launch configuration a name, and click "Run"
- Subsequent runs can simpy use the launch configuration you just created

#### Running the correctness tests

The next step is to add the test projects. These can be used to verify that everything is okay with your environment and configuration, plus of course to verify the integrity of any changes you might make. Switch back to the CVS perspective and check-out the following projects:

- org.eclipse.ajdt.core.tests
- org.eclipse.ajdt.test
- org.eclipse.contribution.visualiser.tests
- org.eclipse.contribution.xref.core.test
- org.eclipse.contribution.xref.ui.test

There are two steps to running all of the tests. The first is to run the AJDT core specific tests found in org.eclipse.ajdt.core.tests, and the second is to run the remaining tests.

To run the AJDT core specific tests expand the org.eclipse.ajdt.core.test project, then the src folder, then the org.eclipse.ajdt.core.tests package. Now select the AllAJDTCoreTests.java file, right-click and select "Run As" > "JUnit Plug-in Test". A new runtime workbench should then be launched and the tests run inside that. Progress and test results can be observed from the JUnit Eclipse view.

You can then run all of the remaining tests by expanding the org.eclipse.ajdt.test project, then the testsrc folder, then the org.eclipse.ajdt.test package. Now select the AllTests.java file, right-click and select "Run As" > "JUnit Plug-in Test". A new runtime workbench should then be launched and the tests run inside that. Progress and test results can be observed from the JUnit Eclipse view.

Now you're ready to start enhancing the plugins by adding to or extending the code in your projects - just use run (or debug) to try out your changes. When you have a patch to submit to the project, go to the "Team" item in the project context menu and select "Create Patch...". Naturally the correctness tests should also be run, and new tests written to accompany fixes or new features.

#### Running the performance tests

Work is underway on a new plugin, org.eclipse.ajdt.tests.performance, to monitor the performance of every build of AJDT. This plugin has dependencies on a number of Eclipse test projects, which are not shipped in the base Eclipse SDK. These instructions will be updated later when the plugin is fully up and running.

#### Creating an update site

Each of the AJDT plugin projects also contains an Ant build file, "build.xml." The default target builds a packaged version of the project in question. Check-out the "UpdateSite" project from CVS, and use the build.xml file in that project to invoke a master build that builds an entire update site structure in its "dist" directory. To run the build.xml file inside Eclipse, you need to do "Run As > Ant Build..." to bring up the run configuration dialog, then go to the "JRE" tab and select "Run in the same JRE as the workspace". This is required for the "eclipse.incrementalBuild" Ant task to work.

You can now test the built update site as follows:

- Copy the contents of the dist directory to a clean directory, outside of your workspace. For example, "ajupdate."
- From the help menu of the Eclipse in which you wish to install the AspectJ feature, choose "Help" > "Software Updates" > "Find and Install..." and follow the steps outlined earlier in this section.