Updating .annotation files through an ANT Eclipse Builder

Eclipse's ANT Builders allow the execution of any ANT script when workspace files change. The following describes how to create an ANT Builder configuration that automatically extracts the annotations from modified Business Entities. 

Create the build.xml file

The following is an excerpt of an build.xml file. For more details on writing build.xml files, please refer to the ANT and PCT documentation.

Excerpt from build.xml
<?xml version="1.0" encoding="utf-8"?>
<project name="SmartComponent Library" default="SmartComponentLibrary" basedir=".">

	<description>SmartComponent Library</description>

    <property environment="env" />
    <property file="build/build.props" />

	<!-- Définition des tâches externes -->
    <taskdef resource="PCT.properties" classpath="/Progress/PCT116/ant/lib/PCT.jar" />
    <typedef resource="types.properties" classpath="/Progress/PCT116/ant/lib/PCT.jar" />  
    <taskdef resource="extras115.properties" classpath="/Progress/PCT116/ant/lib/PCT.jar" /> 
    <import file="Consultingwerk/Studio/ExtractClassAnnotations/extract-class-annotations.xml"/>
	
    <!-- For use as an Eclipse ANT builder with the -DbuildFiles={build_files} parameter -->	
    <target name="ExtractClassAnnotationsBuilder">
        <extractClassAnnotations directory="."
                                 fileMask="*BusinessEntity.cls"
                                 overwriteWriteProtected="true"
                                 excludeAnnotations="@Test,@TestIgnore,@BusinessEntityGenerator"
                                 verbose="true" 
                                 buildFiles="${buildFiles}" />
    </target> 
</project>

Defining the ANT Builder

Using the project property sheet, add a new ANT Builder:

 

Specify your build.xml file name and the project root folder as the working folder.

The Arguments to the ANT script should be: -DbuildFiles="${build_files:f}" - This will pass the names of the modified files that caused the build as an argument to the ANT script.

 

Select the EctractClassAnnotationBuilder task for execution on the Auto Build event:

 

The ANT script does not need to allocate the console. By unchecking this checkbox you ensure that the script will not switch to the Console view of Eclipse whenever a file is modified.