package org.folio.okapi.common;

import io.vertx.core.logging.Logger;
import java.io.InputStream;
import java.util.Properties;

public class ModuleVersionReporter {

  private String version;
  private String artifact;
  private String gitCommitId;
  private String gitRemoteOriginUrl;

  private final Logger logger = OkapiLogger.get();

  public ModuleVersionReporter(String path) {
    readProperties(path);
  }

  private void readProperties(String path) {
    try {
      final String fp = "META-INF/maven/" + path + "/pom.properties";
      InputStream in = getClass().getClassLoader().
        getResourceAsStream(fp);
      if (in != null) {
        Properties prop = new Properties();
        prop.load(in);
        in.close();
        version = prop.getProperty("version");
        artifact = prop.getProperty("artifactId");
      } else {
        logger.warn(fp + " not found");
      }
      in = getClass().getClassLoader().getResourceAsStream("git.properties");
      if (in != null) {
        Properties prop = new Properties();
        prop.load(in);
        in.close();
        gitCommitId = prop.getProperty("git.commit.id");
        gitRemoteOriginUrl = prop.getProperty("git.remote.origin.url");
      } else {
        logger.warn("git.properties not found");
      }
    } catch (Exception ex) {
      logger.warn(ex);
    }
  }

  public String getModule() {
    return artifact;
  }

  public String getVersion() {
    return version;
  }

  public String getCommitId() {
    return gitCommitId;
  }

  public String getRemoteOriginUrl() {
    return gitRemoteOriginUrl;
  }

  public void logStart() {
    logger.info("Module " + getModule() + " " + getVersion() + " started");
    logger.info("git: " + gitRemoteOriginUrl + " " + getCommitId());
  }
}

@@ -401,16 +401,148 @@
 ies(path
+, %22git.properties%22);%0A  %7D%0A%0A  public ModuleVersionReporter(String path, String gitProperties) %7B%0A    readProperties(path, gitProperties
 );%0A  %7D%0A%0A
@@ -574,32 +574,54 @@
 ties(String path
+, String gitProperties
 ) %7B%0A    try %7B%0A  
@@ -1104,22 +1104,20 @@
 sStream(
-%22
 git
-.p
+P
 ropertie
@@ -1113,25 +1113,24 @@
 itProperties
-%22
 );%0A      if 

Allow git properties file to be given for ModuleVersionReporte OKAPI-486