Usage

Managing source code sections in java source files

The java-container, java-container-tests, java-commit and java-commit-tests goals of the plugin are used in a parent pom of a multi-module project by providing a configuration as shown below. For each project providing container model data (as determined by the container implementation provided to the plugin by a corresponding container implementation dependency), the plugin will manage the contents of various source code sections based on that data.

See the jdtaus-container-1.1.xsd XML schema regarding the jDTAUS Container reference implemenation, which expects XML document resources located at classpath location META-INF/jdtaus/module.xml.

...
<build>
  ...
  <pluginManagement>
    <plugins>
      ...
      <plugin>
        <groupId>org.jdtaus.mojo</groupId>
        <artifactId>jdtaus-container-mojo</artifactId>
        <version>${jdtaus-container-mojo.artifact.version}</version>
        <dependencies>
          <dependency>
            <groupId>org.jdtaus.core.container</groupId>
            <artifactId>jdtaus-core-client-container</artifactId>
            <version>${core.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>remove-trailing-spaces</id>
            <phase>validate</phase>
            <inherited>true</inherited>
            <goals>
              <goal>clean-sources</goal>
            </goals>
          </execution>
          <execution>
            <id>manage-main</id>
            <inherited>true</inherited>
            <goals>
              <goal>java-container</goal>
            </goals>
          </execution>
          <execution>
            <id>manage-tests</id>
            <inherited>true</inherited>
            <goals>
              <goal>java-container-tests</goal>
            </goals>
          </execution>
          <execution>
            <id>commit-main</id>
            <inherited>true</inherited>
            <goals>
              <goal>java-commit</goal>
            </goals>
          </execution>
          <execution>
            <id>commit-tests</id>
            <inherited>true</inherited>
            <goals>
              <goal>java-commit-tests</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <locale>en</locale>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
      ...
    </plugins>
  </pluginManagement>
  ..
  <plugins>
    ...
    <plugin>
      <groupId>org.jdtaus.mojo</groupId>
      <artifactId>jdtaus-container-mojo</artifactId>
    </plugin>
    ...
  </plugins>
  ...
</build>

Note: The default plugin configuration expects the following section markers to be present in source files of java classes defined in a project's container model. Any non-existent source file will be created in the source root configured via the sourceRoot parameter.

    //--Constructors------------------------------------------------------------
    //------------------------------------------------------------Constructors--
    //--Dependencies------------------------------------------------------------
    //------------------------------------------------------------Dependencies--
    //--Properties--------------------------------------------------------------
    //--------------------------------------------------------------Properties--
    //--Messages----------------------------------------------------------------
    //----------------------------------------------------------------Messages--

Removing trailing spaces from a projects' source files

The jdtaus-container-mojo:clean-sources goal of the Container Plugin is not bound to any lifecycle phase and is intended to be invoked on its own or to be added to a multi-module parent project.

To remove any trailing spaces from a projects' source files, execute the following command in that project's base directory.

  mvn org.jdtaus.mojo:jdtaus-container-mojo:clean-sources

Validating a set of runtime artifacts to form a valid container model.

The jdtaus-container-mojo:verify-model goal of the Container Plugin is bound to the verify lifecycle phase. It is intended to be used on projects creating a final distribution artifact of an application and will fail a build for any problems leading to an invalid container runtime.

To use the goal, add the following to the final distribution project.

...
<build>
  <plugins>
    ...
    <plugin>
      <groupId>org.jdtaus.mojo</groupId>
      <artifactId>jdtaus-container-mojo</artifactId>
      <version>${jdtaus-container-mojo.artifact.version}</version>
      <dependencies>
        <dependency>
          <groupId>org.jdtaus.core.container</groupId>
          <artifactId>jdtaus-core-client-container</artifactId>
          <version>${core.version}</version>
        </dependency>
      </dependencies>
      <executions>
        <execution>
          <id>verify-model</id>
          <goals>
            <goal>verify-model</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ...
  <plugins>
</build>
...

Validating a single jar file to contain valid container model data

The jdtaus-container-mojo:verify-jar goal of the Container Plugin is bound to the verify lifecycle phase. It is intended to be used for validating a single jar file to contain valid container model data and will fail a build for any problems.

To use the goal, add the following to the project and adjust the value of the jarFile attribute accordingly.

...
<build>
  <plugins>
    ...
    <plugin>
      <groupId>org.jdtaus.mojo</groupId>
      <artifactId>jdtaus-container-mojo</artifactId>
      <version>${jdtaus-container-mojo.artifact.version}</version>
      <dependencies>
        <dependency>
          <groupId>org.jdtaus.core.container</groupId>
          <artifactId>jdtaus-core-client-container</artifactId>
          <version>${core.version}</version>
        </dependency>
      </dependencies>
      <executions>
        <execution>
          <id>verify-jar</id>
          <goals>
            <goal>verify-jar</goal>
          </goals>
          <configuration>
            <jarFile>/home/schulte/VPS/jdtaus/jdtaus-core/tags/jdtaus-core-1.15/jdtaus-container-mojo/target/jdtaus-container-mojo-3.13.jar</jarFile>
          </configuration>
        </execution>
      </executions>
    </plugin>
    ...
  <plugins>
</build>
...

Creating a spring beans document from a project's container model

The jdtaus-container-mojo:spring-descriptor goal of the Container Plugin is bound to the process-resources lifecycle phase. It is intended to be used for creating a spring beans document with information compatible with the project's container model.

To use the goal, add the following to the project.

...
<build>
  <plugins>
    ...
    <plugin>
      <groupId>org.jdtaus.mojo</groupId>
      <artifactId>jdtaus-container-mojo</artifactId>
      <version>${jdtaus-container-mojo.artifact.version}</version>
      <dependencies>
        <dependency>
          <groupId>org.jdtaus.core.container</groupId>
          <artifactId>jdtaus-core-client-container</artifactId>
          <version>${core.version}</version>
        </dependency>
      </dependencies>
      <executions>
        <execution>
          <id>spring-descriptor</id>
          <goals>
            <goal>spring-descriptor</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ...
  <plugins>
</build>
...

Note: Mapping a jDTAUS Container model to a Spring beans model does not decouple from the jDTAUS Container. The generated spring beans descriptor solely helps in accessing classes managed by the jDTAUS container from a spring container.