Manifest
The Microservice.Builder.manifest(Object)
method can be used to specify the contents or location of of the main manifest file of the executable jar.
If you do not specify the location/contents of the manifest file, the microservice will attempt to resolve it through
the following methods: - Looking on the file system for a file at META-INF/MANIFEST.MF.
This is primarily to allow for running microservices from within eclipse workspaces where the manifest file is located
in the project root.
- Using the class loader for this class to find the file at the URL
META-INF/MANIFEST.MF.
If you do manually specify the manifest file, you can pass in any of the following types:
The manifest file can be retrieved using the the Microservice.getManifest() method which provides an API for accessing manifest file entries.
This method returns an instance of ManifestFile — a lean, immutable wrapper around a java.util.jar.Manifest that returns Optional<String> from its get(...) accessors.
ManifestFile manifestFile = Microservice.getInstance().getManifest();
String mainClass = manifestFile.get("Main-Class").orElse(null);
int myInt = manifestFile.get("My-Int").map(Integer::parseInt).orElse(123);
boolean myBoolean = manifestFile.get("My-Boolean").map(Boolean::parseBoolean).orElse(false);
The manifest is also used for the $MF SVL variable.
// $MF used in variable resolver.
VarResolver var = Microservice.getInstance().getVarResolver();
System.out.println(var.resolve("The main class is $MF{Main-Class}"));
// $MF used in annotation.
@Rest(
title="$MF{Application-Title}",
...
)