Skip to content

Commit

Permalink
Use sbt 1 to build Lagom itself
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Mar 23, 2019
1 parent cd39048 commit 9c046c8
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 53 deletions.
2 changes: 1 addition & 1 deletion bin/test-2.11
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Akka snapshots which aren't being published for Scala 2.11 anymore.
checkIfShouldSkip "Scala 2.11"

runSbtNoisy "+++2.11.12 test"
runSbtNoisy "++2.11.12 test"
2 changes: 1 addition & 1 deletion bin/test-2.12
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/scriptLib"

runSbtNoisy "+++2.12.8 test"
runSbtNoisy "++2.12.8 test"
2 changes: 1 addition & 1 deletion bin/test-sbt-1.0
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
SCALA_VERSION="2.12.8"

# disable publishing javadoc for scripted
runSbt ";set publishArtifact in (Compile, packageDoc) in ThisBuild := false ;+++ ${SCALA_VERSION} publishLocal"
runSbt ";set publishArtifact in (Compile, packageDoc) in ThisBuild := false ;++ ${SCALA_VERSION} publishLocal"
runSbtNoisy ";set publishArtifact in (Compile, packageDoc) in ThisBuild := false ;++${SCALA_VERSION} scripted"
50 changes: 25 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import lagom.Protobuf
import lagom.build._
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import com.typesafe.tools.mima.core._
import sbt.CrossVersion._

// Turn off "Resolving" log messages that clutter build logs
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet
Expand Down Expand Up @@ -128,7 +127,7 @@ def releaseStepCommandAndRemaining(command: String): State => State = { original
if (newState.remainingCommands.isEmpty) {
newState
} else {
runCommand(newState.remainingCommands.head, newState.copy(remainingCommands = newState.remainingCommands.tail))
runCommand(newState.remainingCommands.head.commandLine, newState.copy(remainingCommands = newState.remainingCommands.tail))
}
}

Expand Down Expand Up @@ -160,8 +159,6 @@ def runtimeLibCommon: Seq[Setting[_]] = common ++ sonatypeSettings ++ runtimeSca
Dependencies.pruneWhitelistSetting,
Dependencies.dependencyWhitelistSetting,

incOptions := incOptions.value.withNameHashing(true),

