Usage

Prerequisites

The plugin itself does not include the SQLJ Translator, but expects it to be available on the classpath during build time. For this to happen, an artifact containing the SQLJ Translator (the sqlj.tools.Sqlj class) needs to be added as a dependency to the plugin or as a dependency to the project. Below is an example showing how to configure an SQLJ artifact as a dependency to the plugin:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>sqlj-maven-plugin</artifactId>
  <version>1.3</version>
  <dependencies>
    <dependency>
      <groupId>com.ibm.db2</groupId>
      <artifactId>sqlj</artifactId>
      <version>1.0</version>
    </dependency>
  </dependencies>
</plugin>      

The coordinates of the SQLJ artifact does not matter. The coordinates used above are only an example.

The plugin will use standard Maven artifact resolution to retrieve the artifact from configured Maven repositories. Typically the SQLJ artifact should be deployed to your internally hosted Maven repository, which will make it available for the entire development team. However, for quick evaluation purposes you could add it to your local repository instead. You would do the latter through the usage of the Maven Install Plugin:

mvn install:install-file \
    -DgroupId=com.ibm.db2 \
    -DartifactId=sqlj \
    -Dversion=1.0 \
    -Dpackaging=jar \
    -Dfile=c:\progra~1\ibm\SQLLIB\java\sqlj.zip \
    -DgeneratePom=true

Note: Adding it to your local repository would only make the artifact available for that specific environment and is therefore normally not a good solution for development teams.

SQLJ Translation classpath

The classpath used during SQLJ Translation is as follows:

  1. the classpath of the plugin
  2. the classpath of the project (compile resolution scope)

Note: Java classes in the project will not be included as the plugin executes before they are compiled.

Translating SQLJ source code

To parse and translate SQLJ source code, configure the sqljDirs and/or sqljFiles element. Both can be used at the same time. Only files with .sqlj extension will be picked up from the sqljDirs element.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>sqlj-maven-plugin</artifactId>
  <version>1.3</version>
  <executions>
    <execution>
      <id>sqlj</id>
      <goals>
        <goal>sqlj</goal>
      </goals>
      <configuration>
        <sqljDirs>
          <sqljDir>src/main/sqlj</sqljDir>
        </sqljDirs>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    ...
  </dependencies>
</plugin>