Using annotation processors - fieldenms/tg GitHub Wiki
This document describes how to configure and use annotation processors in TG applications. For processor-specific details, refer respective wiki pages.
Development of TG applications involves the following processors:
Each processor page provides its own configuration instructions.
Combined together, a typical TG application should be configured by adding the following to pom.xml
of a *-pojo-bl
Maven module:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<!-- to enable output of annotation processors -->
<showWarnings>true</showWarnings>
<generatedSourcesDirectory>${project.build.directory}/generated-sources/</generatedSourcesDirectory>
<annotationProcessorPaths>
<path>
<groupId>fielden</groupId>
<artifactId>platform-annotation-processors</artifactId>
<version>${platform.version}</version>
</path>
</annotationProcessorPaths>
<annotationProcessors>
<processor>ua.com.fielden.platform.processors.appdomain.ApplicationDomainProcessor</processor>
<processor>ua.com.fielden.platform.processors.verify.VerifyingProcessor</processor>
<processor>ua.com.fielden.platform.processors.metamodel.MetaModelProcessor</processor>
</annotationProcessors>
</configuration>
</plugin>
</plugins>
The order of processors, specified by the <processor>
tag, matters significantly.
-
ApplicationDomainProcessor
generates theApplicationDomain
class. -
VerifyingProcessor
verifies entity definitions. It must be aware of the generatedApplicationDomain
, hence is placed after it. -
MetaModelProcessor
generates meta-models. However, if verification fails, the verifying processor can prevent any subsequent processing from taking place, hence the meta-model processor is placed after it.NOTE: Currently, the meta-model processor can't be prevented from running by the verifying processor. Therefore, even if verification fails, meta-model generation will nevertheless be attempted.
To use annotations related to annotation processing, an additional compile-time dependency should be included in the same pom.xml
file:
<dependency>
<groupId>fielden</groupId>
<artifactId>platform-annotation-processors</artifactId>
<version>${platform.version}</version>
<scope>compile</scope>
</dependency>