Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active April 2, 2023 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/40ddcecfdf21ae54304ccd3a8a4417ca to your computer and use it in GitHub Desktop.
Save dacr/40ddcecfdf21ae54304ccd3a8a4417ca to your computer and use it in GitHub Desktop.
Generate build medata data and inject them into the packaging process as properties file / published by https://github.com/dacr/code-examples-manager #bc0aa5a3-4380-4099-abe0-701969cfea6d/b98ef6e658f7fefc03bc21e609a115cb8de022a3
// summary : Generate build medata data and inject them into the packaging process as properties file
// keywords : scala, sbt, metadata, tracing
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : bc0aa5a3-4380-4099-abe0-701969cfea6d
// created-on : 2021-06-15T12:05:02Z
// managed-by : https://github.com/dacr/code-examples-manager
Compile / resourceGenerators += Def.task {
val dir = (Compile / sourceManaged).value
val projectName = name.value
val projectGroup = organization.value
val projectPage=homepage.value.map(_.toString).getOrElse("https://github.com/dacr")
val projectVersion = version.value
val buildDateTime = java.time.Instant.now().toString
val buildUUID = java.util.UUID.randomUUID.toString
val file = dir / "app-meta.conf"
IO.write(file,
s"""application-config {
| meta-info {
| project-name = "$projectName"
| project-code = "cem"
| project-group = "$projectGroup"
| project-page = "$projectPage"
| build-version = "$projectVersion"
| build-date-time = "$buildDateTime"
| build-uuid = "$buildUUID"
| }
|}""".stripMargin
)
Seq(file)
}.taskValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment