Java 如何在maven程序集中包含rmic包jar

Java 如何在maven程序集中包含rmic包jar,java,rmi,maven-assembly-plugin,Java,Rmi,Maven Assembly Plugin,我有一个多模块maven项目,它必须生成RMI存根(以便与不能使用动态代理的遗留产品集成)。我已经将RMICMaven插件配置为在编译阶段执行rmic,并在打包阶段打包存根jar <execution> <id>rmic-process-classes</id> <goals> <goal>rmic</goal> </goals>

我有一个多模块maven项目,它必须生成RMI存根(以便与不能使用动态代理的遗留产品集成)。我已经将RMICMaven插件配置为在编译阶段执行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>

rmic进程类
rmic
编译
真的
com.MyImpl
rmic包
包裹
在my'-dist'模块中创建程序集后,我遇到了一个问题,my'-dist'模块是用于创建分发存档的父级的子模块。它不包括rmic包执行生成的客户机jar


我如何配置汇编插件以包含rmic插件在包阶段生成的jar?我尝试添加一个
,通过从使用模块集切换到文件集和依赖集的组合,我自己就能够解决这个问题。文件集将程序集根目录的主jar和rmic客户机jar从rmic包目标中提取到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>

../{project}/target
.
*jar先生
*-dl-*.jar
../{project}/target
解放党
*-dl-*.jar
假的
解放党
{groupId}:{artifact}
假的

不确定a)我的问题是如此可怕或无知,以至于每个人都忽略了它;b)没有人知道答案;或者c)没有人熟悉Maven必须处理遗留的RMI应用程序。虽然接受的答案已经超过4年了,但缺少具体的例子。@GKrost感谢您的反馈。我借此机会改进了我的答案。
<!-- 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>