Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7010721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:01:53+00:00 2026-05-27T22:01:53+00:00

I am building an app with SBT (0.11.0) using a Scala build definition like

  • 0

I am building an app with SBT (0.11.0) using a Scala build definition like so:

object MyAppBuild extends Build {

  import Dependencies._

  lazy val basicSettings = Seq[Setting[_]](
    organization  := "com.my",
    version       := "0.1",
    description   := "Blah",
    scalaVersion  := "2.9.1",
    scalacOptions := Seq("-deprecation", "-encoding", "utf8"),
    resolvers     ++= Dependencies.resolutionRepos
  )

  lazy val myAppProject = Project("my-app-name", file("."))
    .settings(basicSettings: _*)
    [...]

I’m packaging a .jar at the end of the process.

My question is a simple one: is there a way of accessing the application’s name (“my-app-name”) and version (“0.1”) programmatically from my Scala code? I don’t want to repeat them in two places if I can help it.

Any guidance greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:01:54+00:00Added an answer on May 27, 2026 at 10:01 pm

    sbt-buildinfo

    I just wrote sbt-buildinfo.
    After installing the plugin:

    lazy val root = (project in file(".")).
      enablePlugins(BuildInfoPlugin).
      settings(
        buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
        buildInfoPackage := "foo"
      )
    

    Edit: The above snippet has been updated to reflect more recent version of sbt-buildinfo.

    It generates foo.BuildInfo object with any setting you want by customizing buildInfoKeys.

    Ad-hoc approach

    I’ve been meaning to make a plugin for this, (I wrote it) but here’s a quick script to generate a file:

    sourceGenerators in Compile <+= (sourceManaged in Compile, version, name) map { (d, v, n) =>
      val file = d / "info.scala"
      IO.write(file, """package foo
        |object Info {
        |  val version = "%s"
        |  val name = "%s"
        |}
        |""".stripMargin.format(v, n))
      Seq(file)
    }
    

    You can get your version as foo.Info.version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an app in Backbone using Node as the backend. As part of
I'm building an app with iPod-like controls (play, pause, etc). The app has tableView
I am building an app which uses cocos2D. I developed my app using iOS
I'm building app using GAE and wanted to use Django for that. Which patch
I am building an app for iPhone and iPad using PhoneGap and jQM <div
Building an app using android.support.v4.app , targeting API level 8. Everything's working as planned
Building an app using Phonegap and jquery on Android using this code to request
In building an app, we created a generic object model to store some values,
Im building an app using kohana. I need to be able to upload files
When building an app that is using sqlalchemy I get this error: creating python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.