From c89009809eacf3a00a07d9e08a099215d7bdc6c5 Mon Sep 17 00:00:00 2001 From: Friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:53:32 -0700 Subject: [PATCH] Backport dummy jar handling for Consistent Analysis Format --- .../main/scala/sbt/internal/inc/Analysis.scala | 1 + .../consistent/ConsistentAnalysisFormat.scala | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Analysis.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Analysis.scala index d1fa60c66..5f2813071 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Analysis.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Analysis.scala @@ -133,6 +133,7 @@ object Analysis { } lazy val dummyOutputPath: Path = Paths.get("/tmp/dummy") + lazy val dummyOutputJarPath: Path = Paths.get("/tmp/dummy/output.jar") } private class MAnalysis( diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala index 73d5fd203..683b5ae9c 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala @@ -28,7 +28,7 @@ import Compat._ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { import ConsistentAnalysisFormat._ - private[this] final val VERSION = 1100028 + private[this] final val VERSION = 1100029 private[this] final val readMapper = mappers.getReadMapper private[this] final val writeMapper = mappers.getWriteMapper @@ -40,6 +40,7 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { writeStamps(out, analysis0.stamps) writeAPIs(out, analysis0.apis, setup.storeApis()) writeSourceInfos(out, analysis0.infos) + // we do not read or write the Compilations out.int(VERSION) out.end() } @@ -51,9 +52,11 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { val stamps = readStamps(in) val apis = readAPIs(in, setup.storeApis()) val infos = readSourceInfos(in) + // we do not read or write the Compilations + val compilations = Compilations.of(Nil) readVersion(in) in.end() - (Analysis.Empty.copy(stamps, apis, relations, infos, Compilations.of(Nil)), setup) + (Analysis.Empty.copy(stamps, apis, relations, infos, compilations), setup) } @inline @@ -294,6 +297,13 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { out.byte(setup.order.ordinal().toByte) out.bool(setup.storeApis()) out.writeArray("extra", setup.extra, 2) { t => out.string(t.get1); out.string(t.get2) } + val singleOutput = setup.output().getSingleOutputAsPath() + val outputPath = singleOutput match { + case o if o.isPresent() && o.get().getFileName().toString().endsWith(".jar") => + Analysis.dummyOutputJarPath + case _ => Analysis.dummyOutputPath + } + out.string(outputPath.toString()) } } @@ -308,8 +318,9 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { val compileOrder = CompileOrder.values()(in.byte().toInt) val skipApiStoring = in.bool() val extra = in.readArray(2) { InterfaceUtil.t2(in.string() -> in.string()) } + val outputPath = in.string() readMapper.mapMiniSetup(MiniSetup.of( - CompileOutput(Analysis.dummyOutputPath), + CompileOutput(Paths.get(outputPath)), MiniOptions.of(classpathHash, scalacOptions, javacOptions), compilerVersion, compileOrder,