[Notice] Announcing the End of Demo Server [Read me]

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
... | ... | @@ -20,15 +20,12 @@ |
20 | 20 |
*/ |
21 | 21 |
package utils; |
22 | 22 |
|
23 |
-import com.typesafe.config.ConfigFactory; |
|
24 | 23 |
import models.SiteAdmin; |
25 | 24 |
import org.apache.commons.lang3.ObjectUtils; |
26 | 25 |
import play.Configuration; |
27 | 26 |
import play.mvc.Http; |
28 | 27 |
|
29 |
-import java.io.File; |
|
30 | 28 |
import java.net.*; |
31 |
-import java.nio.file.Paths; |
|
32 | 29 |
import java.util.Enumeration; |
33 | 30 |
|
34 | 31 |
public class Config { |
... | ... | @@ -263,9 +260,7 @@ |
263 | 260 |
* @return the current version |
264 | 261 |
*/ |
265 | 262 |
public static String getCurrentVersion() { |
266 |
- File versionFile = Paths.get("conf", "version.conf").toFile(); |
|
267 |
- |
|
268 |
- return ConfigFactory.parseFile(versionFile).resolve().getString("app.version"); |
|
263 |
+ return yobi.BuildInfo.version(); |
|
269 | 264 |
} |
270 | 265 |
|
271 | 266 |
public static String getEmailFromImap() { |
--- build.sbt
+++ build.sbt
... | ... | @@ -3,12 +3,7 @@ |
3 | 3 |
|
4 | 4 |
name := """yobi""" |
5 | 5 |
|
6 |
-val CONFIG_DIRNAME = "conf" |
|
7 |
-val VERSION_CONF = "version.conf" |
|
8 |
-val pathToVersionConfig = Paths.get(basePath, CONFIG_DIRNAME, VERSION_CONF) |
|
9 |
-val versionConf = ConfigFactory.parseFile(pathToVersionConfig.toFile()).resolve() |
|
10 |
- |
|
11 |
-version := versionConf.getString("app.version") |
|
6 |
+version := "0.8.0-rc2" |
|
12 | 7 |
|
13 | 8 |
libraryDependencies ++= Seq( |
14 | 9 |
// Add your project dependencies here, |
... | ... | @@ -67,7 +62,13 @@ |
67 | 62 |
scalacOptions ++= Seq("-feature") |
68 | 63 |
) |
69 | 64 |
|
70 |
-scalaVersion := "2.10.4" |
|
65 |
+buildInfoSettings |
|
66 |
+ |
|
67 |
+sourceGenerators in Compile <+= buildInfo |
|
68 |
+ |
|
69 |
+buildInfoKeys := Seq[BuildInfoKey](name, version) |
|
70 |
+ |
|
71 |
+buildInfoPackage := "yobi" |
|
71 | 72 |
|
72 | 73 |
lazy val yobi = (project in file(".")) |
73 | 74 |
.enablePlugins(PlayScala) |
--- conf/version.conf
... | ... | @@ -1,1 +0,0 @@ |
1 | -app.version="0.8.0-rc2" |
--- project/plugins.sbt
+++ project/plugins.sbt
... | ... | @@ -16,4 +16,6 @@ |
16 | 16 |
|
17 | 17 |
addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.3.0") |
18 | 18 |
|
19 |
+addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.3.2") |
|
20 |
+ |
|
19 | 21 |
libraryDependencies += "org.javassist" % "javassist" % "3.18.2-GA" |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?