-
Notifications
You must be signed in to change notification settings - Fork 92
/
build.sbt
110 lines (96 loc) · 4.26 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
val sharedSettings = ScalaModulePlugin.scalaModuleSettings ++ ScalaModulePlugin.scalaModuleOsgiSettings ++ Seq(
name := "scala-async",
scalaModuleAutomaticModuleName := Some("scala.async"),
crossScalaVersions := Seq("2.13.15", "2.12.20"),
scalaVersion := crossScalaVersions.value.head,
OsgiKeys.exportPackage := Seq(s"scala.async.*;version=${version.value}"),
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
libraryDependencies += "junit" % "junit" % "4.13.2" % Test,
libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % Test,
ScalaModulePlugin.enableOptimizer,
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s"),
Test / scalacOptions ++= Seq("-Yrangepos"),
scalacOptions ++= List("-deprecation" , "-Xasync"),
)
lazy val proj = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("."))
.settings(sharedSettings)
.jvmEnablePlugins(SbtOsgi)
// until we have actually published for Scala.js. this is also why,
// for now, release.yml does just `proj/versionCheck` instead of `versionCheck`
.jvmSettings(versionPolicyIntention := Compatibility.BinaryAndSourceCompatible)
.jsSettings(versionPolicyIntention := Compatibility.None)
// override sbt-scala-module default (which is unsuitable for Scala.js)
.jsSettings(Test / fork := false)
lazy val root = project.in(file("."))
.settings(sharedSettings)
.aggregate(proj.jvm, proj.js)
Global / parallelExecution := false
// Uncomment to disable test compilation.
// Test / sources ~= ((xs: Seq[File]) => xs.filter(f => Seq("TreeInterrogation", "package").exists(f.name.contains)))
description := "An asynchronous programming facility for Scala that offers a direct API for working with Futures."
homepage := Some(url("http://github.com/scala/async"))
startYear := Some(2012)
pomExtra := (
<issueManagement>
<system>GitHub</system>
<url>https://github.com/scala/async/issues</url>
</issueManagement>
<developers>
<developer>
<id>phaller</id>
<name>Philipp Haller</name>
<timezone>+1</timezone>
<url>http://github.com/phaller</url>
</developer>
<developer>
<id>retronym</id>
<name>Jason Zaugg</name>
<timezone>+10</timezone>
<url>http://github.com/retronym</url>
</developer>
</developers>
)
commands += testDeterminism
def testDeterminism = Command.command("testDeterminism") { state =>
val extracted = Project.extract(state)
println("Running test:clean")
val (state1, _) = extracted.runTask(LocalRootProject / Test / clean, state)
println("Running test:compile")
val (state2, _) = extracted.runTask(LocalRootProject / Test / compile, state1)
val testClasses = extracted.get(Test / classDirectory)
val baseline: File = testClasses.getParentFile / (testClasses.getName + "-baseline")
baseline.mkdirs()
IO.copyDirectory(testClasses, baseline, overwrite = true)
IO.delete(testClasses)
println("Running test:compile")
val (state3, _) = extracted.runTask(LocalRootProject / Test / compile, state2)
import java.nio.file.FileVisitResult
import java.nio.file.{Files, Path}
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes
import java.util
def checkSameFileContents(one: Path, other: Path): Unit = {
Files.walkFileTree(one, new SimpleFileVisitor[Path]() {
override def visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult = {
val result: FileVisitResult = super.visitFile(file, attrs)
// get the relative file name from path "one"
val relativize: Path = one.relativize(file)
// construct the path for the counterpart file in "other"
val fileInOther: Path = other.resolve(relativize)
val otherBytes: Array[Byte] = Files.readAllBytes(fileInOther)
val thisBytes: Array[Byte] = Files.readAllBytes(file)
if (!(util.Arrays.equals(otherBytes, thisBytes))) {
throw new AssertionError(file + " is not equal to " + fileInOther)
}
return result
}
})
}
println("Comparing: " + baseline.toPath + " and " + testClasses.toPath)
checkSameFileContents(baseline.toPath, testClasses.toPath)
checkSameFileContents(testClasses.toPath, baseline.toPath)
state3
}