Skip to content

Commit 3465120

Browse files
committed
Set workspace-dir as current directory
1 parent 8cabe98 commit 3465120

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

modules/build/src/main/scala/scala/build/Build.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ object Build {
560560
value(validate(logger, options))
561561

562562
val project = Project(
563-
workspace = inputs.workspace / ".scala",
563+
directory = inputs.workspace / ".scala",
564+
workspace = inputs.workspace,
564565
classesDir = classesDir0,
565566
scalaCompiler = scalaCompiler,
566567
scalaJsOptions =

modules/build/src/main/scala/scala/build/Project.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import scala.build.options.Scope
1212

1313
final case class Project(
1414
workspace: os.Path,
15+
directory: os.Path,
1516
classesDir: os.Path,
1617
scalaCompiler: ScalaCompiler,
1718
scalaJsOptions: Option[BloopConfig.JsConfig],
@@ -47,8 +48,8 @@ final case class Project(
4748
)
4849
baseBloopProject(
4950
projectName,
50-
workspace.toNIO,
51-
(workspace / ".bloop" / projectName).toNIO,
51+
directory.toNIO,
52+
(directory / ".bloop" / projectName).toNIO,
5253
classesDir.toNIO,
5354
scope
5455
)
@@ -69,7 +70,7 @@ final case class Project(
6970

7071
def writeBloopFile(logger: Logger): Boolean = {
7172
val bloopFileContent = writeAsJsonToArray(bloopFile)(BloopCodecs.codecFile)
72-
val dest = workspace / ".bloop" / s"$projectName.json"
73+
val dest = directory / ".bloop" / s"$projectName.json"
7374
val doWrite = !os.isFile(dest) || {
7475
val currentContent = os.read.bytes(dest)
7576
!Arrays.equals(currentContent, bloopFileContent)

modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,4 +1234,21 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String])
12341234
expect(p.out.text().trim == "hello")
12351235
}
12361236
}
1237+
1238+
test("workspace dir") {
1239+
val inputs = TestInputs(
1240+
Seq(
1241+
os.rel / "Hello.scala" ->
1242+
"""|// using lib com.lihaoyi::os-lib:0.7.8
1243+
|
1244+
|object Hello extends App {
1245+
| println(os.pwd)
1246+
|}""".stripMargin
1247+
)
1248+
)
1249+
inputs.fromRoot { root =>
1250+
val p = os.proc(TestUtil.cli, "Hello.scala").call(cwd = root)
1251+
expect(p.out.text().trim == root.toString)
1252+
}
1253+
}
12371254
}

0 commit comments

Comments
 (0)