Part 4: Deploying the Audit to Together
The previous parts of this tutorial explained all the coding for the audit. This part explains the deployment steps. Two more files are required:
- a JAR file containing a default manifest file and the EmptyMethodRule
class
- an audit XML plugin file.
Together needs the two files in order to locate and use your new audit.
- You can create the JAR file within Together. From the
main menu, choose File > Export.
- In the resulting dialog, choose JAR file and click Next. The JAR Export page opens.
- In the Select resources to export list on the
left, check CustomAudit.
- The right side of the dialog has a list of project
resources. Uncheck .classpath and .project
since these files do not need to be in the JAR file.
- In the Select the export destination field,
click Browse to find the destination for the JAR:
$Together_home$\eclipse\plugins\com.togethersoft.sapient.audit
Together scans for audits in this directory. Here, you
find the audit.jar file that contains all the standard audits that
come with Together as well as any additional JAR files added for custom
audits.
- In the File name field, enter the JAR name,
example.jar. Then click Save.
- Make sure that the option Export generated class
files and resources is checked. Your dialog should be similar to the
following.
- Click Finish. This creates the JAR file in the proper
place.
- Now, create the audit XML plugin file. In the UML Explorer
view, right click on the CustomAudit project,
and choose New > Other.
- In the resulting dialog, choose Simple > File, and
click Next.
- In New File dialog, click the CustomAudit
project. In the File name field, enter example.xml.
- Click Finish. The newly created empty file opens in the editor.
- Click the Source tab at the bottom of the editor. Then copy and paste the following text into the file:
<?xml version="1.0"?>
<plugin>
 <inspector id="Audit">
  <category id="CS"
description="Coding
style">
   <analyzer id="EM"
name="Empty
Method" implementation="EmptyMethodRule"
library="example.jar">
    <parameter type="string"
name="severity"
value="Info"
/>
   </analyzer>
  </category>
 </inspector>
</plugin>
The category tag determines the category in the QA preferences where the user selects which audits to apply. While you could create an entirely new category, this example simply uses an existing category, Coding style.
The analyzer tag defines the audit's
abbreviation, name, and the JAR where it is located. The abbreviation
and name display on the audit tab for QA preferences, under the Coding
style group.
The parameter tag sets the default severity for the audit.
- Save the audit plugin XML file. Then copy it to the same directory as example.jar:
$Together_home$\eclipse\plugins\com.togethersoft.sapient.audit
Together scans the audit directory looking for audits,
using the XML files in the audit directory to determine which audits to
load and where to find them. Together can find example.xml file
and load the audit from example.jar.