2012-06-30 162 views
1

我有一个多模块Maven项目,必须有它生成的RMI存根(与不能使用动态代理的旧产品集成)。我已经配置了rmic-maven-plugin在编译阶段执行rmic,并在包阶段打包存根jar。如何在maven程序集中包含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-package执行生成的客户机jar。

如何配置程序集插件以包含rmic插件在程序包阶段生成的jar?我尝试在<moduleSets>之后添加<files.部分,但是当文件部分存在时,只有这些文件最终在我的程序集中,就好像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但创建一个存根项目似乎是不可能的,因为从其产生存根的RMI服务器类显然需要是主要的应用程序JAR的一部分,而不是部分一个Stub jar,所以我没有看到如何在一个模块中使用RMI服务器,而在另一个模块中使用javac。

+0

不知道如果)我的问题是如此可怕的或无知,每个人都只是忽略了它,二)没有人知道答案,或c)没有人十分熟悉Maven有应对传统RMI的应用程序。 – mwhidden

回答

0

我能够通过从使用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> 
+0

虽然接受的答案是4岁以上,但缺乏特定的例子。 –

+0

@GKrost感谢您的反馈。我借此机会改进了我的答案。 – mwhidden

相关问题