File tree Expand file tree Collapse file tree 2 files changed +21
-14
lines changed
src/main/scala/higherkindness/rules_scala/workers/zinc/compile Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -4,23 +4,23 @@ import xsbti.compile.{CompileOptions, MiniSetup}
44import java .nio .file .{Path , Paths }
55
66/**
7- * Zinc's MiniSetup contains scalacOptions which include the -- sourceroot flag that references
7+ * Zinc's MiniSetup contains scalacOptions which include the -sourceroot flag that references
88 * absolute sandbox paths. These paths are non-deterministic across builds because the sandbox
99 * directory changes (e.g., __sandbox/4/_main vs __sandbox/8/_main), making the analysis files
1010 * non-deterministic.
1111 *
12- * This class filters out the -- sourceroot option from the scalacOptions to ensure deterministic
12+ * This class filters out the -sourceroot option from the scalacOptions to ensure deterministic
1313 * analysis files.
1414 *
1515 * TODO: Consider if there's a better way to handle this upstream in Zinc
1616 */
1717object FilteredSetup {
18- private val sourcerootFlag = " -- sourceroot"
18+ private val sourcerootFlag = " -sourceroot"
1919
2020 def getFilteredSetup (setup : MiniSetup ): MiniSetup = {
2121 val options = setup.options()
2222
23- // Filter out the -- sourceroot option and its value
23+ // Filter out the -sourceroot option and its value
2424 val filteredScalacOptions = {
2525 val originalOptions = options.scalacOptions()
2626 val filtered = scala.collection.mutable.ArrayBuffer [String ]()
Original file line number Diff line number Diff line change @@ -212,18 +212,25 @@ object ZincRunner extends WorkerMain[ZincRunnerWorkerConfig] {
212212 isWorker,
213213 )
214214
215+ val shouldIncludeSourceRoot = ! scalaInstance.actualVersion.startsWith(" 0." ) &&
216+ scalaInstance.actualVersion.startsWith(" 3" )
217+
218+ val scalacOptions =
219+ workRequest.plugins.view.map(p => s " -Xplugin: $p" ).toArray ++
220+ workRequest.compilerOptions ++
221+ workRequest.compilerOptionsReferencingPaths.toArray ++
222+ (if (shouldIncludeSourceRoot)
223+ Array (" -sourceroot" , task.workDir.toAbsolutePath().toString)
224+ else
225+ Array .empty[String ])
226+
215227 val compileOptions =
216228 CompileOptions .create
217- .withSources(sources.view.map(source => PlainVirtualFile (source.toAbsolutePath().normalize())).toArray)
218- .withClasspath((classesOutputDir +: deps.view.map(_.classpath)).map(path => PlainVirtualFile (path)).toArray)
219- .withClassesDirectory(classesOutputDir)
220- .withJavacOptions(workRequest.javaCompilerOptions)
221- .withScalacOptions(
222- workRequest.plugins.view.map(p => s " -Xplugin: $p" ).toArray ++
223- workRequest.compilerOptions ++
224- workRequest.compilerOptionsReferencingPaths.toArray ++
225- Array (" --sourceroot" , task.workDir.toAbsolutePath().toString)
226- )
229+ .withSources(sources.view.map(source => PlainVirtualFile (source.toAbsolutePath().normalize())).toArray)
230+ .withClasspath((classesOutputDir +: deps.view.map(_.classpath)).map(path => PlainVirtualFile (path)).toArray)
231+ .withClassesDirectory(classesOutputDir)
232+ .withJavacOptions(workRequest.javaCompilerOptions)
233+ .withScalacOptions(scalacOptions)
227234
228235 val compilers = {
229236 val scalaCompiler = ZincUtil
You can’t perform that action at this time.
0 commit comments