/** * Builds the engine instance. * * @return the built engine */ public synchronized MustacheEngine build() { MustacheEngine engine = new DefaultMustacheEngine(this); for (EngineBuiltCallback callback : engineReadyCallbacks) { callback.engineBuilt(engine); } BuildInfo buildInfo = BuildInfo.load(); LOGGER.info("Engine built {} ({})", buildInfo.getVersion(), buildInfo.getTimestampDate()); LOGGER.debug("Engine configuration: {}", engine.getConfiguration().getInfo()); isBuilt = true; return engine; }
public static BuildInfo load() { String version = null; String timestamp = null; // First try to get trimou-build.properties file try (InputStream in = MustacheEngineBuilder.class.getResourceAsStream(BUILD_PROPERTIES_FILE)) { if (in != null) { Properties buildProperties = new Properties(); buildProperties.load(in); version = buildProperties.getProperty("version"); timestamp = buildProperties.getProperty("timestamp"); } } catch (IOException e) { // No-op } if (version == null) { // If not available try to use the manifest info version = MustacheEngineBuilder.class.getPackage().getImplementationVersion(); } if (Strings.isEmpty(version)) { version = "SNAPSHOT"; } if (Strings.isEmpty(timestamp)) { timestamp = "n/a"; } return new BuildInfo(version, timestamp); }