I have a multi-module maven project that must have RMI stubs generated with it (to integrate with a legacy product that can’t use dynamic proxies). I have configured the rmic-maven-plugin to do the rmic during the compile phase, and to package the stubs jar during the package phase.
<execution>
<id>rmic-process-classes</id>
<goals>
<goal>rmic</goal>
</goals>
<phase>compile</phase>
<configuration>
<keep>true</keep>
<!--outputDirectory>${project.build.outputDirectory}</outputDirectory-->
<includes>
<include>com.MyImpl</include>
</includes>
</configuration>
</execution>
<execution>
<id>rmic-package</id>
<goals>
<goal>package</goal>
</goals>
<configuration>
<!--outputDirectory>${project.build.outputDirectory}</outputDirectory>
<finalName>broker-dl</finalName>
<classifier>${project.version}</classifier-->
</configuration>
</execution>
I run into an issue after the assembly is created in my ‘-dist’ module, which is a child module of the parent that exists to create the distribution archive. It does not include the client jar generated by the rmic-package execution.
How do I configured the assembly plugin to include the jar that the rmic plugin produces in the package phase? I tried adding a <files. section after the <moduleSets>, but when the files section is present, only those files end up in my assembly, as though the moduleSet section didn’t exist.
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>com:ImplModule</include>
</includes>
<binaries>
<unpack>false</unpack>
<fileMode>644</fileMode>
<directoryMode>755</directoryMode>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
<files>
<file>
<outputDirectory>lib</outputDirectory>
<source>../ImplModule/target/ImplModule-${project.version}-client.jar</source>
<fileMode>644</fileMode>
</file>
</files>
Note: I have read a related question but creating a Stub project seems impossible, since the RMI server class from which the stub is generated clearly needs to be a part of the main application jar, not part of a Stub jar, so I don’t see how to rmic the RMI server in one module and yet javac it in another.
I was able to solve this problem myself by switching from using moduleSets to a combination of fileSets and a dependencySets. The fileSets pick up the main jar for the root of the assembly, and the rmic client jar from the rmic-package goal into the lib directory. Then, the dependencySet pulls all the dependencies of the main jar into the lib directory as well.