Skip to content

Commit 4d38c7d

Browse files
committed
Avoid intermittent "cannot create classes.bak" SBT error.
Our subprojects were sharing the `incOptions` value from the root project, which includes the class backup directory derived from the root project's `crossTarget` setting. Instead, we should share the code to modify the `incOptions`. Before: ``` sbt:root> show library/incOptions [info] IncOptions(transitiveStep: 3, recompileAllFraction: 0.5, relationsDebug: false, apiDebug: false, apiDiffContextSize: 5, apiDumpDirectory: Optional.empty, classfileManagerType: Optional[TransactionalManagerType(backupDirectory: /Users/jz/code/scala/target/scala-2.13.0-M5/classes.bak, logger: sbt.util.Logger$$anon$2@c7ba58d)], useCustomizedFileManager: false, recompileOnMacroDef: Optional[false], useOptimizedSealed: false, storeApis: true, enabled: true, extra: {}, logRecompileOnMacro: true, externalHooks: xsbti.compile.DefaultExternalHooks@2d579733, ignoredScalacOptions: [Ljava.lang.String;@282c2bbd) ``` After: ``` sbt:root> show library/incOptions [info] IncOptions(transitiveStep: 3, recompileAllFraction: 0.5, relationsDebug: false, apiDebug: false, apiDiffContextSize: 5, apiDumpDirectory: Optional.empty, classfileManagerType: Optional[TransactionalManagerType(backupDirectory: /Users/jz/code/scala/target/library/classes.bak, logger: sbt.util.Logger$$anon$2@c7ba58d)], useCustomizedFileManager: false, recompileOnMacroDef: Optional[false], useOptimizedSealed: false, storeApis: true, enabled: true, extra: {}, logRecompileOnMacro: true, externalHooks: xsbti.compile.DefaultExternalHooks@5e425ceb, ignoredScalacOptions: [Ljava.lang.String;@26af3265) ```
1 parent be29631 commit 4d38c7d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

build.sbt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ lazy val commonSettings = instanceSettings ++ clearSourceAndResourceDirectories
164164
"-doc-source-url", s"https://github.com/scala/scala/tree/${versionProperties.value.githubTree}€{FILE_PATH}.scala#L1"
165165
),
166166
//maxErrors := 10,
167-
incOptions := (incOptions in LocalProject("root")).value,
167+
setIncOptions,
168168
apiURL := Some(url("http://www.scala-lang.org/api/" + versionProperties.value.mavenVersion + "/")),
169169
pomIncludeRepository := { _ => false },
170170
pomExtra := {
@@ -944,10 +944,7 @@ lazy val root: Project = (project in file("."))
944944
throw new RuntimeException
945945
}
946946
},
947-
incOptions := {
948-
incOptions.value
949-
.withRecompileOnMacroDef(Some(Boolean box false).asJava) // macros in library+reflect are hard-wired to implementations with `FastTrack`.
950-
}
947+
setIncOptions
951948
)
952949
.aggregate(library, reflect, compiler, compilerOptionsExporter, interactive, repl, replFrontend,
953950
scaladoc, scalap, partest, junit, scalaDist).settings(
@@ -956,6 +953,11 @@ lazy val root: Project = (project in file("."))
956953
|Check README.md for more information.""".stripMargin
957954
)
958955

956+
def setIncOptions = incOptions := {
957+
incOptions.value
958+
.withRecompileOnMacroDef(Some(Boolean box false).asJava) // macros in library+reflect are hard-wired to implementations with `FastTrack`.
959+
}
960+
959961
// The following subprojects' binaries are required for building "pack":
960962
lazy val distDependencies = Seq(replFrontend, compiler, library, reflect, scalap, scaladoc)
961963

0 commit comments

Comments
 (0)