001package io.ebean; 002 003import org.slf4j.Logger; 004import org.slf4j.LoggerFactory; 005 006import java.io.IOException; 007import java.io.InputStream; 008import java.util.Properties; 009 010/** 011 * Class to determine the ebean version. 012 * 013 * @author Roland Praml, FOCONIS AG 014 */ 015public class EbeanVersion { 016 017 private static final Logger logger = LoggerFactory.getLogger(EbeanVersion.class); 018 019 private static String version = "unknown"; 020 021 static { 022 try { 023 Properties prop = new Properties(); 024 try (InputStream in = DB.class.getResourceAsStream("/META-INF/maven/io.ebean/ebean/pom.properties")) { 025 if (in != null) { 026 prop.load(in); 027 in.close(); 028 version = prop.getProperty("version"); 029 } 030 } 031 logger.info("ebean version: {}", version); 032 } catch (IOException e) { 033 logger.warn("Could not determine ebean version: {}", e.getMessage()); 034 } 035 } 036 037 private EbeanVersion() { 038 // hide 039 } 040 041 /** 042 * Returns the ebean version (read from /META-INF/maven/io.ebean/ebean/pom.properties) 043 */ 044 public static String getVersion() { 045 return version; 046 } 047 048}