Yi EungJun 2015-02-09
Don't use version.conf
Problem: We should not store Yobi's version information in
conf/version.conf because user may not update the file when upgrade
Yobi. Since Play 2.3, conf directory for product is copied while
packaging so the directory is not updated even if Yobi is upgraded.

Solution: Store the version information in build.sbt. We used
version.conf to know the application version, required for YobiUpdate
feature, while application is running. But it is not necessary because
we can get the version by using sbt-buildinfo.
@ad072569dac7e5ffcf0fff1b0ee52e4ae4b2dbcf
app/utils/Config.java
--- app/utils/Config.java
+++ app/utils/Config.java
@@ -20,15 +20,12 @@
  */
 package utils;
 
-import com.typesafe.config.ConfigFactory;
 import models.SiteAdmin;
 import org.apache.commons.lang3.ObjectUtils;
 import play.Configuration;
 import play.mvc.Http;
 
-import java.io.File;
 import java.net.*;
-import java.nio.file.Paths;
 import java.util.Enumeration;
 
 public class Config {
@@ -263,9 +260,7 @@
      * @return  the current version
      */
     public static String getCurrentVersion() {
-        File versionFile = Paths.get("conf", "version.conf").toFile();
-
-        return ConfigFactory.parseFile(versionFile).resolve().getString("app.version");
+        return yobi.BuildInfo.version();
     }
 
     public static String getEmailFromImap() {
build.sbt
--- build.sbt
+++ build.sbt
@@ -3,12 +3,7 @@
 
 name := """yobi"""
 
-val CONFIG_DIRNAME = "conf"
-val VERSION_CONF = "version.conf"
-val pathToVersionConfig = Paths.get(basePath, CONFIG_DIRNAME, VERSION_CONF)
-val versionConf = ConfigFactory.parseFile(pathToVersionConfig.toFile()).resolve()
-
-version := versionConf.getString("app.version")
+version := "0.8.0-rc2"
 
 libraryDependencies ++= Seq(
   // Add your project dependencies here,
@@ -67,7 +62,13 @@
   scalacOptions ++= Seq("-feature")
 )
 
-scalaVersion := "2.10.4"
+buildInfoSettings
+
+sourceGenerators in Compile <+= buildInfo
+
+buildInfoKeys := Seq[BuildInfoKey](name, version)
+
+buildInfoPackage := "yobi"
 
 lazy val yobi = (project in file("."))
       .enablePlugins(PlayScala)
 
conf/version.conf (deleted)
--- conf/version.conf
@@ -1,1 +0,0 @@
-app.version="0.8.0-rc2"
project/plugins.sbt
--- project/plugins.sbt
+++ project/plugins.sbt
@@ -16,4 +16,6 @@
 
 addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.3.0")
 
+addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.3.2")
+
 libraryDependencies += "org.javassist" % "javassist" % "3.18.2-GA"
Add a comment
List