Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to specify postgres version using sbt? #41

Open
hedefalk opened this issue Aug 21, 2020 · 2 comments
Open

Any way to specify postgres version using sbt? #41

hedefalk opened this issue Aug 21, 2020 · 2 comments

Comments

@hedefalk
Copy link

I'm using embedded-postgres in a Scala project and building with sbt. I now need features from postgres 12 but can't seem to understand how to use a Maven BOM from sbt. Maybe its not even possible:

sbt/sbt#4531
https://stackoverflow.com/questions/42032303/how-do-i-use-a-maven-bom-bill-of-materials-to-manage-my-dependencies-in-sbt

Is there any other way I can specify the postgres version to use, maybe programmatically?

Thanks for this project!

@tomix26
Copy link
Collaborator

tomix26 commented Sep 11, 2020

Hi, it should be possible to specify it with the dependencyOverrides setting, see the example below. Note that I didn't test it because I don't use sbt. But according to sbt reference manual, it should work. The only thing I'm not sure about is the asterisk instead of the name of the dependency. Maybe you will have to use an explicit name of the dependency.

dependencyOverrides += "io.zonky.test.postgres" % "*" % "12.4.0"

@mblund
Copy link

mblund commented Sep 22, 2020

We couldn't get the dependencyOverrides to work but instead we pointed out the exact jar file for the binary.

  val embeddedPostgres = ("io.zonky.test" % "embedded-postgres" % "1.2.8")
    .exclude("io.zonky.test", "postgres")

  val postgresV = "12.1.0"
  val osVersion        =
    System.getProperty("os.name").toLowerCase match {
      case osName if osName.contains("mac")   =>
        "embedded-postgres-binaries-darwin-amd64"
      case osName if osName.contains("win")   =>
        "embedded-postgres-binaries-windows-amd64"
      case osName if osName.contains("linux") =>
        "embedded-postgres-binaries-linux-amd64"
      case osName                             => throw new RuntimeException(s"Unknown operating system $osName")
    }
  val postgresBinaries = "io.zonky.test.postgres" % osVersion % postgresV

and then we used this these values in our project definition to get the right depenencies.

lazy val persistence = (project in file("libs/persistence"))
  .configs(IntegrationTest)
  .settings(
    name := "persistence",
    common,
    Defaults.itSettings,
    libraryDependencies ++= Seq(
          embeddedPostgres % "it",
          postgresBinaries % "it",
          flyway           % "it"
        ),

This got our integration test to run fine with postgres 12.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants