Merge pull request #4589 from eed3si9n/wip/metabuild_fix

Exclude all sbt modules from metabuild resolution
This commit is contained in:
eugene yokota 2019-03-30 11:52:25 -04:00 committed by GitHub
commit ca5f978df4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -175,6 +175,7 @@ object Defaults extends BuildCommon {
javaOptions :== Nil,
sbtPlugin :== false,
isMetaBuild :== false,
reresolveSbtArtifacts :== false,
crossPaths :== true,
sourcePositionMappers :== Nil,
artifactClassifier in packageSrc :== Some(SourceClassifier),
@ -1897,6 +1898,7 @@ object Classpaths {
unmanagedClasspath := unmanagedDependencies.value,
managedClasspath := {
val isMeta = isMetaBuild.value
val force = reresolveSbtArtifacts.value
val app = appConfiguration.value
val sbtCp0 = app.provider.mainClasspath.toList
val sbtCp = sbtCp0 map { Attributed.blank(_) }
@ -1905,7 +1907,7 @@ object Classpaths {
classpathTypes.value,
update.value
)
if (isMeta) mjars ++ sbtCp
if (isMeta && !force) mjars ++ sbtCp
else mjars
},
exportedProducts := trackedExportedProducts(TrackLevel.TrackAlways).value,
@ -2349,12 +2351,25 @@ object Classpaths {
ScalaArtifacts.toolDependencies(sbtOrg, version, isDotty) ++ pluginAdjust
}
},
// in case of meta build, exclude sbt 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 := {
val sbtdeps = sbtDependency.value
val isMeta = isMetaBuild.value
val force = reresolveSbtArtifacts.value
val excludes = excludeDependencies.value
if (isMeta) excludes.toVector :+ ExclusionRule(sbtdeps.organization, sbtdeps.name)
val sbtModules = Vector(
"sbt",
"zinc_2.12",
"librarymanagement-core_2.12",
"librarymanagement-ivy_2.12",
"util-logging_2.12",
"util-position_2.12",
"io_2.12"
)
val sbtModulesExcludes = sbtModules map { nm: String =>
ExclusionRule(organization = sbtdeps.organization, name = nm)
}
if (isMeta && !force) excludes.toVector ++ sbtModulesExcludes
else excludes
},
dependencyOverrides ++= {

View File

@ -186,6 +186,7 @@ object Keys {
val discoveredSbtPlugins = taskKey[PluginDiscovery.DiscoveredNames]("The names of sbt plugin-related modules (modules that extend Build, Plugin, AutoPlugin) defined by this project.").withRank(CTask)
val sbtPlugin = settingKey[Boolean]("If true, enables adding sbt as a dependency and auto-generation of the plugin descriptor file.").withRank(BMinusSetting)
val isMetaBuild = settingKey[Boolean]("If true, this is a metabuild, a project inside project/ directory, and sbt is added to the classpath.").withRank(DSetting)
val reresolveSbtArtifacts = settingKey[Boolean]("If true, include sbt into the metabuild dependency graph. Otherwise reuse the artifacts resolved by the launcher on startup.").withRank(DSetting)
val pluginCrossBuild = taskKey[Unit]("Dummy task to scope `sbtVersion in pluginCrossBuild`, which gets used for plugin compilation.")
val crossSbtVersions = settingKey[Seq[String]]("The versions of Sbt used when cross-building an sbt plugin.")
val printWarnings = taskKey[Unit]("Shows warnings from compilation, including ones that weren't printed initially.").withRank(BPlusTask)