Harald Wirths - 2015-01-23

Integration of Remote Tea in Maven projects

The following descriptions rely on version 1.1.1 of Remote Tea (see http://search.maven.org/#search|ga|1|remotetea). For convinence it is assumed, that the version has been defined as a property in the properties section of a POM as shown below:

 <properties>
 ...
   <remotetea.version>1.1.1</remotetea.version>
 ...
 </properties>

The runtime environment of ONC/RPC can be included by adding the dependency

 <dependencies>
 ...
   <dependency>
     <groupId>org.acplt.remotetea</groupId>
     <artifactId>remotetea-oncrpc</artifactId>
     <version>${remotetea.version}</version>
   </dependency>
 ...
 </dependencies>

in the dependencies block of the POM.

If an RPC program is defined in an x-file located for example in src/main/resources/example.x, related Java classes can be generated using the Maven plugin remotetea-maven-plugin. Actually the goals client, server and clientandserver are available. Planning the directory target/generated-sources as destination directory of the generated classes, the plugin build-helper-maven-plugin may be used to get the directory target/generated-sources considered as additional source directory in the project. Following, an example of the plugin configuration in a POM is given:

<build>
...
  <plugins>
    <plugin>
      <groupId>org.acplt.remotetea</groupId>
      <artifactId>remotetea-maven-plugin</artifactId>
      <version>${remotetea.version}</version>
      <executions>
        <execution>
          <id>jrpcgen</id>
          <goals>
            <goal>clientandserver</goal>
          </goals>
          <configuration>
            <xFile>src/main/resources/example.x</xFile>
            <destDir>${project.build.directory}/generated-sources</destDir>
            <packageName>com.example</packageName>
            <!-- Force the creation of the destination directory
                 if it does not already exist at generation time. --> 
            <createDir>true</createDir>
            <!-- Uncomment the following line to create
                 an RPC server listening only on TCP. -->
            <!-- <serverTcpOnly>true</serverTcpOnly> -->
            <!-- Uncomment the following line to create
                 an RPC server listening only on UDP. -->
            <!-- <serverUdpOnly>true</serverUdpOnly> -->
          </configuration>
        </execution>
      </executions>
    </plugin>
    <!-- Let the destination directory containing the generated
         Java sources be considered as additional source
         directory. --> 
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <version>1.9.1</version>
      <executions>
        <execution>
          <phase>generate-sources</phase>
          <goals>
            <goal>add-source</goal>
          </goals>
          <configuration>
            <sources>
              <source>${project.build.directory}/generated-sources</source>
            </sources>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
...
</build>

Remote Tea gets sometimes deployed as well as snapshot to the snapshot repository of Sonatype (actually version 1.1.1-SNAPSHOT). To get access to this repository, the following profile can be added to the profiles section in settings.xml:

<profiles>
...
  <profile>
    <id>sonatype-snapshots</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <repositories>
      <repository>
        <id>sonatype_snapshots</id>
        <name>Sonatype Snapshot Repository</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <releases>
          <enabled>false</enabled>
        </releases>
      </repository>
    </repositories>
    <!-- The plugin repositories section is needed only,
         if the Maven plugin of Remote Tea is planned
         to use. -->
    <pluginRepositories>
      <pluginRepository>
        <id>sonatype_snapshots</id>
        <name>Sonatype Snapshot Repository</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <releases>
          <enabled>false</enabled>
        </releases>
      </pluginRepository>
    </pluginRepositories>
  </profile>
...
</profiles>
 

Last edit: Harald Wirths 2015-01-31