Skip to content

Commit

Permalink
Resolve only once artifacts during build project
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Mar 27, 2023
1 parent be50104 commit 06a6393
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions modules/build/src/main/scala/scala/build/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ object Build {
compilerJvmVersionOpt: Option[Positioned[Int]],
scope: Scope,
logger: Logger,
artifacts: Artifacts,
maybeRecoverOnError: BuildException => Option[BuildException] = e => Some(e)
): Either[BuildException, Project] = either {

Expand All @@ -809,8 +810,6 @@ object Build {
val classesDir0 = classesDir(inputs.workspace, inputs.projectName, scope)
val scaladocDir = classesDir(inputs.workspace, inputs.projectName, scope, suffix = "-doc")

val artifacts = value(options.artifacts(logger, scope, maybeRecoverOnError))

val generateSemanticDbs = options.scalaOptions.generateSemanticDbs.getOrElse(false)

val releaseFlagVersion = releaseFlag(options, compilerJvmVersionOpt, logger).map(_.toString)
Expand Down Expand Up @@ -1007,6 +1006,7 @@ object Build {
compilerJvmVersionOpt,
scope,
logger,
artifacts,
maybeRecoverOnError
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@ class BuildProjectTests extends munit.FunSuite {
)
)

val inputs = Inputs.empty("project")
val sources = Sources(Nil, Nil, None, Nil, options)
val logger = new LoggerMock()
val inputs = Inputs.empty("project")
val sources = Sources(Nil, Nil, None, Nil, options)
val logger = new LoggerMock()
val artifacts = options.artifacts(logger, Scope.Test).orThrow
val res = Build.buildProject(
inputs,
sources,
Nil,
options,
Some(Positioned(bloopJavaPath, bloopJvmVersion)),
Scope.Test,
logger
logger,
artifacts
)

val scalaCompilerOptions = res.fold(throw _, identity)
Expand Down Expand Up @@ -169,12 +171,13 @@ class BuildProjectTests extends munit.FunSuite {
LocalRepo.localRepo(scala.build.Directories.default().localRepoDir)
)
)
val inputs = Inputs.empty("project")
val sources = Sources(Nil, Nil, None, Nil, options)
val logger = new LoggerMock()
val inputs = Inputs.empty("project")
val sources = Sources(Nil, Nil, None, Nil, options)
val logger = new LoggerMock()
val artifacts = options.artifacts(logger, Scope.Test).orThrow

val project =
Build.buildProject(inputs, sources, Nil, options, None, Scope.Main, logger).orThrow
Build.buildProject(inputs, sources, Nil, options, None, Scope.Main, logger, artifacts).orThrow

expect(project.workspace == inputs.workspace)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ object Repl extends ScalaCommand[ReplOptions] {
scope = scope,
sources = Sources(Nil, Nil, None, Nil, options),
artifacts = artifacts,
project = value(Build.buildProject(inputs, sources, Nil, options, None, scope, logger)),
project = value(
Build.buildProject(inputs, sources, Nil, options, None, scope, logger, artifacts)
),
output = classDir.getOrElse(ws),
diagnostics = None,
generatedSources = Nil,
Expand Down

0 comments on commit 06a6393

Please sign in to comment.