[英]How to include rmic package jar in maven assembly
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). 我有一个多模块Maven项目,该项目必须带有生成的RMI存根(以与不能使用动态代理的旧产品集成)。 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.
我已将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>
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. 在我的“ -dist”模块中创建了程序集后,我遇到了一个问题,该模块是用于创建分发归档文件的父级的子级模块。 It does not include the client jar generated by the rmic-package execution.
它不包括由rmic-package执行生成的客户端jar。
How do I configured the assembly plugin to include the jar that the rmic plugin produces in the package phase? 如何配置Assembly插件以包括Rmic插件在打包阶段生成的jar? I tried adding a
<files.
我尝试添加
<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>
之后的部分,但是当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>
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. 注意 :我已经阅读了一个相关的问题,但是创建Stub项目似乎是不可能的,因为从中生成Stub的RMI服务器类显然需要成为主应用程序jar的一部分,而不是Stub jar的一部分,所以我不看如何在一个模块中对RMI服务器进行仿造,而在另一个模块中对其进行仿制。
I was able to solve this problem myself by switching from using moduleSets to a combination of fileSets and a dependencySets. 我自己能够解决此问题,方法是从使用moduleSets切换到fileSets和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.
fileSet拾取主jar作为程序集的根,然后将rmic客户端jar从rmic-package目标移至lib目录。 Then, the dependencySet pulls all the dependencies of the main jar into the lib directory as well.
然后,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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.