“No main manifest attribute” when creating Kotlin jar using IntelliJ IDEA

倖福魔咒の 提交于 2019-12-17 22:01:38

问题


When creating a jar from my Kotlin code and running it, it says "No main manifest attribute". When looking at the manifest.mf, it has this content:

Manifest-Version: 1.0

When looking at the file in the source, it has this content:

Manifest-Version: 1.0
Main-Class: MyMainClass

When manually copying the source manifest to the jar, it runs perfectly.

Screenshot of my artifact settings


回答1:


If any of the dependent jars has a MANIFEST.MF file, it will override your custom one which defines the Main-Class.

In order to address this problem you should do the following:

  • Disable the alphabetical ordering
  • Change items ordering so that item which has META-INF/MANIFEST.MF file is the first in the list
  • Your custom MANIFEST.MF will be picked up by IntelliJ IDEA and displayed for the jar artifact.

See the related issue for more details.

You can also use Gradle or Maven to generate the fat jar instead.



来源:https://stackoverflow.com/questions/54892529/no-main-manifest-attribute-when-creating-kotlin-jar-using-intellij-idea

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