Skip to content

Commit c52d375

Browse files
Allow to disable Bloop file content comparison (#666)
Use --strict-bloop-json-check=false This can potentially save several 100 ms if the Bloop files are already on disk.
1 parent 3f7a047 commit c52d375

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ object Build {
115115
def diagnostics: None.type = None
116116
}
117117

118+
def defaultStrictBloopJsonCheck = true
119+
118120
def updateInputs(
119121
inputs: Inputs,
120122
options: BuildOptions,
@@ -724,7 +726,10 @@ object Build {
724726

725727
val project = value(buildProject(inputs, sources, generatedSources, options, scope, logger))
726728

727-
val updatedBloopConfig = project.writeBloopFile(logger)
729+
val updatedBloopConfig = project.writeBloopFile(
730+
options.internal.strictBloopJsonCheck.getOrElse(defaultStrictBloopJsonCheck),
731+
logger
732+
)
728733

729734
if (updatedBloopConfig && os.isDir(classesDir0)) {
730735
logger.debug(s"Clearing $classesDir0")

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,16 @@ final case class Project(
6868
def bloopFile: BloopConfig.File =
6969
BloopConfig.File(BloopConfig.File.LatestVersion, bloopProject)
7070

71-
def writeBloopFile(logger: Logger): Boolean = {
72-
val bloopFileContent = writeAsJsonToArray(bloopFile)(BloopCodecs.codecFile)
73-
val dest = directory / ".bloop" / s"$projectName.json"
71+
def writeBloopFile(strictCheck: Boolean, logger: Logger): Boolean = {
72+
lazy val bloopFileContent =
73+
writeAsJsonToArray(bloopFile)(BloopCodecs.codecFile)
74+
val dest = directory / ".bloop" / s"$projectName.json"
7475
val doWrite = !os.isFile(dest) || {
75-
val currentContent = os.read.bytes(dest)
76-
!Arrays.equals(currentContent, bloopFileContent)
76+
strictCheck && {
77+
logger.debug(s"Checking Bloop project in $dest")
78+
val currentContent = os.read.bytes(dest)
79+
!Arrays.equals(currentContent, bloopFileContent)
80+
}
7781
}
7882
if (doWrite) {
7983
logger.debug(s"Writing bloop project in $dest")

modules/build/src/main/scala/scala/build/options/InternalOptions.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ final case class InternalOptions(
77
keepDiagnostics: Boolean = false,
88
cache: Option[FileCache[Task]] = None,
99
localRepository: Option[String] = None,
10-
verbosity: Option[Int] = None
10+
verbosity: Option[Int] = None,
11+
strictBloopJsonCheck: Option[Boolean] = None
1112
)
1213

1314
object InternalOptions {

modules/cli/src/main/scala/scala/cli/commands/SharedOptions.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ final case class SharedOptions(
101101
@Hidden
102102
forbid: List[String] = Nil,
103103
@Recurse
104-
helpGroups: HelpGroupOptions = HelpGroupOptions()
104+
helpGroups: HelpGroupOptions = HelpGroupOptions(),
105+
106+
@Hidden
107+
strictBloopJsonCheck: Option[Boolean] = None
105108
) {
106109
// format: on
107110

@@ -171,7 +174,8 @@ final case class SharedOptions(
171174
internal = bo.InternalOptions(
172175
cache = Some(coursierCache),
173176
localRepository = LocalRepo.localRepo(directories.directories.localRepoDir),
174-
verbosity = Some(logging.verbosity)
177+
verbosity = Some(logging.verbosity),
178+
strictBloopJsonCheck = strictBloopJsonCheck
175179
)
176180
)
177181
}

website/docs/reference/cli-options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,8 @@ Generate SemanticDBs
10431043

10441044
#### `--forbid`
10451045

1046+
#### `--strict-bloop-json-check`
1047+
10461048
## Test options
10471049

10481050
Available in commands:

0 commit comments

Comments
 (0)