Merge pull request #322 from eed3si9n/wip/nohouse

in-source sbt-houserules
This commit is contained in:
eugene yokota 2019-10-19 20:13:20 -04:00 committed by GitHub
commit da6897b8a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 191 additions and 128 deletions

View File

@ -4,7 +4,7 @@ group: stable
language: scala language: scala
scala: scala:
- 2.12.8 - 2.12.10
env: env:
global: global:
@ -30,9 +30,8 @@ install:
- unset JAVA_HOME - unset JAVA_HOME
- java -Xmx32m -version - java -Xmx32m -version
# detect sbt version from project/build.properties # detect sbt version from project/build.properties
# - export TRAVIS_SBT=$(grep sbt.version= project/build.properties | sed -e 's/sbt.version=//g' ) && echo "sbt $TRAVIS_SBT" - export TRAVIS_SBT=$(grep sbt.version= project/build.properties | sed -e 's/sbt.version=//g' ) && echo "sbt $TRAVIS_SBT"
# use 1.2.8 until 1.3.0 installer is out # - export TRAVIS_SBT=1.3.3
- export TRAVIS_SBT=1.2.8
- sdk install sbt $TRAVIS_SBT - sdk install sbt $TRAVIS_SBT
# override Travis CI's SBT_OPTS # override Travis CI's SBT_OPTS
- unset SBT_OPTS - unset SBT_OPTS

View File

@ -7,16 +7,28 @@ val _ = {
sys.props += ("line.separator" -> "\n") sys.props += ("line.separator" -> "\n")
} }
ThisBuild / git.baseVersion := "1.3.0"
ThisBuild / version := { ThisBuild / version := {
val old = (ThisBuild / version).value val old = (ThisBuild / version).value
nightlyVersion match { nightlyVersion match {
case Some(v) => v case Some(v) => v
case _ => case _ => old
if (old contains "SNAPSHOT") git.baseVersion.value + "-SNAPSHOT"
else old
} }
} }
ThisBuild / organization := "org.scala-sbt"
ThisBuild / bintrayPackage := "librarymanagement"
ThisBuild / homepage := Some(url("https://github.com/sbt/librarymanagement"))
ThisBuild / description := "Library management module for sbt"
ThisBuild / scmInfo := {
val slug = "sbt/librarymanagement"
Some(ScmInfo(url(s"https://github.com/$slug"), s"git@github.com:$slug.git"))
}
ThisBuild / licenses := List(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")))
ThisBuild / scalafmtOnCompile := true
ThisBuild / developers := List(
Developer("harrah", "Mark Harrah", "@harrah", url("https://github.com/harrah")),
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("http://eed3si9n.com/")),
Developer("dwijnand", "Dale Wijnand", "@dwijnand", url("https://github.com/dwijnand")),
)
ThisBuild / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat ThisBuild / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
@ -65,6 +77,7 @@ val mimaSettings = Def settings (
"1.1.3", "1.1.3",
"1.1.4", "1.1.4",
"1.2.0", "1.2.0",
"1.3.0",
) map ( ) map (
version => version =>
organization.value %% moduleName.value % version organization.value %% moduleName.value % version
@ -75,24 +88,14 @@ val mimaSettings = Def settings (
lazy val lmRoot = (project in file(".")) lazy val lmRoot = (project in file("."))
.aggregate(lmCore, lmIvy) .aggregate(lmCore, lmIvy)
.settings( .settings(
inThisBuild(
Seq(
homepage := Some(url("https://github.com/sbt/librarymanagement")),
description := "Library management module for sbt",
scmInfo := {
val slug = "sbt/librarymanagement"
Some(ScmInfo(url(s"https://github.com/$slug"), s"git@github.com:$slug.git"))
},
bintrayPackage := "librarymanagement",
)
),
commonSettings, commonSettings,
name := "LM Root", name := "LM Root",
publish := {}, publish := {},
publishLocal := {}, publishLocal := {},
publishArtifact in Compile := false, publishArtifact in Compile := false,
publishArtifact := false, publishArtifact := false,
customCommands mimaPreviousArtifacts := Set.empty,
customCommands,
) )
lazy val lmCore = (project in file("core")) lazy val lmCore = (project in file("core"))
@ -330,19 +333,19 @@ lazy val lmIvy = (project in file("ivy"))
), ),
) )
lazy val lmScriptedTest = (project in file("scripted-test")) // lazy val lmScriptedTest = (project in file("scripted-test"))
.enablePlugins(SbtPlugin) // .enablePlugins(SbtPlugin)
.settings( // .settings(
commonSettings, // commonSettings,
skip in publish := true, // skip in publish := true,
name := "scripted-test", // name := "scripted-test",
scriptedLaunchOpts := { // scriptedLaunchOpts := {
scriptedLaunchOpts.value ++ // scriptedLaunchOpts.value ++
Seq("-Xmx1024M", "-Dplugin.version=" + version.value) // Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
}, // },
scriptedBufferLog := false // scriptedBufferLog := false
) // )
.enablePlugins(SbtScriptedIT) // .enablePlugins(SbtScriptedIT)
// we are updating the nightly process, so we are commenting this out for now // we are updating the nightly process, so we are commenting this out for now
// addCommandAlias("scriptedIvy", Seq( // addCommandAlias("scriptedIvy", Seq(

