How to manipulate Manifest file with maven

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 06:31:07

问题


I have an EAR file built with maven. The EAR contains several jars and I need to add a line in the manifest file for just one of these jars. I know of the maven-jar-plugin option (manifestEntries) but this is good for a single standalone jar, not one that is inside an EAR.


回答1:


If you take a deeper look into maven-ear-plugin configuration you will find the archive configuration part which is exactly intended for such purposes.

This can be added to the configuration of the maven-ear-plugin:

<archive>
  <addMavenDescriptor/>
  <compress/>
  <forced/>
  <index/>
  <manifest>
    <addClasspath/>
    <addDefaultImplementationEntries/>
    <addDefaultSpecificationEntries/>
    <addExtensions/>
    <classpathLayoutType/>
    <classpathMavenRepositoryLayout/>
    <classpathPrefix/>
    <customClasspathLayout/>
    <mainClass/>
    <packageName/>
  </manifest>
  <manifestEntries>
    <key>value</key>
  </manifestEntries>
  <manifestFile/>
  <manifestSections>
    <manifestSection>
      <name/>
      <manifestEntries>
        <key>value</key>
      </manifestEntries>
    <manifestSection/>
  </manifestSections>
  <pomPropertiesFile/>
</archive>

Which gives you any opportunity you need.




回答2:


I think can you look at the maven-shade-plugin and use the ManifestResourceTransformer to change the manifest for the jar.



来源:https://stackoverflow.com/questions/10704543/how-to-manipulate-manifest-file-with-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!