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 which extends from JsonMap allowing you to retrieve entries as any data types supported by that class.
ManifestFile manifestFile = Microservice.getInstance().getManifest();
String mainClass = manifestFile.getString("Main-Class");
int myInt = manifestFile.getInt("My-Int", 123);
boolean myBoolean = manifestFile.getBoolean("My-Boolean");
The manifest is also used for the $MF SVL variable.
// $MF used in variable resolver.
VarResolver var = Microservice.getInstance().getVarResolver();
System.out.println(vr.resolve("The main class is $MF{Main-Class}"));
// $MF used in annotation.
@Rest(
title="$MF{Application-Title}",
...
)