Skip to content

Commit 8f5c222

Browse files
committed
Introduce tastyFiles task
1 parent 06292cb commit 8f5c222

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

main/src/main/scala/sbt/Defaults.scala

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,13 @@ object Defaults extends BuildCommon {
835835
}) :+ compileAnalysisFile.value.toPath
836836
},
837837
compileOutputs := compileOutputs.triggeredBy(compile).value,
838+
tastyFiles := Def.taskIf {
839+
if (ScalaArtifacts.isScala3(scalaVersion.value)) {
840+
val _ = compile.value
841+
val tastyFiles = classDirectory.value.**("*.tasty").get
842+
tastyFiles.map(_.getAbsoluteFile)
843+
} else Nil
844+
}.value,
838845
clean := (compileOutputs / clean).value,
839846
earlyOutputPing := Def.promise[Boolean],
840847
compileProgress := {
@@ -2029,38 +2036,30 @@ object Defaults extends BuildCommon {
20292036
Seq("-project", project)
20302037
} else compileOptions
20312038
},
2032-
sources := Def.taskDyn {
2033-
val originalSources = sources.value
2034-
val sv = scalaVersion.value
2035-
if (ScalaArtifacts.isScala3(sv) && originalSources.nonEmpty) Def.task {
2036-
val _ = compile.value
2037-
val tastyFiles = classDirectory.value.**("*.tasty").get
2038-
tastyFiles.map(_.getAbsoluteFile)
2039-
} else Def.task(originalSources)
2040-
}.value,
20412039
key in TaskZero := {
20422040
val s = streams.value
20432041
val cs: Compilers = compilers.value
20442042
val srcs = sources.value
20452043
val out = target.value
20462044
val sOpts = scalacOptions.value
20472045
val xapis = apiMappings.value
2048-
val hasScala =
2049-
srcs.exists(_.name.endsWith(".scala")) ||
2050-
srcs.exists(_.name.endsWith(".tasty"))
2046+
val hasScala = srcs.exists(_.name.endsWith(".scala"))
20512047
val hasJava = srcs.exists(_.name.endsWith(".java"))
20522048
val cp = data(dependencyClasspath.value).toList
20532049
val label = nameForSrc(configuration.value.name)
20542050
val fiOpts = fileInputOptions.value
20552051
val reporter = (compile / bspReporter).value
20562052
val converter = fileConverter.value
2053+
val tFiles = tastyFiles.value
2054+
val sv = scalaVersion.value
20572055
(hasScala, hasJava) match {
20582056
case (true, _) =>
20592057
val options = sOpts ++ Opts.doc.externalAPI(xapis)
20602058
val runDoc = Doc.scaladoc(label, s.cacheStoreFactory sub "scala", cs.scalac match {
20612059
case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scaladoc"))
20622060
}, fiOpts)
2063-
runDoc(srcs, cp, out, options, maxErrors.value, s.log)
2061+
val docSrcs = if (ScalaArtifacts.isScala3(sv)) tFiles else srcs
2062+
runDoc(docSrcs, cp, out, options, maxErrors.value, s.log)
20642063
case (_, true) =>
20652064
val javadoc =
20662065
sbt.inc.Doc.cachedJavadoc(label, s.cacheStoreFactory sub "java", cs.javaTools)

main/src/main/scala/sbt/Keys.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ object Keys {
223223
val manipulateBytecode = taskKey[CompileResult]("Manipulates generated bytecode").withRank(BTask)
224224
val compileIncremental = taskKey[CompileResult]("Actually runs the incremental compilation").withRank(DTask)
225225
val previousCompile = taskKey[PreviousResult]("Read the incremental compiler analysis from disk").withRank(DTask)
226+
val tastyFiles = taskKey[Seq[File]]("Returns the TASTy files produced by compilation").withRank(DTask)
226227
private[sbt] val compileScalaBackend = taskKey[CompileResult]("Compiles only Scala sources if pipelining is enabled. Compiles both Scala and Java sources otherwise").withRank(Invisible)
227228
private[sbt] val compileEarly = taskKey[CompileAnalysis]("Compiles only Scala sources if pipelining is enabled, and produce an early output (pickle JAR)").withRank(Invisible)
228229
private[sbt] val earlyOutputPing = taskKey[PromiseWrap[Boolean]]("When pipelining is enabled, this returns true when early output (pickle JAR) is created; false otherwise").withRank(Invisible)

0 commit comments

Comments
 (0)