Skip to content

Commit b46bd0a

Browse files
authored
Merge pull request #130 from dwijnand/build
Upgrade to sbt 0.13.13-RC3
2 parents 7c956c5 + 959bbfe commit b46bd0a

File tree

4 files changed

+93
-100
lines changed

4 files changed

+93
-100
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env:
2323
- TEST_COMMAND="-Dmima.testScalaVersion=2.12.0-RC1 testFunctional"
2424

2525
script:
26-
- sbt -J-XX:ReservedCodeCacheSize=256M $TEST_COMMAND
26+
- sbt -J-XX:ReservedCodeCacheSize=256M -J-Xmx3072M $TEST_COMMAND
2727

2828
# Tricks to avoid unnecessary cache updates
2929
- find $HOME/.sbt -name "*.lock" | xargs rm

build.sbt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
val root = MimaBuild.root
2+
val core = MimaBuild.core
3+
val reporter = MimaBuild.reporter
4+
val sbtplugin = MimaBuild.sbtplugin
5+
val reporterFunctionalTests = MimaBuild.reporterFunctionalTests

project/Build.scala

Lines changed: 86 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ object BuildSettings {
4747
publishMavenStyle := true,
4848
publishArtifact in Test := false,
4949
// The Nexus repo we're publishing to.
50-
publishTo <<= version { (v: String) =>
51-
val nexus = "https://oss.sonatype.org/"
52-
if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
53-
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
54-
},
50+
publishTo := Some(
51+
if (isSnapshot.value) "snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
52+
else "releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"
53+
),
5554
// Maven central cannot allow other repos. We're ok here because the artifacts we
5655
// we use externally are *optional* dependencies.
5756
pomIncludeRepository := { x => false },
@@ -82,29 +81,20 @@ object Dependencies {
8281

8382
}
8483

85-
// we cannot switch to build.sbt style here because we
86-
// do `override lazy val projects = ... tests ...`;
87-
// blocked by sbt/sbt#2532
88-
89-
object MimaBuild extends Build {
84+
object MimaBuild {
9085
import BuildSettings._
9186
import Dependencies._
9287

93-
// here we list all projects that are defined.
94-
override lazy val projects = Seq(root) ++ modules ++ tests :+ reporterFunctionalTests
95-
96-
lazy val modules = Seq(core, reporter, sbtplugin)
97-
9888
lazy val root = (
9989
project("root", file("."))
10090
aggregate(core, reporter, sbtplugin)
10191
settings(s3Settings:_*)
10292
settings(name := buildName,
10393
publish := (),
10494
publishLocal := (),
105-
mappings in upload <<= (assembly in reporter, version) map { (cli, v) =>
106-
def loc(name: String) = "migration-manager/%s/%s-%s.jar" format (v, name, v)
107-
Seq(cli -> loc("migration-manager-cli"))
95+
mappings in upload := {
96+
def loc(name: String) = "migration-manager/%s/%s-%s.jar" format (version.value, name, version.value)
97+
Seq((assembly in reporter).value -> loc("migration-manager-cli"))
10898
},
10999
host in upload := "downloads.typesafe.com.s3.amazonaws.com",
110100
testScalaVersion in Global := sys.props.getOrElse("mima.testScalaVersion", scalaVersion.value)
@@ -115,7 +105,7 @@ object MimaBuild extends Build {
115105
lazy val core = (
116106
project("core", file("core"),
117107
settings = ((commonSettings ++ buildInfoSettings): Seq[Setting[_]]) ++: Seq(
118-
sourceGenerators in Compile <+= buildInfo,
108+
sourceGenerators in Compile += buildInfo.taskValue,
119109
buildInfoKeys := Seq(version),
120110
buildInfoPackage := "com.typesafe.tools.mima.core.buildinfo",
121111
buildInfoObject := "BuildInfo"
@@ -127,19 +117,14 @@ object MimaBuild extends Build {
127117
)
128118

129119
val myAssemblySettings: Seq[Setting[_]] = (assemblySettings: Seq[Setting[_]]) ++ Seq(
130-
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
131-
{
132-
case "LICENSE" => MergeStrategy.first
133-
case x => old(x)
134-
}
135-
},
136-
AssemblyKeys.excludedFiles in assembly <<= (AssemblyKeys.excludedFiles in assembly) { (old) =>
137-
val tmp: Seq[File] => Seq[File] = { files: Seq[File] =>
138-
// Hack to keep LICENSE files.
139-
old(files) filterNot (_.getName contains "LICENSE")
140-
}
141-
tmp
142-
}
120+
mergeStrategy in assembly ~= (old => {
121+
case "LICENSE" => MergeStrategy.first
122+
case x => old(x)
123+
}),
124+
AssemblyKeys.excludedFiles in assembly ~= (old =>
125+
// Hack to keep LICENSE files.
126+
{ files: Seq[File] => old(files) filterNot (_.getName contains "LICENSE") }
127+
)
143128
)
144129

145130
lazy val reporter = (
@@ -151,7 +136,7 @@ object MimaBuild extends Build {
151136
settings(myAssemblySettings:_*)
152137
settings(
153138
// add task functional-tests that depends on all functional tests
154-
functionalTests <<= runAllTests,
139+
functionalTests := runAllTests.value,
155140
mainClass in assembly := Some("com.typesafe.tools.mima.cli.Main")
156141
)
157142
)
@@ -165,7 +150,7 @@ object MimaBuild extends Build {
165150
scriptedBufferLog := false,
166151
// Scripted locally publishes sbt plugin and then runs test projects with locally published version.
167152
// Therefore we also need to locally publish dependent projects on scripted test run.
168-
scripted <<= scripted dependsOn (publishLocal in core, publishLocal in reporter))
153+
scripted := (scripted dependsOn (publishLocal in core, publishLocal in reporter)).evaluated)
169154
dependsOn(reporter)
170155
settings(sbtPublishSettings:_*)
171156
)
@@ -183,14 +168,14 @@ object MimaBuild extends Build {
183168

184169
// defines a Project for the given base directory (for example, functional-tests/test1)
185170
// Its name is the directory name (test1) and it has compile+package tasks for sources in v1/ and v2/
186-
def testProject(base: File) = project(base.name, base, settings = testProjectSettings).configs(v1Config, v2Config)
171+
def testProject(base: File) = project("test-" + base.name, base, settings = testProjectSettings).configs(v1Config, v2Config)
187172

188173
lazy val testProjectSettings =
189174
commonSettings ++ // normal project defaults; can be trimmed later- test and run aren't needed, for example.
190-
Seq(scalaVersion <<= testScalaVersion in Global) ++
175+
Seq(scalaVersion := (testScalaVersion in Global).value) ++
191176
inConfig(v1Config)(perConfig) ++ // add compile/package for the v1 sources
192177
inConfig(v2Config)(perConfig) :+ // add compile/package for the v2 sources
193-
(functionalTests <<= runTest) // add the functional-tests task
178+
(functionalTests := runTest.value) // add the functional-tests task
194179

195180
// this is the key for the task that runs the reporter's functional tests
196181
lazy val functionalTests = TaskKey[Unit]("test-functional")
@@ -211,65 +196,68 @@ object MimaBuild extends Build {
211196
// sets the source directory in this configuration to be: testN / vN
212197
// scalaSource is the setting key that defines the directory for Scala sources
213198
// configuration gets the current configuration
214-
// expanded version: ss <<= (bd, conf) apply { (b,c) => b / c.name }
215-
lazy val shortSourceDir = scalaSource <<= (baseDirectory, configuration) { _ / _.name }
216-
217-
// this is the custom test task of the form (ta, tb, tc) map { (a,b,c) => ... }
218-
// tx are the tasks we need to do our job.
219-
// Once the task engine runs these tasks, it evaluates the function supplied to map with the task results bound to
220-
// a,b,c
221-
lazy val runTest =
222-
(fullClasspath in (reporterFunctionalTests, Compile), // the test classpath from the functionalTest project for the test
223-
thisProjectRef, // gives us the ProjectRef this task is defined in
224-
scalaInstance in core, // get a reference to the already loaded Scala classes so we get the advantage of a warm jvm
225-
packageBin in v1Config, // package the v1 sources and get the configuration used
226-
packageBin in v2Config, // same for v2
227-
scalaVersion,
228-
streams) map { (cp, proj, si, v1, v2, scalaV, streams) =>
229-
val urls = Attributed.data(cp).map(_.toURI.toURL).toArray
230-
val loader = new java.net.URLClassLoader(urls, si.loader)
231-
232-
val testClass = loader.loadClass("com.typesafe.tools.mima.lib.CollectProblemsTest")
233-
val testRunner = testClass.newInstance().asInstanceOf[{
234-
def runTest(testClasspath: Array[String], testName: String, oldJarPath: String, newJarPath: String, oraclePath: String): Unit
235-
}]
236-
237-
// Add the scala-library to the MiMa classpath used to run this test
238-
val testClasspath = Attributed.data(cp).filter(_.getName endsWith "scala-library.jar").map(_.getAbsolutePath).toArray
239-
240-
val projectPath = proj.build.getPath + "reporter" + "/" + "functional-tests" + "/" + "src" + "/" + "test" + "/" + proj.project
241-
242-
val oraclePath = {
243-
val p = projectPath + "/problems.txt"
244-
val p212 = projectPath + "/problems-2.12.txt"
245-
if(!(scalaV.startsWith("2.10.") || scalaV.startsWith("2.11.")) && new java.io.File(p212).exists) p212
246-
else p
247-
}
248-
249-
try {
250-
import scala.language.reflectiveCalls
251-
testRunner.runTest(testClasspath, proj.project, v1.getAbsolutePath, v2.getAbsolutePath, oraclePath)
252-
streams.log.info("Test '" + proj.project + "' succeeded.")
253-
} catch {
254-
case e: Exception => sys.error(e.toString)
255-
}
256-
()
257-
}
258-
259-
lazy val runAllTests =
260-
(state, // this is how we access all defined projects from a task
261-
thisProjectRef, // gives us the ProjectRef this task is defined in
262-
test in Test // requires unit tests to run first
263-
) flatMap { (s, proj, _) =>
264-
// gets all defined projects, dropping this project (core) so the task doesn't depend on itself
265-
val structure = Project.structure(s)
266-
val allProjects = structure.units(proj.build).defined.values filter (_.id != proj.project)
267-
// get the fun-tests task in each project
268-
val allTests = allProjects.toSeq flatMap { p => functionalTests in ProjectRef(proj.build, p.id) get structure.data }
269-
// depend on all fun-tests
270-
allTests.join.map(_ => ())
271-
}
272-
273-
def project(id: String, base: File, settings: Seq[Def.Setting[_]] = Nil) =
274-
Project(id, base, settings = settings) disablePlugins(BintrayPlugin)
199+
lazy val shortSourceDir = scalaSource := baseDirectory.value / configuration.value.name
200+
201+
lazy val runTest = Def.task {
202+
val cp = (fullClasspath in (reporterFunctionalTests, Compile)).value // the test classpath from the functionalTest project for the test
203+
val proj = thisProjectRef.value // gives us the ProjectRef this task is defined in
204+
val si = (scalaInstance in core).value // get a reference to the already loaded Scala classes so we get the advantage of a warm jvm
205+
val v1 = (packageBin in v1Config).value // package the v1 sources and get the configuration used
206+
val v2 = (packageBin in v2Config).value // same for v2
207+
val scalaV = scalaVersion.value
208+
val streams = Keys.streams.value
209+
val urls = Attributed.data(cp).map(_.toURI.toURL).toArray
210+
val loader = new java.net.URLClassLoader(urls, si.loader)
211+
212+
val testClass = loader.loadClass("com.typesafe.tools.mima.lib.CollectProblemsTest")
213+
val testRunner = testClass.newInstance().asInstanceOf[{
214+
def runTest(testClasspath: Array[String], testName: String, oldJarPath: String, newJarPath: String, oraclePath: String): Unit
215+
}]
216+
217+
// Add the scala-library to the MiMa classpath used to run this test
218+
val testClasspath = Attributed.data(cp).filter(_.getName endsWith "scala-library.jar").map(_.getAbsolutePath).toArray
219+
220+
val projectPath = proj.build.getPath + "reporter" + "/" + "functional-tests" + "/" + "src" + "/" + "test" + "/" + proj.project.stripPrefix("test-")
221+
222+
val oraclePath = {
223+
val p = projectPath + "/problems.txt"
224+
val p212 = projectPath + "/problems-2.12.txt"
225+
if(!(scalaV.startsWith("2.10.") || scalaV.startsWith("2.11.")) && new java.io.File(p212).exists) p212
226+
else p
227+
}
228+
229+
try {
230+
import scala.language.reflectiveCalls
231+
testRunner.runTest(testClasspath, proj.project, v1.getAbsolutePath, v2.getAbsolutePath, oraclePath)
232+
streams.log.info("Test '" + proj.project + "' succeeded.")
233+
} catch {
234+
case e: Exception => sys.error(e.toString)
235+
}
236+
()
237+
}
238+
239+
lazy val runAllTests = Def.taskDyn {
240+
val s = state.value // this is how we access all defined projects from a task
241+
val proj = thisProjectRef.value // gives us the ProjectRef this task is defined in
242+
val _ = (test in Test).value // requires unit tests to run first
243+
244+
// gets all defined projects, dropping this project (core) so the task doesn't depend on itself
245+
val structure = Project.structure(s)
246+
val allProjects = structure.units(proj.build).defined.values filter (_.id != proj.project)
247+
248+
// get the fun-tests task in each project
249+
val allTests = allProjects.toSeq flatMap { p => functionalTests in ProjectRef(proj.build, p.id) get structure.data }
250+
251+
// depend on all fun-tests
252+
Def.task {
253+
allTests.join.map(_ => ()).value
254+
}
255+
}
256+
257+
def project(id: String, base: File, settings: Seq[Def.Setting[_]] = Nil) =
258+
Project(id, base, settings = settings) disablePlugins(BintrayPlugin)
259+
}
260+
261+
object DefineTestProjectsPlugin extends AutoPlugin {
262+
override def extraProjects = MimaBuild.tests
275263
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.12
1+
sbt.version=0.13.13-RC3

0 commit comments

Comments
 (0)