Skip to content

Commit ac88395

Browse files
committed
Build cleanup
1 parent 0c471e5 commit ac88395

File tree

4 files changed

+32
-42
lines changed

4 files changed

+32
-42
lines changed

project/Build.scala

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,22 @@ object Build {
249249
// Compile using the non-bootstrapped and non-published dotty
250250
managedScalaInstance := false,
251251
scalaInstance := {
252-
val updateResult = update.value
253-
val (libraryJar, compilerJar) =
254-
if (bootstrapFromPublishedJars.value) {
255-
val jars = updateResult.select(
252+
val updateReport = update.value
253+
var libraryJar = packageBin.in(`dotty-library`, Compile).value
254+
var compilerJar = packageBin.in(`dotty-compiler`, Compile).value
255+
256+
if (bootstrapFromPublishedJars.value) {
257+
val jars = updateReport.select(
256258
configuration = configurationFilter(Configurations.ScalaTool.name),
257259
module = moduleFilter(),
258260
artifact = artifactFilter(extension = "jar")
259261
)
260-
(jars.find(_.getName.startsWith("dotty-library_2.12")).get,
261-
jars.find(_.getName.startsWith("dotty-compiler_2.12")).get)
262-
} else
263-
((packageBin in (`dotty-library`, Compile)).value: @sbtUnchecked,
264-
(packageBin in (`dotty-compiler`, Compile)).value: @sbtUnchecked)
262+
libraryJar = jars.find(_.getName.startsWith("dotty-library_2.12")).get
263+
compilerJar = jars.find(_.getName.startsWith("dotty-compiler_2.12")).get
264+
}
265265

266266
// All compiler dependencies except the library
267-
val otherDependencies = (dependencyClasspath in (`dotty-compiler`, Compile)).value
267+
val otherDependencies = dependencyClasspath.in(`dotty-compiler`, Compile).value
268268
.filterNot(_.get(artifact.key).exists(_.name == "dotty-library"))
269269
.map(_.data)
270270

@@ -362,8 +362,8 @@ object Build {
362362
val dottyInterfaces =jars("dotty-interfaces")
363363
val otherDeps = (dependencyClasspath in Compile).value.map(_.data).mkString(":")
364364
val sources =
365-
(unmanagedSources in (Compile, compile)).value ++
366-
(unmanagedSources in (`dotty-compiler`, Compile)).value
365+
unmanagedSources.in(Compile, compile).value ++
366+
unmanagedSources.in(`dotty-compiler`, Compile).value
367367
val args = Seq(
368368
"-siteroot", "docs",
369369
"-project", "Dotty",
@@ -488,7 +488,7 @@ object Build {
488488
"org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1", // used by the backend
489489
("org.scala-lang.modules" %% "scala-xml" % "1.0.6").withDottyCompat(scalaVersion.value),
490490
"org.scala-lang" % "scala-library" % scalacVersion % "test",
491-
Dependencies.`compiler-interface`,
491+
Dependencies.compilerInterface(sbtVersion.value),
492492
),
493493

494494
// For convenience, change the baseDirectory when running the compiler
@@ -675,19 +675,19 @@ object Build {
675675
// packageAll packages all and then returns a map with the abs location
676676
packageAll := {
677677
Map(
678-
"dotty-interfaces" -> (packageBin in (`dotty-interfaces`, Compile)).value,
679-
"dotty-compiler" -> (packageBin in Compile).value,
680-
"dotty-library" -> (packageBin in (`dotty-library`, Compile)).value,
681-
"dotty-compiler-test" -> (packageBin in Test).value
678+
"dotty-interfaces" -> packageBin.in(`dotty-interfaces`, Compile).value,
679+
"dotty-compiler" -> packageBin.in(Compile).value,
680+
"dotty-library" -> packageBin.in(`dotty-library`, Compile).value,
681+
"dotty-compiler-test" -> packageBin.in(Test).value
682682
).mapValues(_.getAbsolutePath)
683683
}
684684
)
685685

686686
lazy val bootstrapedDottyCompilerSettings = commonDottyCompilerSettings ++ Seq(
687687
packageAll := {
688-
(packageAll in `dotty-compiler`).value ++ Seq(
689-
("dotty-compiler" -> (packageBin in Compile).value.getAbsolutePath),
690-
("dotty-library" -> (packageBin in (`dotty-library-bootstrapped`, Compile)).value.getAbsolutePath)
688+
packageAll.in(`dotty-compiler`).value ++ Seq(
689+
"dotty-compiler" -> packageBin.in(Compile).value.getAbsolutePath,
690+
"dotty-library" -> packageBin.in(`dotty-library-bootstrapped`, Compile).value.getAbsolutePath
691691
)
692692
}
693693
)
@@ -738,8 +738,8 @@ object Build {
738738
description := "sbt compiler bridge for Dotty",
739739
resolvers += Resolver.typesafeIvyRepo("releases"), // For org.scala-sbt:api
740740
libraryDependencies ++= Seq(
741-
Dependencies.`compiler-interface`,
742-
(Dependencies.`zinc-apiinfo` % Test).withDottyCompat(scalaVersion.value),
741+
Dependencies.compilerInterface(sbtVersion.value),
742+
(Dependencies.zincApiinfo(sbtVersion.value) % Test).withDottyCompat(scalaVersion.value),
743743
("org.specs2" %% "specs2-core" % "3.9.1" % Test).withDottyCompat(scalaVersion.value),
744744
("org.specs2" %% "specs2-junit" % "3.9.1" % Test).withDottyCompat(scalaVersion.value)
745745
),
@@ -836,7 +836,7 @@ object Build {
836836
// Keep in sync with inject-sbt-dotty.sbt
837837
libraryDependencies ++= Seq(
838838
Dependencies.`jackson-databind`,
839-
Dependencies.`compiler-interface`
839+
Dependencies.compilerInterface(sbtVersion.value)
840840
),
841841
unmanagedSourceDirectories in Compile +=
842842
baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config",
@@ -871,12 +871,13 @@ object Build {
871871
includeFilter in unmanagedSources := NothingFilter | "*.ts" | "**.json",
872872
watchSources in Global ++= (unmanagedSources in Compile).value,
873873
compile in Compile := {
874-
val coursier = baseDirectory.value / "out/coursier"
875-
val packageJson = baseDirectory.value / "package.json"
874+
val workingDir = baseDirectory.value
875+
val coursier = workingDir / "out/coursier"
876+
val packageJson = workingDir / "package.json"
876877
if (!coursier.exists || packageJson.lastModified > coursier.lastModified)
877-
runProcess(Seq("npm", "run", "update-all"), wait = true, directory = baseDirectory.value: @sbtUnchecked)
878+
runProcess(Seq("npm", "run", "update-all"), wait = true, directory = workingDir)
878879
val tsc = baseDirectory.value / "node_modules" / ".bin" / "tsc"
879-
runProcess(Seq(tsc.getAbsolutePath, "--pretty", "--project", baseDirectory.value.getAbsolutePath), wait = true)
880+
runProcess(Seq(tsc.getAbsolutePath, "--pretty", "--project", workingDir.getAbsolutePath), wait = true)
880881

881882
// Currently, vscode-dotty depends on daltonjorge.scala for syntax highlighting,
882883
// this is not automatically installed when starting the extension in development mode

project/Dependencies.scala

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ object Dependencies {
1313
val `jackson-dataformat-yaml` =
1414
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-yaml" % jacksonVersion
1515

16-
private def readPropertyFile(file: String): Properties = {
17-
val prop = new Properties()
18-
val input = new FileInputStream(file)
19-
try {
20-
prop.load(input)
21-
prop
22-
}
23-
finally input.close
24-
}
25-
26-
private val sbtVersion = readPropertyFile("project/build.properties").getProperty("sbt.version")
27-
val `compiler-interface` = "org.scala-sbt" % "compiler-interface" % sbtVersion
28-
val `zinc-apiinfo` = "org.scala-sbt" %% "zinc-apiinfo" % sbtVersion
16+
def compilerInterface(sbtVersion: String) = "org.scala-sbt" % "compiler-interface" % sbtVersion
17+
def zincApiinfo(sbtVersion: String) = "org.scala-sbt" %% "zinc-apiinfo" % sbtVersion
2918
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.1.0
1+
sbt.version=1.1.1

project/inject-sbt-dotty.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ unmanagedSourceDirectories in Compile += baseDirectory.value / "../sbt-dotty/src
77
// Keep in sync with `sbt-dotty` config in Build.scala
88
libraryDependencies ++= Seq(
99
Dependencies.`jackson-databind`,
10-
Dependencies.`compiler-interface`
10+
Dependencies.compilerInterface(sbtVersion.value)
1111
)
1212
unmanagedSourceDirectories in Compile +=
1313
baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config"

0 commit comments

Comments
 (0)