0

I'm trying to add AppName and Version to actuator's /info endpoint using jcabi-manifests https://github.com/jcabi/jcabi-manifests library. Code snippet is below:

@Component
public class VersionInfoContributor implements InfoContributor {

@Override
public void contribute(Info.Builder builder) {
    String artifactName = Manifests.read("Artifact-Name");

    builder.withDetail("Artifact-Name", artifactName);
}

Artifact-Name is set in build.gradle file next way:

jar {
   manifest {
        attributes("Artifact-Name": "TestActuator")
    }
}

The attribute IS present in META-INF/MANIFEST.MF file inside result .jar file but when trying to access /info endpoint getting error: Attribute 'Artifact-Name' not found in MANIFEST.MF file(s) among 46 other attribute(s)

I know there is BuildProperties bean in Spring-boot actuator but won't like idea to expose all these fields - AppName and Version more than enough.

Alex Kamornikov
  • 278
  • 2
  • 10
  • Try to turn logging ON to see what attributes are visible – yegor256 Mar 22 '18 at 20:45
  • "Agent-Class", "Ant-Version", "Archiver-Version", "Automatic-Module-Name", "Bnd-LastModified", "Boot-Class-Path", "Build-Jdk", "Build-Timestamp", "Built-By", "Bundle-Description", "Bundle-DocURL", "Bundle-License", "Bundle-ManifestVersion",etc. Inside Manifests.append(Mf streams) there are 58 stream fetched. A lot of them are coming from jdk, some from spring-boot libraries but there is no stream from my .jar. – Alex Kamornikov Mar 22 '18 at 21:27
  • It seems that your JAR is not on the classpath at the time of calling `Manifests.read()`. Most likely it's loaded later, by Spring. Not sure how it works exactly in Spring. – yegor256 Mar 23 '18 at 07:59

0 Answers0