Merge pull request #4258 from eed3si9n/wip/scripted

scripted-sbt-redux
This commit is contained in:
eugene yokota 2018-07-10 10:03:26 -04:00 committed by GitHub
commit 18602c521d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 48 additions and 22 deletions

View File

@ -94,6 +94,10 @@ val mimaSettings = Def settings (
),
)
val scriptedSbtReduxMimaSettings = Def settings (
mimaPreviousArtifacts := Set()
)
lazy val sbtRoot: Project = (project in file("."))
.enablePlugins(ScriptedPlugin) // , SiteScaladocPlugin, GhpagesPlugin)
.configs(Sxr.SxrConf)
@ -307,34 +311,43 @@ lazy val runProj = (project in file("run"))
val sbtProjDepsCompileScopeFilter =
ScopeFilter(inDependencies(LocalProject("sbtProj"), includeRoot = false), inConfigurations(Compile))
lazy val scriptedSbtProj = (project in scriptedPath / "sbt")
lazy val scriptedSbtReduxProj = (project in file("scripted-sbt-redux"))
.dependsOn(commandProj)
.settings(
baseSettings,
name := "Scripted sbt",
name := "Scripted sbt Redux",
libraryDependencies ++= Seq(launcherInterface % "provided"),
resourceGenerators in Compile += Def task {
val mainClassDir = (classDirectory in Compile in LocalProject("sbtProj")).value
val testClassDir = (classDirectory in Test in LocalProject("sbtProj")).value
val classDirs = (classDirectory all sbtProjDepsCompileScopeFilter).value
val extDepsCp = (externalDependencyClasspath in Compile in LocalProject("sbtProj")).value
val cpStrings = (mainClassDir +: testClassDir +: classDirs) ++ extDepsCp.files map (_.toString)
val file = (resourceManaged in Compile).value / "RunFromSource.classpath"
IO.writeLines(file, cpStrings)
List(file)
},
mimaSettings,
mimaBinaryIssueFilters ++= Seq(
// sbt.test package is renamed to sbt.scriptedtest.
exclude[MissingClassProblem]("sbt.test.*"),
),
scriptedSbtReduxMimaSettings,
)
.configure(addSbtIO, addSbtUtilLogging, addSbtCompilerInterface, addSbtUtilScripted, addSbtLmCore)
lazy val scriptedPluginProj = (project in scriptedPath / "plugin")
.dependsOn(mainProj)
lazy val scriptedSbtOldProj = (project in file("scripted-sbt-old"))
.dependsOn(scriptedSbtReduxProj)
.settings(
baseSettings,
name := "Scripted sbt",
mimaSettings,
mimaBinaryIssueFilters ++= Seq(
// sbt.test package is renamed to sbt.scriptedtest.
exclude[MissingClassProblem]("sbt.test.*"),
exclude[DirectMissingMethodProblem]("sbt.test.*"),
exclude[IncompatibleMethTypeProblem]("sbt.test.*"),
),
)
lazy val scriptedPluginProj = (project in file("scripted-plugin"))
.settings(
baseSettings,
name := "Scripted Plugin",
@ -344,7 +357,6 @@ lazy val scriptedPluginProj = (project in scriptedPath / "plugin")
exclude[MissingClassProblem]("sbt.ScriptedPlugin*")
),
)
.configure(addSbtCompilerClasspath)
// Implementation and support code for defining actions.
lazy val actionsProj = (project in file("main-actions"))
@ -524,7 +536,8 @@ lazy val mainSettingsProj = (project in file("main-settings"))
// The main integration project for sbt. It brings all of the projects together, configures them, and provides for overriding conventions.
lazy val mainProj = (project in file("main"))
.enablePlugins(ContrabandPlugin)
.dependsOn(logicProj, actionsProj, mainSettingsProj, runProj, commandProj, collectionProj, scriptedSbtProj)
.dependsOn(logicProj, actionsProj, mainSettingsProj, runProj, commandProj, collectionProj,
scriptedSbtReduxProj, scriptedPluginProj)
.settings(
testedBaseSettings,
name := "Main",
@ -557,7 +570,7 @@ lazy val mainProj = (project in file("main"))
// technically, we need a dependency on all of mainProj's dependencies, but we don't do that since this is strictly an integration project
// with the sole purpose of providing certain identifiers without qualification (with a package object)
lazy val sbtProj = (project in file("sbt"))
.dependsOn(mainProj, scriptedSbtProj % "test->test")
.dependsOn(mainProj, scriptedSbtReduxProj % "test->test")
.settings(
testedBaseSettings,
name := "sbt",
@ -654,8 +667,8 @@ def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
(sbtProj / Test / compile).value // make sure sbt.RunFromSourceMain is compiled
Scripted.doScripted(
(sbtLaunchJar in bundledLauncherProj).value,
(fullClasspath in scriptedSbtProj in Test).value,
(scalaInstance in scriptedSbtProj).value,
(fullClasspath in scriptedSbtReduxProj in Test).value,
(scalaInstance in scriptedSbtReduxProj).value,
scriptedSource.value,
scriptedBufferLog.value,
Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed,
@ -667,8 +680,8 @@ def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
def scriptedUnpublishedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
Scripted.doScripted(
(sbtLaunchJar in bundledLauncherProj).value,
(fullClasspath in scriptedSbtProj in Test).value,
(scalaInstance in scriptedSbtProj).value,
(fullClasspath in scriptedSbtReduxProj in Test).value,
(scalaInstance in scriptedSbtReduxProj).value,
scriptedSource.value,
scriptedBufferLog.value,
Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed,
@ -689,7 +702,8 @@ def allProjects =
taskProj,
stdTaskProj,
runProj,
scriptedSbtProj,
scriptedSbtReduxProj,
scriptedSbtOldProj,
scriptedPluginProj,
protocolProj,
actionsProj,
@ -727,7 +741,7 @@ def otherRootSettings =
))
lazy val docProjects: ScopeFilter = ScopeFilter(
inAnyProject -- inProjects(sbtRoot, sbtProj, scriptedSbtProj, scriptedPluginProj),
inAnyProject -- inProjects(sbtRoot, sbtProj, scriptedSbtReduxProj, scriptedSbtOldProj, scriptedPluginProj),
inConfigurations(Compile)
)
lazy val safeUnitTests = taskKey[Unit]("Known working tests (for both 2.10 and 2.11)")

View File

@ -2190,6 +2190,16 @@ object Classpaths {
val isDotty = ScalaInstance.isDotty(version)
ScalaArtifacts.toolDependencies(sbtOrg, version, isDotty) ++ pluginAdjust
}
},
dependencyOverrides ++= {
val old = dependencyOverrides.value
val isPlugin = sbtPlugin.value
val app = appConfiguration.value
val id = app.provider.id
val sv = (sbtVersion in pluginCrossBuild).value
val base = ModuleID(id.groupID, "scripted-plugin", sv).withCrossVersion(CrossVersion.binary)
if (isPlugin) Seq(base)
else Seq()
}
)

View File

@ -7,9 +7,7 @@ import sbt.internal.inc.classpath.{ ClasspathUtilities, FilteredLoader }
object ScriptedPlugin extends AutoPlugin {
override def requires = plugins.JvmPlugin
object autoImport extends ScriptedKeys {
def scriptedPath = file("scripted")
}
object autoImport extends ScriptedKeys
import autoImport._

View File

@ -0,0 +1 @@
enablePlugins(ScriptedPlugin)

View File

@ -0,0 +1 @@
addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.11.0-M4")

View File

@ -0,0 +1 @@
> about

View File

@ -218,6 +218,7 @@ final class ScriptedTests(
case "project/extra" => LauncherBased // tbd
case "project/flatten" => LauncherBased // sbt/Package$
case "project/generated-root-no-publish" => LauncherBased // tbd
case "project/giter8-plugin" => LauncherBased // tbd
case "project/lib" => LauncherBased // sbt/Package$
case "project/scripted-plugin" => LauncherBased // tbd
case "project/scripted-skip-incompatible" => LauncherBased // sbt/Package$