简体   繁体   中英

Scala Play messages file to inline or reuse the version in build.sbt

I have a Scala Play project and currently I show the current application version at some location in my main template. The version I can easily define in the conf/messages file. However, since I have an automated build for creating releases, the release iterations will update the build.sbt increasing the version according to the release there eg version := "1.0.6-SNAPSHOT"

I could use the same mechanics during the release to update my conf/messages file as well but instead I would prefer to have my conf/messages file including the version information from build.sbt eg alla application.version=${sbt.application.version} .

How can I accomplish this? is it possible at all?

UPDATE: it is worth mentioning that in Maven these build settings become Java system properties and can be easily used.

You can use sbt-buildinfo plugin to generate a Scala source based on the build.sbt .

The plugin generates a BuildInfo object, which contains information you can then use to display the application version.

Otherwise I don't think you can access sbt information from your configuration.

You can use the xsbt-filter plugin to achieve this. It basically works like Maven's resource filtering mechanism, and exposes the project's name, version, etc. by default. You can further configure it to expose other properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM