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

Add link to working example of BuildEnvPlugin #1283

Merged
merged 2 commits into from Nov 25, 2019

Conversation

ryanberckmans
Copy link
Contributor

It took me awhile to figure out how to run the scalac optimizer for only a production build. I used the BuildEnvPlugin described here and thought readers might benefit from the docs linking to a working example.

@lightbend-cla-validator

Hi @ryanberckmans,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

http://www.lightbend.com/contribute/cla

@ryanberckmans
Copy link
Contributor Author

I signed the Lightbend Contributors License Agreement.

@nigredo-tori
Copy link
Collaborator

nigredo-tori commented Nov 20, 2019

Maybe we should simplify the code itself, so that everything happens in build.sbt? Like

ThisBuild / buildEnv := ...
ThisBuild / onLoadMessage := ...

lazy val app = project
  .in(file("."))
  .enablePlugins(JavaAppPackaging)
  .settings(
    // common
    name := "my-app",
    libraryDependencies += "com.typesafe" % "config" % "1.3.0",
    // environment-specific
    mappings in Universal += {
      val confFile = buildEnv.value match {
	case BuildEnv.Developement => "dev.conf"
	case BuildEnv.Test => "test.conf"
	case BuildEnv.Stage => "stage.conf"
	case BuildEnv.Production => "prod.conf"
      }
      ((resourceDirectory in Compile).value / confFile) -> "conf/application.conf"
    }
  )

AutoPlugin feels too heavy for a simple example.

@ryanberckmans
Copy link
Contributor Author

That sounds good to me. I wasn't sure how to get it working with only code in build.sbt.

@muuki88
Copy link
Contributor

muuki88 commented Nov 23, 2019

Thanks a lot for sharing your work 😊

I'm totally fine with merging this. There is an existing collection of examples here: https://github.com/muuki88/sbt-native-packager-examples

You could also add it there

@ryanberckmans
Copy link
Contributor Author

@muuki88 good idea! muuki88/sbt-native-packager-examples#16

Can we also merge it here? It's nice to have a reference to a working example at the site of the pertinent docs.

@muuki88 muuki88 merged commit c0e2e76 into sbt:master Nov 25, 2019
@muuki88
Copy link
Contributor

muuki88 commented Nov 25, 2019

Done :)

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

Successfully merging this pull request may close these issues.

None yet

4 participants