diff --git a/modules/build/src/main/scala/scala/build/Build.scala b/modules/build/src/main/scala/scala/build/Build.scala index ae9811c7a5..64fafc1f0c 100644 --- a/modules/build/src/main/scala/scala/build/Build.scala +++ b/modules/build/src/main/scala/scala/build/Build.scala @@ -1004,6 +1004,10 @@ object Build { else Nil } + val moduleDeps = inputs.moduleDependencies ++ { + if (scope == Scope.Test) Seq(inputs.scopeProjectName(Scope.Main)) else Nil + } + value(validate(logger, options)) val fullClassPath = artifacts.compileClassPath ++ @@ -1036,7 +1040,7 @@ object Build { scope = scope, javaHomeOpt = Option(options.javaHomeLocation().value), javacOptions = javacOptions, - moduleDependencies = inputs.moduleDependencies + moduleDependencies = moduleDeps ) project } diff --git a/modules/build/src/main/scala/scala/build/bsp/BspImpl.scala b/modules/build/src/main/scala/scala/build/bsp/BspImpl.scala index 915e540463..1e2e98eb8c 100644 --- a/modules/build/src/main/scala/scala/build/bsp/BspImpl.scala +++ b/modules/build/src/main/scala/scala/build/bsp/BspImpl.scala @@ -333,7 +333,22 @@ final class BspImpl( executor ) - preBuild.thenCompose { + preBuild.thenCompose { x => + Thread.sleep(1000) + x.foreach{ r => + r.prebuildModules.foreach{ m => + pprint.err.log(m.mainScope.project.projectName) + m.mainScope.sources.paths.foreach(path => pprint.err.log(os.read(path._1))) + m.mainScope.project.classPath.foreach(p => pprint.err.log(p.toString)) + } + r.prebuildModules.foreach { m => + pprint.err.log(m.testScope.project.projectName) + m.testScope.sources.paths.foreach(path => pprint.err.log(os.read(path._1))) + m.testScope.project.classPath.foreach(p => pprint.err.log(p.toString)) + } + } + CompletableFuture.supplyAsync(() => x, executor) + }.thenCompose { case Left((ex, projectName)) => val taskId = new b.TaskId(UUID.randomUUID().toString) diff --git a/modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala b/modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala index baa04df5d3..af75903945 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala @@ -1,6 +1,6 @@ package scala.cli.integration -import ch.epfl.scala.bsp4j.{BuildTargetEvent, JvmTestEnvironmentParams, SourcesParams} +import ch.epfl.scala.bsp4j.{BuildTargetEvent, JvmTestEnvironmentParams} import ch.epfl.scala.bsp4j as b import com.eed3si9n.expecty.Expecty.expect import com.google.gson.{Gson, JsonElement} @@ -8,6 +8,7 @@ import com.google.gson.{Gson, JsonElement} import java.net.URI import java.nio.file.Paths import java.util.concurrent.{ExecutorService, ScheduledExecutorService} + import scala.annotation.tailrec import scala.async.Async.{async, await} import scala.cli.integration.compose.ComposeBspTestDefinitions @@ -778,7 +779,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg } } - test("tes scope uses artifacts from main scope") { + test("test workspace update after adding file to main scope") { val inputs = TestInputs( os.rel / "Messages.scala" -> """//> using dep "com.lihaoyi::os-lib:0.7.8"