Alex Wilson
Alex Wilson

Reputation: 6740

Sharing source/libraries between sbt and Scala play framework

I have two related apps I am developing in Scala. One is a server-side processing engine built using SBT and running headlessly doing some number crunching (on a cron job). The other is a web site written in Scala and running on the play framework.

I have code that I would like to be able to share between the two, but as each of them (SBT and Play) has their own ideas about directory structure and how to build things it's pretty unclear to me how I should do this. I'd hate to copy and paste the .scala files - but I'm also not keen on using sym links and having them both build from the same files.

If it were possible, I would accept getting the Play scripts to run SBT to build libraries as required. If it were the only way then I would also be OK with using SBT to build jars for Play and then copying them into place. But I'm often developing both simultaneously (they are parts of a bigger app) and it would all work much more smoothly if they updated together. Is this even possible, or if there's another simpler technique I'm missing?

Thanks, Alex

Upvotes: 4

Views: 683

Answers (1)

Pere Villega
Pere Villega

Reputation: 16439

The only easy way is to build JARs with SBT and make Play use them.

On how to copy, you have 2 options:

  • You manually build and copy them over to the libs folder in Play (you can script that to make it less annoying)
  • You use a custom repository for your JARs (ala Nexus repository) and use Play dependencies.yml to point to that repo and update. With this you would also need to run play sync --deps often and to tweak the versions, so I'm not sure if it makes too much sense during dev (it makes more sense once the JARs are complete though)

Upvotes: 7

Related Questions