我正在使用 Maven 2 程序集插件来构建带有依赖项的 jar 并生成可执行 JAR 文件。我的程序集包括 Spring 和 CXF 库。
CXF 包含 META-INF 文件 spring.schemas 和 spring.handlers 的副本,最终会破坏 spring-2.5.4 jar 中的类似文件。
我可以手动更新 jar-with-dependencies 中的这两个文件。
我正在寻找的是 Maven POM 中的某种方法来指导程序集插件获取这两个文件的正确版本。
程序集插件文档谈论了文件过滤,但似乎没有配置或参数,无需麻烦地创建自定义程序集描述符。
在这种情况下,制作自定义程序集描述符是我唯一的希望吗?
最佳答案
出于某种原因,Mojo 和其他人建议的解决方案仍然对我不起作用。我创建了自定义 spring.handlers
和 spring.schemas
文件,并将它们放在 src/main/resources/META-INF
下。但是,当使用 unpackOptions
时,我的文件也不包含在内。当我不使用 unpackOptions
时,我的文件不是 jar 中的文件。
我最终所做的是直接引用这些文件。这最终将我的文件放入 JAR 中。
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<!-- TODO: a jarjar format would be better -->
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>META-INF/spring.handlers</exclude>
<exclude>META-INF/spring.schemas</exclude>
</excludes>
</unpackOptions>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<files>
<file>
<source>${project.basedir}/src/main/resources/META-INF/spring.handlers</source>
<outputDirectory>META-INF</outputDirectory>
</file>
<file>
<source>${project.basedir}/src/main/resources/META-INF/spring.schemas</source>
<outputDirectory>META-INF</outputDirectory>
</file>
</files>
</assembly>
关于java - Maven 2 程序集插件破坏了一些 META-INF 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/971158/