Merge pull request #3181 from dwijnand/pre-sbt1

Upgrades & tweaks to the build to prep for using sbt 1
This commit is contained in:
Dale Wijnand 2017-05-08 16:41:27 +01:00 committed by GitHub
commit 367ab3b2d3
5 changed files with 59 additions and 68 deletions

View File

@ -2,10 +2,6 @@ import Util._
import Dependencies._
import Sxr.sxr
import com.typesafe.tools.mima.core._, ProblemFilters._
import com.typesafe.tools.mima.plugin.MimaKeys.{ binaryIssueFilters, previousArtifact }
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
// ThisBuild settings take lower precedence,
// but can be shared across the multi projects.
def buildLevelSettings: Seq[Setting[_]] =
@ -52,11 +48,12 @@ def commonSettings: Seq[Setting[_]] =
crossScalaVersions := Seq(baseScalaVersion),
bintrayPackage := (bintrayPackage in ThisBuild).value,
bintrayRepository := (bintrayRepository in ThisBuild).value,
mimaDefaultSettings,
publishArtifact in Test := false,
mimaPreviousArtifacts := Set.empty, // Set(organization.value % moduleName.value % "1.0.0"),
mimaBinaryIssueFilters ++= Seq(
)
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._, ProblemFilters._
Seq()
}
) flatMap (_.settings)
def minimalSettings: Seq[Setting[_]] =
@ -70,13 +67,30 @@ def testedBaseSettings: Seq[Setting[_]] =
baseSettings ++ testDependencies
lazy val sbtRoot: Project = (project in file("."))
.enablePlugins(ScriptedPlugin)
.enablePlugins(ScriptedPlugin, SiteScaladocPlugin, GhpagesPlugin)
.configs(Sxr.sxrConf)
.aggregate(nonRoots: _*)
.settings(
buildLevelSettings,
minimalSettings,
rootSettings,
Util.baseScalacOptions,
Docs.settings,
Sxr.settings,
scalacOptions += "-Ymacro-expand:none", // for both sxr and doc
sources in sxr := {
val allSources = (sources ?? Nil).all(docProjects).value
allSources.flatten.distinct
}, //sxr
sources in (Compile, doc) := (sources in sxr).value, // doc
Sxr.sourceDirectories := {
val allSourceDirectories = (sourceDirectories ?? Nil).all(docProjects).value
allSourceDirectories.flatten
},
fullClasspath in sxr := (externalDependencyClasspath in Compile in sbtProj).value,
dependencyClasspath in (Compile, doc) := (fullClasspath in sxr).value,
Util.publishPomSettings,
otherRootSettings,
Transform.conscriptSettings(bundledLauncherProj),
publish := {},
publishLocal := {}
)
@ -312,8 +326,6 @@ def scriptedUnpublishedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
lazy val publishLauncher = TaskKey[Unit]("publish-launcher")
lazy val myProvided = config("provided") intransitive
def allProjects =
Seq(
testingProj,
@ -332,15 +344,8 @@ def allProjects =
bundledLauncherProj
)
def projectsWithMyProvided =
allProjects.map(p =>
p.copy(configurations = (p.configurations.filter(_ != Provided)) :+ myProvided))
lazy val nonRoots = projectsWithMyProvided.map(p => LocalProject(p.id))
lazy val nonRoots = allProjects.map(p => LocalProject(p.id))
def rootSettings =
fullDocSettings ++
Util.publishPomSettings ++ otherRootSettings ++
Transform.conscriptSettings(bundledLauncherProj)
def otherRootSettings =
Seq(
scripted := scriptedTask.evaluated,
@ -388,21 +393,6 @@ lazy val docProjects: ScopeFilter = ScopeFilter(
inAnyProject -- inProjects(sbtRoot, sbtProj, scriptedSbtProj, scriptedPluginProj),
inConfigurations(Compile)
)
def fullDocSettings = Util.baseScalacOptions ++ Docs.settings ++ Sxr.settings ++ Seq(
scalacOptions += "-Ymacro-expand:none", // for both sxr and doc
sources in sxr := {
val allSources = (sources ?? Nil).all(docProjects).value
allSources.flatten.distinct
}, //sxr
sources in (Compile, doc) := (sources in sxr).value, // doc
Sxr.sourceDirectories := {
val allSourceDirectories = (sourceDirectories ?? Nil).all(docProjects).value
allSourceDirectories.flatten
},
fullClasspath in sxr := (externalDependencyClasspath in Compile in sbtProj).value,
dependencyClasspath in (Compile, doc) := (fullClasspath in sxr).value
)
lazy val safeUnitTests = taskKey[Unit]("Known working tests (for both 2.10 and 2.11)")
lazy val safeProjects: ScopeFilter = ScopeFilter(
inProjects(mainSettingsProj, mainProj, actionsProj, runProj, stdTaskProj),

View File

@ -31,6 +31,10 @@ We are working with Scala Center to provide [an automatic migration tool][sbt-mi
- Drops deprecated `seq(..)` DSL method. Use `Seq` or pass in the settings without wrapping.
- Drops deprecated `File`/`Seq[File]` setting enrichments. Use `.value` and `Def.setting`.
- Drops deprecated `SubProcess` `apply` overload. Use `SubProcess(ForkOptions(runJVMOptions = ..))`.
- Drops `toError(o: Option[String]): Unit` in favour of `o foreach sys.error`.
- A number of the methods on `sbt.Path` (such as `relativeTo` and `rebase` and `flat`) are now no longer in the
default namespace by virtue of being mixed into the sbt package object. Use `sbt.io.Path` to access them
again.
#### Features

View File

@ -64,7 +64,7 @@ object Dependencies {
c: Option[Configuration] = None) =
path match {
case Some(f) =>
p dependsOn c.fold[ClasspathDependency](ProjectRef(file(f), projectName))(
p dependsOn c.fold[ClasspathDep[ProjectReference]](ProjectRef(file(f), projectName))(
ProjectRef(file(f), projectName) % _)
case None => p settings (libraryDependencies += c.fold(m)(m % _))
}

View File

@ -1,50 +1,47 @@
import sbt._
import Keys._
import sbt._, Keys._
import StatusPlugin.autoImport._
import com.typesafe.sbt.{ SbtGhPages, SbtGit, SbtSite, site => sbtsite }
import SbtSite.{ site, SiteKeys }
import SbtGhPages.{ ghpages, GhPagesKeys => ghkeys }
import SbtGit.{ git, GitKeys }
import sbtsite.SphinxSupport
import SiteKeys.{ makeSite, siteMappings }
import Sxr.sxr
import SiteMap.Entry
import com.typesafe.sbt.site.SitePlugin.autoImport._
import com.typesafe.sbt.site.SiteScaladocPlugin.autoImport._
import com.typesafe.sbt.sbtghpages.GhpagesPlugin.autoImport._
import com.typesafe.sbt.SbtGit, SbtGit.{ git, GitKeys }
import Sxr.{ sxr, sxrConf }
object Docs {
val siteExcludes = Set(".buildinfo", "objects.inv")
def siteInclude(f: File) = !siteExcludes.contains(f.getName)
def settings: Seq[Setting[_]] =
site.settings ++
site.includeScaladoc("api") ++
siteIncludeSxr("sxr") ++
ghPagesSettings
def ghPagesSettings = ghpages.settings ++ Seq(
git.remoteRepo := "git@github.com:sbt/sbt.github.com.git",
localRepoDirectory,
ghkeys.synchLocal := synchLocalImpl.value,
GitKeys.gitBranch in ghkeys.updatedRepository := Some("master")
def settings: Seq[Setting[_]] = Def settings (
siteSubdirName in SiteScaladoc := "api",
siteIncludeSxr("sxr"),
ghPagesSettings
)
def localRepoDirectory = ghkeys.repository := {
def ghPagesSettings = Def settings (
git.remoteRepo := "git@github.com:sbt/sbt.github.com.git",
localRepoDirectory,
ghpagesSynchLocal := synchLocalImpl.value,
ghpagesBranch := "master"
)
def localRepoDirectory = ghpagesRepository := {
// distinguish between building to update the site or not so that CI jobs
// that don't commit+publish don't leave uncommitted changes in the working directory
val status = if (isSnapshot.value) "snapshot" else "public"
Path.userHome / ".sbt" / "ghpages" / status / organization.value / name.value
}
def siteIncludeSxr(prefix: String) =
Seq(
mappings in sxr := Path.allSubpaths(sxr.value).toSeq
) ++ site.addMappingsToSiteDir(mappings in sxr, prefix)
def siteIncludeSxr(prefix: String) = Def settings (
mappings in sxr := Path.allSubpaths(sxr.value).toSeq,
siteSubdirName in sxrConf := prefix,
addMappingsToSiteDir(mappings in sxr, siteSubdirName in sxrConf)
)
def synchLocalImpl = Def task {
val repo = ghkeys.updatedRepository.value
val repo = ghpagesUpdatedRepository.value
val versioned = repo / version.value
IO.delete(versioned / "sxr")
IO.delete(versioned / "api")
val mappings = ghkeys.privateMappings.value
val mappings = ghpagesPrivateMappings.value
val toCopy = for ((file, target) <- mappings if siteInclude(file))
yield (file, versioned / target)
IO.copy(toCopy)

View File

@ -2,11 +2,11 @@ scalaVersion := "2.10.6"
scalacOptions ++= Seq("-feature", "-language:postfixOps")
addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.11")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.8.5")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0")
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.6.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.8.2")
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.2.0")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.4.0")
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0-M4")