Usage

Generating ResourceBundle bundles together with corresponding accessor classes

The jdtaus-resource-mojo:java-resources goal of the Resource Plugin is bound to the process-resources phase in the build lifecycle. The mojo needs to be setup manually in a project to get executed. To generate an accessor class for a ResourceBundle which is backed by properties file resources of your project add the following to the project's pom.xml.

...
<build>
  <plugins>
    ...
    <plugin>
      <groupId>org.jdtaus.mojo</groupId>
      <artifactId>jdtaus-resource-mojo</artifactId>
      <version>${jdtaus-resource-mojo.artifact.version}</version>
      <executions>
        <execution>
          <id>jdtaus-generate</id>
          <goals>
            <goal>java-resources</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ...
  <plugins>
</build>
...

and add a module descriptor to the project (searched for at src/main/resources/META-INF/jdtaus/module.xml by default) like so

<?xml version="1.0" encoding="UTF-8"?>
<container:module xmlns:container="http://jdtaus.org/core/model/container"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://jdtaus.org/core/model/container http://xml.jdtaus.org/1.0.x/jdtaus-core/jdtaus-core-schemas/jdtaus-container-1.1.xsd">

  <container:implementations>
    <container:implementation container:identifier="com.yourcompany.YourClass"
                              container:name="jDTAUS Core ⁑ Resource Mojo"
                              container:vendor="jDTAUS"
                              container:version="3.14">

      <container:messages>
        <container:reference container:name="yourMessage"/>
      </container:messages>
    </container:implementation>
  </container:implementations>

  <container:messages>
    <container:message container:name="yourMessage">
      <container:template container:defaultLanguage="en">
        <container:text container:language="en"><![CDATA[English message text with {0} argument]]></container:text>
        <container:text container:language="de"><![CDATA[Deutscher Meldungs-Text mit Argument {0}]]></container:text>
      </container:template>
      <container:arguments>
        <container:argument container:index="0" container:name="argumentName" container:type="text"/>
      </container:arguments>
    </container:message>
  </container:messages>

  ...
</container:module>

The goal processes the specified messages and generates accessor classes together with corresponding properties files for all messages from the module descriptor.

See the jdtaus-container-1.1.xsd XML schema regarding the document structure.