View File

@ -3,12 +3,12 @@ import Keys._
import sbt.contraband.ContrabandPlugin.autoImport._ import sbt.contraband.ContrabandPlugin.autoImport._
object Dependencies { object Dependencies {
val scala212 = "2.12.8" val scala212 = "2.12.10"
def nightlyVersion: Option[String] = sys.props.get("sbt.build.version") def nightlyVersion: Option[String] = sys.props.get("sbt.build.version")
private val ioVersion = nightlyVersion.getOrElse("1.3.0-M16") private val ioVersion = nightlyVersion.getOrElse("1.3.1")
private val utilVersion = nightlyVersion.getOrElse("1.3.0-M9") private val utilVersion = nightlyVersion.getOrElse("1.3.2")
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion private val sbtIO = "org.scala-sbt" %% "io" % ioVersion

View File

@ -0,0 +1,58 @@
import sbt._
import Keys._
import bintray.BintrayPlugin
import bintray.BintrayPlugin.autoImport._
object HouseRulesPlugin extends AutoPlugin {
override def requires = plugins.JvmPlugin && BintrayPlugin
override def trigger = allRequirements
override def buildSettings: Seq[Def.Setting[_]] = baseBuildSettings
override def projectSettings: Seq[Def.Setting[_]] = baseSettings
lazy val baseBuildSettings: Seq[Def.Setting[_]] = Seq(
bintrayOrganization := Some("sbt"),
bintrayRepository := "maven-releases",
)
lazy val baseSettings: Seq[Def.Setting[_]] = Seq(
bintrayPackage := (ThisBuild / bintrayPackage).value,
bintrayRepository := (ThisBuild / bintrayRepository).value,
scalacOptions ++= Seq("-encoding", "utf8"),
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlint"),
scalacOptions += "-language:higherKinds",
scalacOptions += "-language:implicitConversions",
scalacOptions ++= "-Xfuture".ifScala213OrMinus.value.toList,
scalacOptions += "-Xlint",
scalacOptions ++= "-Xfatal-warnings"
.ifScala(v => {
sys.props.get("sbt.build.fatal") match {
case Some(_) => java.lang.Boolean.getBoolean("sbt.build.fatal")
case _ => v == 12
}
})
.value
.toList,
scalacOptions ++= "-Yinline-warnings".ifScala211OrMinus.value.toList,
scalacOptions ++= "-Yno-adapted-args".ifScala212OrMinus.value.toList,
scalacOptions += "-Ywarn-dead-code",
scalacOptions += "-Ywarn-numeric-widen",
scalacOptions += "-Ywarn-value-discard",
scalacOptions ++= "-Ywarn-unused-import".ifScala(v => 11 <= v && v <= 12).value.toList
) ++ Seq(Compile, Test).flatMap(
c => scalacOptions in (c, console) --= Seq("-Ywarn-unused-import", "-Xlint")
)
private def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value)
private implicit final class AnyWithIfScala[A](val __x: A) {
def ifScala(p: Long => Boolean) =
Def setting (scalaPartV.value collect { case (2, y) if p(y) => __x })
def ifScalaLte(v: Long) = ifScala(_ <= v)
def ifScalaGte(v: Long) = ifScala(_ >= v)
def ifScala211OrMinus = ifScalaLte(11)
def ifScala211OrPlus = ifScalaGte(11)
def ifScala212OrMinus = ifScalaLte(12)
def ifScala213OrMinus = ifScalaLte(13)
}
}

View File

@ -1,108 +1,108 @@
import sbt._ // import sbt._
import Keys._ // import Keys._
import java.io.File // import java.io.File
import java.util.UUID.randomUUID // import java.util.UUID.randomUUID
object SbtScriptedIT extends AutoPlugin { // object SbtScriptedIT extends AutoPlugin {
object autoImport { // object autoImport {
val scriptedTestSbtRepo = settingKey[String]("SBT repository to be used in scripted tests") // val scriptedTestSbtRepo = settingKey[String]("SBT repository to be used in scripted tests")
val scriptedTestSbtRef = settingKey[String]("SBT branch to be used in scripted tests") // val scriptedTestSbtRef = settingKey[String]("SBT branch to be used in scripted tests")
val scriptedTestLMImpl = settingKey[String]("Librarymanagement implementation to be used in scripted tests") // val scriptedTestLMImpl = settingKey[String]("Librarymanagement implementation to be used in scripted tests")
val scriptedSbtVersion = settingKey[String]("SBT version to be published locally for IT tests") // val scriptedSbtVersion = settingKey[String]("SBT version to be published locally for IT tests")
} // }
import autoImport._ // import autoImport._
override def requires = ScriptedPlugin // override def requires = ScriptedPlugin
override def trigger = noTrigger // override def trigger = noTrigger
override lazy val globalSettings = Seq( // override lazy val globalSettings = Seq(
scriptedTestSbtRepo := "https://github.com/sbt/sbt.git", // scriptedTestSbtRepo := "https://github.com/sbt/sbt.git",
scriptedTestSbtRef := "develop", // scriptedTestSbtRef := "develop",
scriptedTestLMImpl := "ivy", // scriptedTestLMImpl := "ivy",
scriptedSbtVersion := s"""${sbtVersion.value}-LM-SNAPSHOT""" // scriptedSbtVersion := s"""${sbtVersion.value}-LM-SNAPSHOT"""
) // )
private def cloneSbt(targetDir: File, repo: String, ref: String) = { // private def cloneSbt(targetDir: File, repo: String, ref: String) = {
import org.eclipse.jgit.api._ // import org.eclipse.jgit.api._
if (!targetDir.exists) { // if (!targetDir.exists) {
IO.createDirectory(targetDir) // IO.createDirectory(targetDir)
new CloneCommand() // new CloneCommand()
.setDirectory(targetDir) // .setDirectory(targetDir)
.setURI(repo) // .setURI(repo)
.call() // .call()
val git = Git.open(targetDir) // val git = Git.open(targetDir)
git.checkout().setName(ref).call() // git.checkout().setName(ref).call()
} // }
} // }
private def publishLocalSbt( // private def publishLocalSbt(
targetDir: File, // targetDir: File,
lmVersion: String, // lmVersion: String,
lmGroupID: String, // lmGroupID: String,
lmArtifactID: String, // lmArtifactID: String,
version: String) = { // version: String) = {
import sys.process._ // import sys.process._
Process( // Process(
Seq( // Seq(
"sbt", // "sbt",
"-J-Xms2048m", // "-J-Xms2048m",
"-J-Xmx2048m", // "-J-Xmx2048m",
"-J-XX:ReservedCodeCacheSize=256m", // "-J-XX:ReservedCodeCacheSize=256m",
"-J-XX:MaxMetaspaceSize=512m", // "-J-XX:MaxMetaspaceSize=512m",
s"""-Dsbt.build.lm.version=${lmVersion}""", // s"""-Dsbt.build.lm.version=${lmVersion}""",
s"""-Dsbt.build.lm.organization=${lmGroupID}""", // s"""-Dsbt.build.lm.organization=${lmGroupID}""",
s"""-Dsbt.build.lm.moduleName=${lmArtifactID}""", // s"""-Dsbt.build.lm.moduleName=${lmArtifactID}""",
s"""set ThisBuild / version := "${version}"""", // s"""set ThisBuild / version := "${version}"""",
"clean", // "clean",
"publishLocal" // "publishLocal"
), // ),
Some(targetDir) // Some(targetDir)
) ! // ) !
} // }
private def setScriptedTestsSbtVersion(baseDir: File, version: String) = { // private def setScriptedTestsSbtVersion(baseDir: File, version: String) = {
IO.listFiles(baseDir).foreach { d => // IO.listFiles(baseDir).foreach { d =>
if (d.isDirectory) { // if (d.isDirectory) {
IO.createDirectory(d / "project") // IO.createDirectory(d / "project")
IO.write( // IO.write(
d / "project" / "build.properties", // d / "project" / "build.properties",
s"sbt.version=$version" // s"sbt.version=$version"
) // )
} // }
} // }
} // }
import sbt.ScriptedPlugin.autoImport._ // import sbt.ScriptedPlugin.autoImport._
override lazy val projectSettings = Seq( // override lazy val projectSettings = Seq(
scriptedTests := { // scriptedTests := {
val targetDir = target.value / "sbt" // val targetDir = target.value / "sbt"
if (!targetDir.exists) { // if (!targetDir.exists) {
cloneSbt(targetDir, scriptedTestSbtRepo.value, scriptedTestSbtRef.value) // cloneSbt(targetDir, scriptedTestSbtRepo.value, scriptedTestSbtRef.value)
publishLocalSbt( // publishLocalSbt(
targetDir, // targetDir,
version.value, // version.value,
organization.value, // organization.value,
s"librarymanagement-${scriptedTestLMImpl.value}", // s"librarymanagement-${scriptedTestLMImpl.value}",
scriptedSbtVersion.value // scriptedSbtVersion.value
) // )
} // }
setScriptedTestsSbtVersion( // setScriptedTestsSbtVersion(
sbtTestDirectory.value / thisProject.value.id, // sbtTestDirectory.value / thisProject.value.id,
scriptedSbtVersion.value // scriptedSbtVersion.value
) // )
scriptedTests.value // scriptedTests.value
} // }
) // )
} // }

View File

@ -1 +1 @@
sbt.version=1.3.0-M3 sbt.version=1.3.3

View File

@ -1,5 +1,8 @@
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.9") addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0") addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.5")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.2")
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.2") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.2")
addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.14") addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.14")