mirror of https://github.com/sbt/sbt.git
Use scala-doc-tool config for scala3doc
This commit is contained in:
parent
6f07bec443
commit
5f4197cf2e
|
|
@ -1027,9 +1027,9 @@ object Defaults extends BuildCommon {
|
||||||
val cache = state.value.extendedClassLoaderCache
|
val cache = state.value.extendedClassLoaderCache
|
||||||
mkScalaInstance(
|
mkScalaInstance(
|
||||||
version,
|
version,
|
||||||
allJars,
|
|
||||||
libraryJars,
|
libraryJars,
|
||||||
compilerJar,
|
allJars,
|
||||||
|
Seq.empty,
|
||||||
cache,
|
cache,
|
||||||
scalaInstanceTopLoader.value
|
scalaInstanceTopLoader.value
|
||||||
)
|
)
|
||||||
|
|
@ -1059,31 +1059,43 @@ object Defaults extends BuildCommon {
|
||||||
|
|
||||||
def scalaInstanceFromUpdate: Initialize[Task[ScalaInstance]] = Def.task {
|
def scalaInstanceFromUpdate: Initialize[Task[ScalaInstance]] = Def.task {
|
||||||
val sv = scalaVersion.value
|
val sv = scalaVersion.value
|
||||||
val toolReport = update.value.configuration(Configurations.ScalaTool) getOrElse
|
val fullReport = update.value
|
||||||
sys.error(noToolConfiguration(managedScalaInstance.value))
|
|
||||||
def files(id: String) =
|
val toolReport = fullReport
|
||||||
for {
|
.configuration(Configurations.ScalaTool)
|
||||||
|
.getOrElse(sys.error(noToolConfiguration(managedScalaInstance.value)))
|
||||||
|
|
||||||
|
def file(id: String): File = {
|
||||||
|
val files = for {
|
||||||
m <- toolReport.modules if m.module.name.startsWith(id)
|
m <- toolReport.modules if m.module.name.startsWith(id)
|
||||||
(art, file) <- m.artifacts if art.`type` == Artifact.DefaultType
|
(art, file) <- m.artifacts if art.`type` == Artifact.DefaultType
|
||||||
} yield file
|
} yield file
|
||||||
def file(id: String) = files(id).headOption getOrElse sys.error(s"Missing $id jar file")
|
files.headOption getOrElse sys.error(s"Missing $id jar file")
|
||||||
val allJars = toolReport.modules.flatMap(_.artifacts.map(_._2))
|
}
|
||||||
|
|
||||||
|
val allCompilerJars = toolReport.modules.flatMap(_.artifacts.map(_._2))
|
||||||
|
val allDocJars =
|
||||||
|
fullReport
|
||||||
|
.configuration(Configurations.ScalaDocTool)
|
||||||
|
.toSeq
|
||||||
|
.flatMap(_.modules)
|
||||||
|
.flatMap(_.artifacts.map(_._2))
|
||||||
val libraryJars = ScalaArtifacts.libraryIds(sv).map(file)
|
val libraryJars = ScalaArtifacts.libraryIds(sv).map(file)
|
||||||
val compilerJar = file(ScalaArtifacts.compilerId(sv))
|
|
||||||
mkScalaInstance(
|
mkScalaInstance(
|
||||||
sv,
|
sv,
|
||||||
allJars,
|
|
||||||
libraryJars,
|
libraryJars,
|
||||||
compilerJar,
|
allCompilerJars,
|
||||||
|
allDocJars,
|
||||||
state.value.extendedClassLoaderCache,
|
state.value.extendedClassLoaderCache,
|
||||||
scalaInstanceTopLoader.value,
|
scalaInstanceTopLoader.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
private[this] def mkScalaInstance(
|
private[this] def mkScalaInstance(
|
||||||
version: String,
|
version: String,
|
||||||
allJars: Seq[File],
|
|
||||||
libraryJars: Array[File],
|
libraryJars: Array[File],
|
||||||
compilerJar: File,
|
allCompilerJars: Seq[File],
|
||||||
|
allDocJars: Seq[File],
|
||||||
classLoaderCache: ClassLoaderCache,
|
classLoaderCache: ClassLoaderCache,
|
||||||
topLoader: ClassLoader,
|
topLoader: ClassLoader,
|
||||||
): ScalaInstance = {
|
): ScalaInstance = {
|
||||||
|
|
@ -1096,17 +1108,33 @@ object Defaults extends BuildCommon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else topLoader
|
else topLoader
|
||||||
val allJarsDistinct = allJars.distinct
|
|
||||||
|
val compilerJars = allCompilerJars.filterNot(libraryJars.contains).distinct.toArray
|
||||||
|
val docJars = allDocJars
|
||||||
|
.filterNot(jar => libraryJars.contains(jar) || compilerJars.contains(jar))
|
||||||
|
.distinct
|
||||||
|
.toArray
|
||||||
|
val allJars = libraryJars ++ compilerJars ++ docJars
|
||||||
|
|
||||||
val libraryLoader = classLoaderCache(libraryJars.toList, jansiExclusionLoader)
|
val libraryLoader = classLoaderCache(libraryJars.toList, jansiExclusionLoader)
|
||||||
val fullLoader = classLoaderCache(allJarsDistinct.toList, libraryLoader)
|
val compilerLoader = classLoaderCache(
|
||||||
|
// It should be `compilerJars` but it would break on `3.0.0-M2` because of
|
||||||
|
// https://github.com/lampepfl/dotty/blob/d932af954ef187d7bdb87500d49ed0ff530bd1e7/sbt-bridge/src/xsbt/CompilerClassLoader.java#L108-L117
|
||||||
|
allCompilerJars.toList,
|
||||||
|
libraryLoader
|
||||||
|
)
|
||||||
|
val fullLoader =
|
||||||
|
if (docJars.isEmpty) compilerLoader
|
||||||
|
else classLoaderCache(docJars.distinct.toList, compilerLoader)
|
||||||
new ScalaInstance(
|
new ScalaInstance(
|
||||||
version,
|
version = version,
|
||||||
fullLoader,
|
loader = fullLoader,
|
||||||
libraryLoader,
|
loaderCompilerOnly = compilerLoader,
|
||||||
libraryJars,
|
loaderLibraryOnly = libraryLoader,
|
||||||
compilerJar,
|
libraryJars = libraryJars,
|
||||||
allJarsDistinct.toArray,
|
compilerJars = compilerJars,
|
||||||
Some(version)
|
allJars = allJars,
|
||||||
|
explicitActual = Some(version)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
def scalaInstanceFromHome(dir: File): Initialize[Task[ScalaInstance]] = Def.task {
|
def scalaInstanceFromHome(dir: File): Initialize[Task[ScalaInstance]] = Def.task {
|
||||||
|
|
@ -1117,9 +1145,9 @@ object Defaults extends BuildCommon {
|
||||||
}
|
}
|
||||||
mkScalaInstance(
|
mkScalaInstance(
|
||||||
dummy.version,
|
dummy.version,
|
||||||
dummy.allJars,
|
|
||||||
dummy.libraryJars,
|
dummy.libraryJars,
|
||||||
dummy.compilerJar,
|
dummy.compilerJars,
|
||||||
|
dummy.allJars,
|
||||||
state.value.extendedClassLoaderCache,
|
state.value.extendedClassLoaderCache,
|
||||||
scalaInstanceTopLoader.value,
|
scalaInstanceTopLoader.value,
|
||||||
)
|
)
|
||||||
|
|
@ -2913,7 +2941,8 @@ object Classpaths {
|
||||||
},
|
},
|
||||||
ivyConfigurations ++= Configurations.auxiliary,
|
ivyConfigurations ++= Configurations.auxiliary,
|
||||||
ivyConfigurations ++= {
|
ivyConfigurations ++= {
|
||||||
if (managedScalaInstance.value && scalaHome.value.isEmpty) Configurations.ScalaTool :: Nil
|
if (managedScalaInstance.value && scalaHome.value.isEmpty)
|
||||||
|
Configurations.ScalaTool :: Configurations.ScalaDocTool :: Nil
|
||||||
else Nil
|
else Nil
|
||||||
},
|
},
|
||||||
// Coursier needs these
|
// Coursier needs these
|
||||||
|
|
@ -3103,10 +3132,15 @@ object Classpaths {
|
||||||
else base
|
else base
|
||||||
val sbtOrg = scalaOrganization.value
|
val sbtOrg = scalaOrganization.value
|
||||||
val version = scalaVersion.value
|
val version = scalaVersion.value
|
||||||
|
val extResolvers = externalResolvers.value
|
||||||
|
val allToolDeps =
|
||||||
if (scalaHome.value.isDefined || scalaModuleInfo.value.isEmpty || !managedScalaInstance.value)
|
if (scalaHome.value.isDefined || scalaModuleInfo.value.isEmpty || !managedScalaInstance.value)
|
||||||
pluginAdjust
|
Nil
|
||||||
else
|
else if (extResolvers.contains(Resolver.JCenterRepository)) {
|
||||||
ScalaArtifacts.toolDependencies(sbtOrg, version) ++ pluginAdjust
|
ScalaArtifacts.toolDependencies(sbtOrg, version) ++
|
||||||
|
ScalaArtifacts.docToolDependencies(sbtOrg, version)
|
||||||
|
} else ScalaArtifacts.toolDependencies(sbtOrg, version)
|
||||||
|
allToolDeps ++ pluginAdjust
|
||||||
},
|
},
|
||||||
// in case of meta build, exclude all sbt modules from the dependency graph, so we can use the sbt resolved by the launcher
|
// in case of meta build, exclude all sbt modules from the dependency graph, so we can use the sbt resolved by the launcher
|
||||||
allExcludeDependencies := {
|
allExcludeDependencies := {
|
||||||
|
|
|
||||||
|
|
@ -128,13 +128,15 @@ private[sbt] object ZincComponentCompiler {
|
||||||
val properties = ResourceLoader.getSafePropertiesFor("compiler.properties", loader)
|
val properties = ResourceLoader.getSafePropertiesFor("compiler.properties", loader)
|
||||||
val loaderVersion = Option(properties.getProperty("version.number"))
|
val loaderVersion = Option(properties.getProperty("version.number"))
|
||||||
val scalaV = loaderVersion.getOrElse("unknown")
|
val scalaV = loaderVersion.getOrElse("unknown")
|
||||||
|
val allJars = jarsToLoad.map(_.toFile).toArray
|
||||||
new ScalaInstance(
|
new ScalaInstance(
|
||||||
scalaV,
|
scalaV,
|
||||||
loader,
|
loader,
|
||||||
|
loader,
|
||||||
loaderLibraryOnly,
|
loaderLibraryOnly,
|
||||||
scalaLibraryJars.map(_.toFile).toArray,
|
scalaLibraryJars.map(_.toFile).toArray,
|
||||||
scalaCompilerJar.toFile,
|
allJars,
|
||||||
jarsToLoad.map(_.toFile).toArray,
|
allJars,
|
||||||
loaderVersion,
|
loaderVersion,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue