How do you create a MANIFEST.MF that's available when you're testing and running from a jar in production?

前端 未结 9 1058
失恋的感觉
失恋的感觉 2020-12-28 16:28

I\'ve spent far too much time trying to figure this out. This should be the simplest thing and everyone who distributes Java applications in jars must have to deal with it.

9条回答
  •  我在风中等你
    2020-12-28 17:17

    You can use a utility class Manifests from jcabi-manifests that automates finding and parsing of all MANIFEST.MF files available in classpath. Then, you read any attribute with a one liner:

    final String name = Manifests.read("Build-By");
    final String date = Manifests.read("Build-Date");
    

    Also, check this out: http://www.yegor256.com/2014/07/03/how-to-read-manifest-mf.html

提交回复
热议问题