RSS Feed for This PostCurrent Article

Maven: Build RMI Stub Using Ant RMIC Task

Oops, it is Maven again. This time I need to build RMI server and client stub classes using Maven. To do this I used the Maven Ant Run plugin.

In my pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>

    <dependencies>
        <dependency>
            <groupId>sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${java.home}/../
             lib/tools.jar</systemPath>
        </dependency>
    </dependencies>

    <executions>

        <execution>
            <id>compile</id>
            <phase>compile</phase>
            <configuration>
                <tasks>
                    <property name="compile_classpath"
                        refid="maven.compile.classpath"/>
                    <property name="runtime_classpath"
                        refid="maven.runtime.classpath"/>
                    <property name="test_classpath"
                         refid="maven.test.classpath"/>
                    <property name="plugin_classpath"
                         refid="maven.plugin.classpath"/>
                    <property name="compile_path"
                         value="target/classes"/>

                    <rmic verify="true"
                          debug="on"
                          classpathref="maven.compile.classpath"
                          includes="**/*.class"
                          base="${compile_path}"
                    />
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The trick here is that I need to set the dependency to point to Java tools.jar file.


Trackback URL


RSS Feed for This PostPost a Comment