Skip to content

Commit

Permalink
Merge pull request #444 from lwronski/bloop-workspace-dir
Browse files Browse the repository at this point in the history
Bloop workspace dir
  • Loading branch information
lwronski authored Dec 2, 2021
2 parents ac683c5 + 3465120 commit 26feee8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion modules/build/src/main/scala/scala/build/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ object Build {
value(validate(logger, options))

val project = Project(
workspace = inputs.workspace / ".scala",
directory = inputs.workspace / ".scala",
workspace = inputs.workspace,
classesDir = classesDir0,
scalaCompiler = scalaCompiler,
scalaJsOptions =
Expand Down
7 changes: 4 additions & 3 deletions modules/build/src/main/scala/scala/build/Project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import scala.build.options.Scope

final case class Project(
workspace: os.Path,
directory: os.Path,
classesDir: os.Path,
scalaCompiler: ScalaCompiler,
scalaJsOptions: Option[BloopConfig.JsConfig],
Expand Down Expand Up @@ -47,8 +48,8 @@ final case class Project(
)
baseBloopProject(
projectName,
workspace.toNIO,
(workspace / ".bloop" / projectName).toNIO,
directory.toNIO,
(directory / ".bloop" / projectName).toNIO,
classesDir.toNIO,
scope
)
Expand All @@ -69,7 +70,7 @@ final case class Project(

def writeBloopFile(logger: Logger): Boolean = {
val bloopFileContent = writeAsJsonToArray(bloopFile)(BloopCodecs.codecFile)
val dest = workspace / ".bloop" / s"$projectName.json"
val dest = directory / ".bloop" / s"$projectName.json"
val doWrite = !os.isFile(dest) || {
val currentContent = os.read.bytes(dest)
!Arrays.equals(currentContent, bloopFileContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,4 +1253,21 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String])
expect(p.out.text().trim == "hello")
}
}

test("workspace dir") {
val inputs = TestInputs(
Seq(
os.rel / "Hello.scala" ->
"""|// using lib com.lihaoyi::os-lib:0.7.8
|
|object Hello extends App {
| println(os.pwd)
|}""".stripMargin
)
)
inputs.fromRoot { root =>
val p = os.proc(TestUtil.cli, "Hello.scala").call(cwd = root)
expect(p.out.text().trim == root.toString)
}
}
}

0 comments on commit 26feee8

Please sign in to comment.