Package org.tquadrat.foundation.i18n.ap


package org.tquadrat.foundation.i18n.ap

This project provides an annotation processor that externalises messages and text that were defined by the annotations from the org.tquadrat.foundation.i18n module.

Use the Annotation Processor with plain javac

That javac can find the annotation processor requires to add the *.jar file with the package org.tquadrat.foundation.i18n.ap to the CLASSPATH; from there javac will detect the annotation processor automatically; or the class name for the annotation processor, I18nAnnotationProcessor, can be provided explicitly with the -processor option.

Finally, the destination for the generated sources has to be set with the -s option.

The documentation for javac says "[…]Unless annotation processing is disabled with the -proc:none option, the compiler searches for any annotation processors that are available. The search path can be specified with the -processorpath option. If no path is specified, then the user class path is used. Processors are located by means of service provider-configuration files named META-INF/services/javax.annotation.processing.Processor on the search path. Such files should contain the names of any annotation processors to be used, listed one per line. Alternatively, processors can be specified explicitly, using the -processor option.[…]"

Configure Maven to use the Annotation Processor

For Maven, the following lines must be added to the pom.xml of the project to build:

…
  <dependencies>
      …
      <dependency>
          <groupId>org.tquadrat.library</groupId>
          <artifactId>org.tquadrat.foundation.i18n</artifactId>
          <version>proper_version</version>
          <scope>compile</scope>
      </dependency>
      …
  </dependencies>
  …
  <build>
      …
      <plugins>
          …
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              …
              <configuration>
                  …
                  <annotationProcessorPaths>
                      <annotationProcessorPath>
                          <groupId>org.tquadrat.tool</groupId>
                          <artifactId>org.tquadrat.foundation.i18n.ap</artifactId>
                          <version>proper_version</version>
                      </annotationProcessorPath>
                      …
                  </annotationProcessorPaths>
                  …
              </configuration>
              …
              <executions>
                  …
                  <execution>
                      <id>default-compile</id>
                      <phase>compile</phase>
                      <goals>
                          <goal>compile</goal>
                      </goals>
                      <configuration>
                          …
                          <annotationProcessors>
                              <annotationProcessor>org.tquadrat.foundation.i18n.ap.I18NAnnotationProcessor</annotationProcessor>
                              …
                          </annotationProcessors>
                          …
                          <compilerArgs>
                              …
                              <arg>-Aorg.tquadrat.foundation.ap.maven.goal=compile</arg>
                              …
                          </compilerArgs>
                          …
                      </configuration>
                      …
                  </execution>
                  …
              </executions>
              …
          </plugin>
          …
      </plugins>
      …
  </build>

Configure Gradle to use the Annotation Processor

To add the annotation processor to the Gradle build configuration, place the following line to the respective build.gradle file:

  …
  dependencies {
      implementation 'org:tquadrat.library:org.tquadrat.foundation.i18n:<proper version>' // For an application
      api 'org:tquadrat.library:org.tquadrat.foundation.i18n:<proper version>' // For a library

      annotationProcessor 'org:tquadrat.library:org.tquadrat.foundation.i18n.ap:<proper version>'
  }
  
  • Class
    Description
    The annotation processor for the module org.tquadrat.foundation.i18n.
    A visitor class that collects the texts for resource bundle properties files from the annotations.
    Entries for resource bundle properties files.
    The implementation for a DefaultHandler that handles the files for additional text resources.