Wrong Manifest.mf in IntelliJ IDEA created .jar

前端 未结 7 1886
-上瘾入骨i
-上瘾入骨i 2020-11-28 02:08

I\'m trying to package a project using OptaPlanner 6.0.1 libraries into a .jar through IntelliJ IDEA\'s jar artifact but instead of my manifest.mf containing the standard

相关标签:
7条回答
  • 2020-11-28 02:35

    As noted in @grudolf's comment in one of the other answers, one way to do this (and the only one that worked for me in an imported Gradle project) is to create an empty jar as follows:

    • Project Structure -> Artifacts -> + Jar -> Empty
    • Centre pane now has Create Manifest and Use Existing Manifest buttons. Use one of these.
    • I had difficulty if I extracted dependent libraries with their own manifests into the output root, they seemed to intermittently overwrite the new manually created manifest. Messing around with order of operations seemed to make it work.

    UPDATE:

    This is definitely a bug in Idea. This linked answer works reliably when there are extracted directories. In essence, you find your .idea/JARNAME.xml, add add the following element to the very top of the <root> element for your jar. Any extracted elements above your new file-copy that contain a manifest will clobber your new manifest.

      <element id="directory" name="/META-INF">
        <element id="file-copy" path="$PROJECT_DIR$/modulename/src/META-INF/MANIFEST.MF" />
      </element>
    
    0 讨论(0)
提交回复
热议问题