Skip to content

Commit

Permalink
Remove crossTestBridges and publishBridgesAndSet
Browse files Browse the repository at this point in the history
These commands are not necessary anymore since they can be expressed by
operations at the task level that are more intuitive than the previous
commands.

This helps simplifying the whole build setup a lot.
  • Loading branch information
jvican committed Oct 18, 2017
1 parent ec6dfec commit 50bd155
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 38 deletions.
12 changes: 10 additions & 2 deletions bin/run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ set -eu
set -o nounset
SCALA_VERSION="$1"

# Exemplifies how the build should be used by user
# The following script makes sure to:
# 1. Checking binary compatibility
# 2. Checking formatting and headers
# 3. Testing the compiler bridge for all versions
# 4. Setting up the scala version specified by the argument
# 5. Running tests for all the projects and then scripted

sbt -Dfile.encoding=UTF-8 \
-J-XX:ReservedCodeCacheSize=256M \
Expand All @@ -13,7 +20,8 @@ sbt -Dfile.encoding=UTF-8 \
headerCheck \
test:headerCheck \
zincRoot/test:compile \
crossTestBridges \
"publishBridgesAndSet $SCALA_VERSION" \
+compilerBridge/test \
+compilerBridge/publishLocal \
++$SCALA_VERSION \
zincRoot/test \
zincRoot/scripted
6 changes: 5 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,13 @@ lazy val compilerBridge: Project = (project in internalPath / "compiler-bridge")
javaOptions in Test += "-Xmx1G",
inCompileAndTest(unmanagedSourceDirectories ++= BuildDefaults.handleScalaSpecificSources.value),
mimaSettings,
cachedPublishLocal := cachedPublishLocal.dependsOn(cachedPublishLocal.in(zincApiInfo)).value,
// Make sure that the sources are published for the bridge because we need them to compile it
publishArtifact in (Compile, packageSrc) := true,
// Cached publish local in the bridge also publishes api info and the compiler interface
cachedPublishLocal := cachedPublishLocal
.dependsOn(cachedPublishLocal.in(zincApiInfo))
.dependsOn(cachedPublishLocal.in(compilerInterface))
.value,
)

// defines operations on the API of a source, including determining whether it has changed and converting it to a string
Expand Down
48 changes: 13 additions & 35 deletions project/BuildPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,40 +126,21 @@ object BuildImplementation {
}

object BuildCommands {
import sbt.{ Command, State }
import sbt.Command
import BuildAutoImported.bridgeScalaVersions
def crossTestBridges(bridge: Project): Command = {
Command.command("crossTestBridges") { (state: State) =>
(bridgeScalaVersions.flatMap { (bridgeVersion: String) =>
// Note the ! here. You need this so compilerInterface gets forced to the scalaVersion
s"++ $bridgeVersion!" :: s"${bridge.id}/test" :: Nil
}) ::: (s"++ ${Dependencies.scala212}!" :: state)
}
}

def publishBridgesAndSet(bridge: Project, interface: Project, apiInfo: Project): Command = {
Command.args("publishBridgesAndSet", "<version>") { (state, args) =>
require(args.nonEmpty, "Missing Scala version argument.")
val userScalaVersion = args.mkString("")
s"${interface.id}/publishLocal" :: bridgeScalaVersions.flatMap { (v: String) =>
s"++ $v!" :: s"${apiInfo.id}/publishLocal" :: s"${bridge.id}/publishLocal" :: Nil
} ::: s"++ $userScalaVersion!" :: state
}
}

def publishBridgesAndTest(bridge: Project, interface: Project, apiInfo: Project): Command = {
def publishBridgesAndTest(bridge: Project, interface: Project, root: Project): Command = {
Command.args("publishBridgesAndTest", "<version>") { (state, args) =>
require(args.nonEmpty, "Missing arguments to publishBridgesAndTest.")
val version = args mkString ""
val bridgeCommands: List[String] = bridgeScalaVersions.flatMap { (v: String) =>
s"++ $v" :: s"${apiInfo.id}/publishLocal" :: s"${bridge.id}/publishLocal" :: Nil
}
s"${interface.id}/publishLocal" ::
bridgeCommands :::
s"++ $version" ::
s"zincRoot/scalaVersion" ::
s"zincRoot/test" ::
s"zincRoot/scripted" ::
val bridgeCommands: List[String] =
bridgeScalaVersions.flatMap((v: String) => s"+${bridge.id}/publishLocal" :: Nil)
val rootProject = root.id
bridgeCommands :::
s"++$version" ::
s"$rootProject/scalaVersion" ::
s"$rootProject/test" ::
s"$rootProject/scripted" ::
state
}
}
Expand All @@ -173,12 +154,10 @@ object BuildImplementation {
Command.command("runBenchmarks")(st => runPreSetup :: runBenchmark :: tearDownResources :: st)
}

def all(bridge: Project, interface: Project, apiInfo: Project, bench: Project): Seq[Command] = {
val crossTest = crossTestBridges(bridge)
val publishBridges = publishBridgesAndSet(bridge, interface, apiInfo)
val publishBridgesTest = publishBridgesAndTest(bridge, interface, apiInfo)
def all(bridge: Project, interface: Project, root: Project, bench: Project): Seq[Command] = {
val publishBridgesTest = publishBridgesAndTest(bridge, interface, root)
val runBench = runBenchmarks(bench)
List(crossTest, publishBridges, publishBridgesTest, runBench)
List(publishBridgesTest, runBench)
}
}

Expand Down Expand Up @@ -237,7 +216,6 @@ object BuildImplementation {
}
}


/**
* This setting figures out whether the version is a snapshot or not and configures
* the source and doc artifacts that are published by the build.
Expand Down

0 comments on commit 50bd155

Please sign in to comment.