SBT: additional source directories not taken by IDEA

So I have a bit of an unusual requirement: I'm developing a Heroku application through Scala, Play and SBT, which takes it's database crendentials from an environment variable in URL form (postgresql://user:password@host/database). That means I have to extract the user and password out and create a jdbc URL for use.

I want to use Flyway, a database migration tool, through SBT, as well as access the DB in my application. That means I need to extract database credentials *during the build*. I could simply copy-and-paste the code from the main project into the build project, but that would be very ugly. Therefore I tried to include a common source folder into both projects.

Surprisingly, it works without much hassle for SBT itself, but IDEA *does not* pick up the extra source roots for neither the main nor the build projects. I have auto-refresh for SBT enabled, and I see the refreshing process run apparently OK, but src-common is not picked up.

I can add them manually to the main project, but I don't know how to add it to the build project, specially since it is not a subfolder of the project/ folder, and I expect it to be done automatically whenever possible. Is this an unsupported configuration, or something to be fixed in the future?

Thanks in advance,
Daniel


More details


My tree looks a bit like this right now:

myProject
- app
- - ApplicationCode.scala
- project
- - build.sbt
- - plugins.sbt
- - Flyway.scala
- src-common
- - some_package
- - - ConnectionInfo.scala
- - build.sbt



>

myProject/project/build.sbt
unmanagedSourceDirectories in Compile <+=
  (baseDirectory / "../build_common")
               


myProject/project/Flyway.scala
/* ... */

import some_package.ConnectionInfo

object FlywayBuild extends Build {
  def flywayCredentials: Seq[sbt.Setting[_]] = {

    /* determine credentials */
  }
}
               


myProject/build.sbt
/* ... */

import FlywayBuild._

/* ... */

unmanagedSourceDirectories in Compile >+=
  (baseDirectory / "src-common")

/* ... */

flywayCredentials

/* ... */
               
1 comment
Comment actions Permalink

I would love to have this missing functionality implemented as well. I'm not sure how to solve it currently, I'll probably try fiddling with (ugly) symlinks...

0

Please sign in to leave a comment.