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

There are several stages to this: building AJDT, running the correctness tests, and creating an Eclipse update site. The first two stages are probably sufficient for most purposes.

#### Building AJDT

Many of the plugins which implement AJDT contain aspects, and so are AspectJ projects themselves. This means that you first need to install a recent build of AJDT into your development environment from the update site or zip file.

Note also that in order to build AJDT from source you will probably need to increase the memory available to Eclipse. This is typically done by passing something like `"-vmargs -Xmx512m"` to the Eclipse launcher.

Start with a clean workspace under Eclipse 3.2. 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 = /cvsroot/tools, Username = anonymous, password should be left blank. Connection type = pserver. Click "Finish". Use the CVS Repositories view to navigate to HEAD/org.eclipse.ajdt/AJDT_src.

You now need to switch to the "ajdt1_4" branch in CVS. To discover the branch, you need to right-click on org.eclipse.ajdt and select "Configure Branches and Versions...", and in the dialog that opens navigate to AJDT_src/org.aspect.ajde/.project. Various tags should appear in the right hand side of the dialog. Press "Add Checked Tags", then "OK". Back in the CVS Repositories view you should now be able to navigate to Branches/ajdt1_4/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.aspectj.weaver,
- 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, after which should you be 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 "Eclipse Application" 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.ui.tests
- org.eclipse.contribution.visualiser.tests
- org.eclipse.contribution.xref.core.tests
- org.eclipse.contribution.xref.ui.tests

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.tests project, then the src folder, then the org.eclipse.ajdt.core.tests package. Now select the AllCoreTests.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.ui.tests project, then the src folder, then the org.eclipse.ajdt.ui.tests package. Now select the AllUITests.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.

#### 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 choose to run in a separate JRE.

Those plugins that use aspects in their implementation need to be built using the AspectJ compiler. To do this the "iajc" Ant task is used in each of the relevant build.xml files. For this to run successfully, it needs to be able to locate the org.aspectj.ajde and org.aspectj.weaver plugins from the installed version of AJDT. Each build.xml file refers to the specific version on AJDT installed on the build machine, so unless you have exactly the same version installed, you need to uncomment and override the "aspectj.plugin.home" and "aspectj.weaver.home" properties in the build.xml file from the "UpdateSite" project.