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

Why directory in unmanagedClasspath is copied to system temporary directory? #4340

Closed
ngocdaothanh opened this issue Sep 2, 2018 · 2 comments

Comments

@ngocdaothanh
Copy link
Contributor

ngocdaothanh commented Sep 2, 2018

I'm using SBT 1.2.1 on Mac for a multimodule project.

My project directory looks like this:

project/
  module1/
    src/
  module2/
    src/
  app/
    config/
      xitrum.conf
    src/
  build.sbt

In my build.sbt, I'm adding app/config directory to classpath of module app like this:

unmanagedClasspath in Compile += baseDirectory.value / "config"
unmanagedClasspath in Runtime += baseDirectory.value / "config"

When I run the project with sbt run, I see that the config directory is copied to system temporary directory like this:

/var/folders/gc/14jrc47n1k17cz4zfx2f9t6h0000gp/T/sbt_d931459f/target/dbed45b7/config

Question:
Why SBT 1.2.1 doesn't simply use the config file as is? Why does it need to copy (unlike SBT 0.13.x)?


I'm asking because in the multimodule project, path to the directory containing the config directory is calculated like this:

val url = Thread.currentThread.getContextClassLoader.getResource("xitrum.conf")
val fileName = url.getFile
val rootDir = fileName.replace("/config/xitrum.conf", "")

The code works with SBT 0.13.x, but not with SBT 1.2.1.

Note: System.getProperty("user.dir") can be used, but it's not flexible for multimodule SBT project.


Question: If modifying SBT to use the config directory as-is is not an option, in a multimodule SBT project, what should I do to get path to directory containing the config directory dynamically (that is, do not hardcode System.getProperty("user.dir") + "/app")?


Also, it seems that SBT doesn't clean up the temporary directory it created when it exits (#502).

@eed3si9n
Copy link
Member

eed3si9n commented Sep 4, 2018

sbt run now uses bgRun (background run). If you would like the same behavior as 0.13, please use fgRun.

@eed3si9n eed3si9n closed this as completed Sep 4, 2018
@ngocdaothanh
Copy link
Contributor Author

I searched about bgRun and found this: #2936

Is there more official doc about bgRun and fgRun?

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

No branches or pull requests

2 participants