I\'m trying to read my META-INF/MANIFEST.MF file from my Spring Boot web app (contained in a jar file).
I\'m trying the following code:
Input
I have it exploiting Spring's resource resolution:
@Service
public class ManifestService {
protected String ciBuild;
public String getCiBuild() { return ciBuild; }
@Value("${manifest.basename:/META-INF/MANIFEST.MF}")
protected void setManifestBasename(Resource resource) {
if (!resource.exists()) return;
try (final InputStream stream = resource.getInputStream()) {
final Manifest manifest = new Manifest(stream);
ciBuild = manifest.getMainAttributes().getValue("CI-Build");
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Here we're getting CI-Build
, and you can easily extend the example to load other attributes.