我有一个多模块的maven项目,它必须具有与它一起生成的RMI存根(与不能使用动态代理的遗留产品集成)。我已经将rmic-maven-plugin配置为在编译阶段执行rmic,并在包阶段打包存根jar。
<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>在我的“-dist”模块中创建程序集后,我遇到了一个问题,该模块是父程序集的子模块,用于创建分发存档。它不包括由rmic包执行生成的客户端jar。
如何将组装插件配置为包含rmic插件在包阶段生成的jar?我尝试在<files.之后添加一个<moduleSets>节,但是当文件部分出现时,只会将这些文件放在程序集中,就好像moduleSet部分不存在一样。
<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>备注:我读过related question,但创建一个Stub项目似乎是不可能的,因为生成存根的RMI服务器类显然需要是主应用程序jar的一部分,而不是stub jar的一部分,所以我不知道如何在一个模块中rmic RMI服务器,而在另一个模块中使用javac。
发布于 2012-07-06 20:32:03
通过从使用moduleSets切换到fileSets和dependencySets的组合,我自己解决了这个问题。fileSets为程序集的根获取主jar,从rmic-package目标获取rmic客户端jar到lib目录。然后,dependencySet将主jar的所有依赖项都拉到lib目录中。
<!-- Include the -dl jar created by the rmic-package goal in
the lib part of the assembly. It is necessary because
the target VM does not support dynamic RMI stubs, so the
stubs must be deployed in the assembly. -->
<fileSets>
<fileSet>
<directory>../{project}/target</directory>
<outputDirectory>.</outputDirectory>
<!-- put the main jar in the top level -->
<includes>
<include>*.jar</include>
</includes>
<!-- don't include the RMIC-built -dl jar at the top -->
<excludes>
<exclude>*-dl-*.jar</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>../{project}/target</directory>
<outputDirectory>lib</outputDirectory>
<!-- put the RMIC-built -dl jar in the lib dir -->
<includes>
<include>*-dl-*.jar</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<!-- put all the dependencies in lib, as usual -->
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<excludes>
<!-- don't include the main jar, which is at
the top level already. -->
<exclude>{groupId}:{artifact}</exclude>
</excludes>
<unpack>false</unpack>
</dependencySet>
</dependencySets>https://stackoverflow.com/questions/11270657
复制相似问题