// show full stack traces and test case durations
testOptions in Test += Tests.Argument("-oDF"),
// -v Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug".
Expand All @@ -188,11 +185,11 @@ val defaultMultiJvmOptions: List[String] = {
// -Djava.net.preferIPv4Stack=true or -Dmultinode.Xmx512m
val MultinodeJvmArgs = "multinode\\.(D|X)(.*)".r
val knownPrefix = Set("akka.", "lagom.")
val properties = System.getProperties.propertyNames.asScala.toList.collect {
val properties = System.getProperties.propertyNames.asScala.toList.collect { case s: String => s }.collect {
case MultinodeJvmArgs(a, b) =>
val value = System.getProperty("multinode." + a + b)
"-" + a + b + (if (value == "") "" else "=" + value)
case key: String if knownPrefix.exists(pre => key.startsWith(pre)) => "-D" + key + "=" + System.getProperty(key)
case key if knownPrefix.exists(pre => key.startsWith(pre)) => "-D" + key + "=" + System.getProperty(key)
}

"-Xmx128m" :: properties
Expand Down Expand Up @@ -242,11 +239,15 @@ def multiJvmTestSettings: Seq[Setting[_]] = {
executeTests in Test := {
val testResults = (executeTests in Test).value
val multiNodeResults = (executeTests in MultiJvm).value
val overall =
if (testResults.overall.id < multiNodeResults.overall.id)
multiNodeResults.overall
else
testResults.overall
import TestResult.{ Passed, Failed, Error }
val overall = (testResults.overall, multiNodeResults.overall) match {
case (Passed, Passed) => Passed
case (Failed, Failed) => Failed
case (Error, Error) => Error
case (Passed, Failed) | (Failed, Passed) => Failed
case (Passed, Error) | (Error, Passed) => Error
case (Failed, Error) | (Error, Failed) => Error
}
Tests.Output(overall,
testResults.events ++ multiNodeResults.events,
testResults.summaries ++ multiNodeResults.summaries)
Expand All @@ -260,7 +261,7 @@ def macroCompileSettings: Seq[Setting[_]] = Seq(
compile in Test ~= { a =>
// Delete classes in "compile" packages after compiling.
// These are used for compile-time tests and should be recompiled every time.
val products = a.relations.allProducts.toSeq ** new SimpleFileFilter(_.getParentFile.getName == "compile")
val products = (a.asInstanceOf[sbt.internal.inc.Analysis]).relations.allProducts.toSeq ** new SimpleFileFilter(_.getParentFile.getName == "compile")
IO.delete(products.get)
a
}
Expand Down Expand Up @@ -373,9 +374,8 @@ val sbtScriptedProjects = Seq[Project](
lazy val root = (project in file("."))
.settings(name := "lagom")
.settings(runtimeLibCommon: _*)
.enablePlugins(CrossPerProjectPlugin)
.settings(
crossScalaVersions := Dependencies.Versions.Scala,
crossScalaVersions := Nil,
scalaVersion := Dependencies.Versions.Scala.head,
PgpKeys.publishSigned := {},
publishLocal := {},
Expand Down Expand Up @@ -674,12 +674,12 @@ def forkedTests: Seq[Setting[_]] = Seq(
def singleTestsGrouping(tests: Seq[TestDefinition]) = {
// We could group non Cassandra tests into another group
// to avoid new JVM for each test, see http://www.scala-sbt.org/release/docs/Testing.html
val javaOptions = Seq("-Xms256M", "-Xmx512M")
val javaOptions = Vector("-Xms256M", "-Xmx512M")
tests map { test =>
Tests.Group(
name = test.name,
tests = Seq(test),
runPolicy = Tests.SubProcess(ForkOptions(runJVMOptions = javaOptions))
runPolicy = Tests.SubProcess(ForkOptions().withRunJVMOptions(javaOptions))
)
}
}
Expand Down Expand Up @@ -1161,10 +1161,9 @@ lazy val `sbt-build-tool-support` = (project in file("dev") / "build-tool-suppor
lazy val `sbt-plugin` = (project in file("dev") / "sbt-plugin")
.settings(common: _*)
.settings(scriptedSettings: _*)
.enablePlugins(SbtPluginPlugins)
.enablePlugins(SbtPluginPlugins, SbtPlugin)
.settings(
name := "lagom-sbt-plugin",
sbtPlugin := true,
crossScalaVersions := Dependencies.Versions.SbtScala,
scalaVersion := Dependencies.Versions.SbtScala.head,
sbtVersion in pluginCrossBuild := defineSbtVersion(scalaBinaryVersion.value),
Expand Down Expand Up @@ -1207,10 +1206,11 @@ lazy val `sbt-plugin` = (project in file("dev") / "sbt-plugin")
val () = (publishLocal in LocalProject("sbt-scripted-tools")).value
},
publishTo := {
val old = publishTo.value
if (isSnapshot.value) {
// Bintray doesn't support publishing snapshots, publish to Sonatype snapshots instead
Some(Opts.resolver.sonatypeSnapshots)
} else publishTo.value
} else old
},
publishMavenStyle := isSnapshot.value
).dependsOn(`sbt-build-tool-support`)
Expand Down Expand Up @@ -1247,7 +1247,7 @@ lazy val `maven-launcher` = (project in file("dev") / "maven-launcher")
Dependencies.`maven-launcher`
)

def scriptedSettings: Seq[Setting[_]] = ScriptedPlugin.scriptedSettings ++
def scriptedSettings: Seq[Setting[_]] =
Seq(scriptedLaunchOpts += s"-Dproject.version=${version.value}") ++
Seq(
scripted := scripted.tag(Tags.Test).evaluated,
Expand Down Expand Up @@ -1325,7 +1325,7 @@ lazy val `maven-dependencies` = (project in file("dev") / "maven-dependencies")
Dependencies.Versions.Scala.map { supportedVersion =>
// we are sure this won't be a None
val crossFunc =
CrossVersion(new Binary(binaryScalaVersion), supportedVersion, binaryScalaVersion(supportedVersion)).get
CrossVersion(Binary(), supportedVersion, CrossVersion.binaryScalaVersion(supportedVersion)).get
// convert artifactName to match the desired scala version
val artifactId = crossFunc(artifactName)

Expand Down Expand Up @@ -1364,7 +1364,7 @@ lazy val `maven-dependencies` = (project in file("dev") / "maven-dependencies")
// if it's a Scala dependency,
// generate <dependency> block for each supported scala version
Dependencies.Versions.Scala.map { supportedVersion =>
val crossDep = CrossVersion(supportedVersion, binaryScalaVersion(supportedVersion))(dep)
val crossDep = CrossVersion(supportedVersion, CrossVersion.binaryScalaVersion(supportedVersion))(dep)
<dependency>
<groupId>{crossDep.organization}</groupId>
<artifactId>{crossDep.name}</artifactId>
Expand All @@ -1376,11 +1376,11 @@ lazy val `maven-dependencies` = (project in file("dev") / "maven-dependencies")
}
</dependencies>
</dependencyManagement>
}
).settings(
},
// This disables creating jar, source jar and javadocs, and will cause the packaging type to be "pom" when the
// pom is created
Classpaths.defaultPackageKeys.map(key => publishArtifact in key := false): _*
Classpaths.defaultPackageKeys.map(key => publishArtifact in key := false),
publishMavenStyle := true, // Disable publishing ("delivering") the ivy.xml file
)

// This project doesn't get aggregated, it is only executed by the sbt-plugin scripted dependencies
Expand Down
6 changes: 4 additions & 2 deletions docs/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ val HibernateVersion = "5.3.7.Final"
val ValidationApiVersion = "2.0.1.Final"

val branch = {
import scala.sys.process._
val rev = "git rev-parse --abbrev-ref HEAD".!!.trim
if (rev == "HEAD") {
// not on a branch, get the hash
Expand Down Expand Up @@ -128,12 +129,13 @@ def forkedTests: Seq[Setting[_]] = Seq(
def singleTestsGrouping(tests: Seq[TestDefinition]) = {
// We could group non Cassandra tests into another group
// to avoid new JVM for each test, see https://www.scala-sbt.org/release/docs/Testing.html
val javaOptions = Seq("-Xms256M", "-Xmx512M")
val javaOptions = Vector("-Xms256M", "-Xmx512M")
tests map { test =>
new Tests.Group(
name = test.name,
tests = Seq(test),
runPolicy = Tests.SubProcess(javaOptions))
runPolicy = Tests.SubProcess(ForkOptions().withRunJVMOptions(javaOptions)),
)
}
}

Expand Down
1 change: 1 addition & 0 deletions docs/manual/common/guide/devmode/code/dev-environment.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ startElasticSearch in ThisBuild := {
elasticsearch / "bin" / "elasticsearch"
}

import scala.sys.process._
val process = Process(binFile.getAbsolutePath, elasticsearch).run(log)
log.info("Elastic search started on port 9200")

Expand Down
2 changes: 1 addition & 1 deletion docs/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.18
sbt.version=1.2.8
14 changes: 6 additions & 8 deletions docs/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ lazy val plugins = (project in file(".")).dependsOn(dev)

lazy val dev = ProjectRef(Path.fileProperty("user.dir").getParentFile, "sbt-plugin")

resolvers += Resolver.typesafeIvyRepo("releases")
addSbtPlugin("com.lightbend.markdown" %% "sbt-lightbend-markdown" % "1.6.1")
addSbtPlugin("com.lightbend.markdown" %% "sbt-lightbend-markdown" % "1.7.0")

// Needed for bintray configuration code samples
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.2.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.4.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.4.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-uglify" % "2.0.0")
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object Dependencies {
val Scala211 = "2.11.12"
val Scala212 = "2.12.8"
val Scala = Seq(Scala212, Scala211)
val SbtScala = Seq(Scala210, Scala212)
val SbtScala = Seq(Scala212, Scala210)

// If you update the version of Play, you probably need to update the other Play* variables.
val Play = "2.7.0"
Expand Down Expand Up @@ -165,7 +165,7 @@ object Dependencies {
"jackson-datatype-jdk8", "jackson-datatype-jsr310", "jackson-datatype-guava", "jackson-datatype-pcollections"
)

val scalaParserCombinatorOverrides = Set(scalaParserCombinators)
val scalaParserCombinatorOverrides = Seq(scalaParserCombinators)

// A whitelist of dependencies that Lagom is allowed to depend on, either directly or transitively.
// This list is used to validate all of Lagom's dependencies.
Expand Down
9 changes: 5 additions & 4 deletions project/Protobuf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
package lagom

import sbt._
import Process._
import Keys._
import sbt.Keys._
import sbt.util.CacheStoreFactory
import scala.sys.process._

import java.io.File
import java.io.PrintWriter
Expand Down Expand Up @@ -98,7 +99,7 @@ object Protobuf {
* Create a transformed version of all files in a directory, given a predicate and a transform function for each file.
*/
def transformDirectory(sourceDir: File, targetDir: File, transformable: File => Boolean, transform: (File, File) => Unit, cache: File, log: Logger): File = {
val runTransform = FileFunction.cached(cache)(FilesInfo.hash, FilesInfo.exists) { (in, out) =>
val runTransform = FileFunction.cached(CacheStoreFactory(cache), FilesInfo.hash, FilesInfo.exists) { (in, out) =>
val map = Path.rebase(sourceDir, targetDir)
if (in.removed.nonEmpty || in.modified.nonEmpty) {
log.info("Preprocessing directory %s..." format sourceDir)
Expand All @@ -116,7 +117,7 @@ object Protobuf {
updated
} else Set.empty
}
val sources = (sourceDir ***).get.toSet
val sources = sourceDir.allPaths.get.toSet
runTransform(sources)
targetDir
}
Expand Down
2 changes: 1 addition & 1 deletion project/SbtMavenPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ object SbtMavenPlugin extends AutoPlugin {
test.getName -> mavenExecutions.foldLeft(true) { (success, execution) =>
if (success) {
log.info(s"Executing mvn $execution")
val rc = Fork.java(ForkOptions(workingDirectory = Some(testDir)), args ++ execution.split(" +"))
val rc = Fork.java(ForkOptions().withWorkingDirectory(testDir), args ++ execution.split(" +"))
rc == 0
} else {
false
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.18
sbt.version=1.2.8
7 changes: 1 addition & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Copyright (C) 2016-2019 Lightbend Inc. <https://www.lightbend.com>

libraryDependencies ++= Seq(
"org.scala-sbt" % "scripted-plugin" % sbtVersion.value
)

addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2")

// the plugins used during release can have an impact on default values
Expand All @@ -18,9 +14,8 @@ addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.4.0")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.1")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")
addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0")
addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.14")
Expand Down

0 comments on commit 9c046c8

Please sign in to comment.