如何在Maven Shade插件中设置清单类路径? [英] How to set manifest class-path in maven shade plugin?
问题描述
我正在使用阴影插件,除了可以通过以下方式为清单设置类路径之外,其他一切都正常运行
I'm using shade plugin and everything works fine except for being able to set Class-Path for manifest via
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.generic.App</mainClass>
<classPath>. ./config</classPath>
</transformer>
我得到
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default) on project SpringThing: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.1:shade for parameter transformer: Cannot find setter, adder nor field in org.apache.maven.plugins.shade.resource.ManifestResourceTransformer for 'classPath' -> [Help 1]
查看文档
应该能够解析任何有效的清单资源?我尝试了clss-path Class-Path ClassPath无效...
Should be able to parse any valid manifest resource? I tried clss-path Class-Path ClassPath nothing works...
我需要classpath来设置外部应用程序属性文件的位置。
I need the classpath to set location of external app property files.
由于一个众所周知的问题,我正在使用阴影插件而不是程序集:
I'm using shade plugin instead of assembly because of a well known problem:
http://blog.idm.fr/2009/09/maven-assembly-plugin-and-spring-namespace- handlers.html
我可以很容易地在汇编中做到这一点:(而且有效)
I can do this in assembly pretty easily by the way: (and it works)
<manifestEntries>
<Class-Path>. ./config</Class-Path>
</manifestEntries>
我无法通过maven使用oneJar插件,因为您也无法设置清单条目。 (我不认为吗?)
I can't use oneJar plugin via maven because you can't set manifest entries either. (I don't think?)
有什么想法吗?
推荐答案
尝试一下,它应该与maven-shade-plugin 2.1版一起使用:
Try this and it should work with maven-shade-plugin version 2.1:
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>your.main.class</Main-Class>
<Class-Path>your/class/path/here</Class-Path>
</manifestEntries>
</transformer>
标记标记< Class-Path> $ c中的差异$ c>,就像您曾经
< classPath>
Mark the difference in tag <Class-Path>
as you had <classPath>
这篇关于如何在Maven Shade插件中设置清单类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!