1

I'm trying to add an sbt plugin to a play application.

The plugin requires some configuration since it needs to connect to a database. These are the settings that the plugin requires in the build.sbt file:

 jooqOptions := Seq("jdbc.driver" -> "com.mysql.jdbc.Driver",
                    "jdbc.url" -> "jdbc:mysql://localhost:3306/fnord",
                    "jdbc.user" -> "fnord",
                    "jdbc.password" -> "fnord",
                    "generator.database.name" -> "org.jooq.util.mysql.MySQLDatabase",
                    "generator.database.inputSchema" -> "fnord",
                    "generator.target.packageName" -> "com.myproject.jooq")

Since the user and password will depent on the specific machine on which i deploy the app, i would like to load them from somewhere where each user can assign the user and password himself.

How do i do that?

user3346601
  • 1,019
  • 1
  • 11
  • 18

2 Answers2

2

I've solved it using the accepted solution from:

How get application version in play framework and build.sbt

I've added this to my build.sbt:

import com.typesafe.config._

val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve()

version := conf.getString("app.version")

and in my application.conf:

app.version="0.2-SNAPSHOT"
Community
  • 1
  • 1
user3346601
  • 1,019
  • 1
  • 11
  • 18
1

One way would be to read them from an environment variable, another to have a config file of some kind in a predefined path that you load and read in your sbt project.

Since the sbt config is scala code you can for example use sys.env to read environment variables. You can find the scaladoc for sys.env here

johanandren
  • 11,249
  • 1
  • 25
  • 30