Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions modules/build/src/main/scala/scala/build/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ trait Build {
def scope: Scope
def outputOpt: Option[os.Path]
def success: Boolean
def cancelled: Boolean
def diagnostics: Option[Seq[(Either[String, os.Path], bsp4j.Diagnostic)]]

def successfulOpt: Option[Build.Successful]
Expand All @@ -54,6 +55,7 @@ object Build {
logger: Logger
) extends Build {
def success: Boolean = true
def cancelled: Boolean = false
def successfulOpt: Some[this.type] = Some(this)
def outputOpt: Some[os.Path] = Some(output)
def dependencyClassPath: Seq[os.Path] = sources.resourceDirs ++ artifacts.classPath
Expand Down Expand Up @@ -215,9 +217,11 @@ object Build {
project: Project,
diagnostics: Option[Seq[(Either[String, os.Path], bsp4j.Diagnostic)]]
) extends Build {
def success: Boolean = false
def successfulOpt: None.type = None
def outputOpt: None.type = None
def success: Boolean = false

override def cancelled: Boolean = false
def successfulOpt: None.type = None
def outputOpt: None.type = None
}

final case class Cancelled(
Expand All @@ -227,6 +231,7 @@ object Build {
reason: String
) extends Build {
def success: Boolean = false
def cancelled: Boolean = true
def successfulOpt: None.type = None
def outputOpt: None.type = None
def diagnostics: None.type = None
Expand Down
15 changes: 14 additions & 1 deletion modules/build/src/test/scala/scala/build/tests/TestInputs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,27 @@ final case class TestInputs(
buildThreads: BuildThreads, // actually only used when bloopConfigOpt is non-empty
bloopConfigOpt: Option[BloopRifleConfig],
fromDirectory: Boolean = false
)(f: (os.Path, Inputs, Build) => T) =
)(f: (os.Path, Inputs, Build) => T): T =
withBuild(options, buildThreads, bloopConfigOpt, fromDirectory)((p, i, maybeBuild) =>
maybeBuild match {
case Left(e) => throw e
case Right(b) => f(p, i, b)
}
)

def withLoadedBuilds[T](
options: BuildOptions,
buildThreads: BuildThreads, // actually only used when bloopConfigOpt is non-empty
bloopConfigOpt: Option[BloopRifleConfig],
fromDirectory: Boolean = false
)(f: (os.Path, Inputs, Builds) => T) =
withBuilds(options, buildThreads, bloopConfigOpt, fromDirectory)((p, i, builds) =>
builds match {
case Left(e) => throw e
case Right(b) => f(p, i, b)
}
)

def withBuilds[T](
options: BuildOptions,
buildThreads: BuildThreads, // actually only used when bloopConfigOpt is non-empty
Expand Down
Loading
Loading