# Deploying an AspectJ plug-in

AspectJ plug-ins can either be build through the Export Plug-ins and Fragments with AspectJ Support Wizard or with an Ant build script. To use the wizard:

1. Select File > Export... > Deployable plug-ins and fragments with AspectJ support.
2. Select the plug-ins and fragments you want to export.
3. You can deploy the plug-ins in one of three formats:
   - a single ZIP file whose content can be unzipped into any Eclipse-based product.
   - a directory structure, so the destination of the export operation can be the root of an Eclipse installation.
   - individual JAR archives for an Update site. This option will result in the creation of one JAR per plug-in, and the JARs will be placed in a plugins/ subdirectory of the chosen destination.

The following issues apply to plug-ins that advise classes in a JAR:

1. The wizard does not translate your project build path to your plug-in classpath. This can result in a build failure (which will appear as an error in the build.xml file generated by the export wizard) if your plug-in includes aspects that advise classes in a JAR. This is still the case even if the JAR is in your project structure and on its build path. To avoid this problem, you must manually add the JAR to the plug-in classpath, making it available to the export wizard, and the plug-in itself at runtime. You can do this on the Runtime tab of the plugin.xml editor. Click the "Add..." button in the classpath section and add the JAR, then save plugin.xml. The export should now complete without error.

It is also worth noting that this problem does not occur when the plug-in is run/debugged from Eclipse; in this case the additional JARs/classes will be picked up.

2. In fixing your classpath, as described above, your plug-in will pick up the versions of the classes which your aspects advise, but not the woven versions. The files exported by default are as follows:

- The class file corresponding to each source file (Java class or Aspect) in the project
- JAR files, properties files and anything else that doesn't need to be compiled

This does not include the woven versions of classes in JARs (advised by the aspects in the project) as there is no corresponding Java source file. These woven classes do exist in the project structure, in the project's output directory (as shown in the Navigator view).

In order for your exported plug-in to use the woven versions of classes from JARs in your project you must add the output directory to the plug-in's build configuration. You can do this in the "Runtime Information" section of the "Build Configuration" page of the plugin.xml editor. By default, there is a single library called "." with a corresponding "src/" folder. Click the "Add Folder" button on the right and select the "bin/" folder (or whatever your output folder is called). The exported plug-in will now use the woven versions of any classes from the JAR file.

See Creating an Ant build file for an AspectJ plug-in for details on how to deploy a plug-in using an Ant build file.

Creating a new AspectJ plug-in project
Converting a plug-in project to an AspectJ project
Creating an Ant build file for an AspectJ plug-in