Skip to content

Commit 0fb55cc

Browse files
committed
[backport] Update SBT and plugins to latest versions
Cherry picked from: cd61713 83451fd 9830d10 0621261
1 parent 72e412c commit 0fb55cc

File tree

10 files changed

+80
-64
lines changed

10 files changed

+80
-64
lines changed

admin/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ if ($env:APPVEYOR_FORCED_BUILD -eq 'true') {
4747
clearIvyCache
4848
# By default, test building the packages (but don't uplaod)
4949
# Need to redirect stderr, otherwise any error output (like jvm warning) fails the build (ErrorActionPreference)
50-
& cmd /c "sbt ""-Dproject.version=$env:version"" ""show s3Upload::mappings""" '2>&1'
50+
& cmd /c "sbt ""-Dproject.version=$env:version"" ""show s3Upload/mappings""" '2>&1'
5151
checkExit
5252
}

admin/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,5 @@ else
107107
version="2.12.4"
108108
clearIvyCache
109109
# By default, test building the packages (but don't uplaod)
110-
sbt -Dproject.version=$version "show s3Upload::mappings"
110+
sbt -Dproject.version=$version "show s3Upload/mappings"
111111
fi

build.sbt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import com.typesafe.sbt.SbtGit._
21
import ScalaDist.upload
32

43
// so we don't require a native git install
@@ -9,18 +8,23 @@ useJGit
98
// For testing, the version may be overridden with -Dproject.version=...
109
versionWithGit
1110

11+
isSnapshot := {
12+
git.overrideVersion(git.versionProperty.value) match {
13+
case Some(v) => v.endsWith("-SNAPSHOT") || git.gitUncommittedChanges.value
14+
case _ => isSnapshot.value // defined in SbtGit.scala
15+
}
16+
}
17+
1218
Versioning.settings
1319

1420
// necessary since sbt 0.13.12 for some dark and mysterious reason
1521
// perhaps related to sbt/sbt#2634. details, to the extent they
1622
// are known/understood, at scala/scala-dist#171
1723
scalaVersion := version.value
1824

19-
mappings in upload := Seq()
25+
upload / mappings := Seq()
2026

2127
upload := {
22-
import com.amazonaws.{ClientConfiguration, Protocol}
23-
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
2428
import com.amazonaws.services.s3.AmazonS3ClientBuilder
2529
import com.amazonaws.services.s3.model.PutObjectRequest
2630
import com.amazonaws.regions.Regions
@@ -29,8 +33,7 @@ upload := {
2933
val client = AmazonS3ClientBuilder.standard.withRegion(Regions.US_EAST_1).build
3034

3135
val log = streams.value.log
32-
33-
(mappings in upload).value map { case (file, key) =>
36+
(upload / mappings).value map { case (file, key) =>
3437
log.info("Uploading "+ file.getAbsolutePath() +" as "+ key)
3538
client.putObject(new PutObjectRequest("downloads.typesafe.com", key, file))
3639
}
@@ -44,6 +47,16 @@ ScalaDist.platformSettings
4447

4548
enablePlugins(UniversalPlugin, RpmPlugin, JDebPackaging, WindowsPlugin)
4649

50+
// TODO This silences a warning I don't understand.
51+
//
52+
// * scala-dist / Universal / configuration
53+
// +- /Users/jz/code/scala-dist/build.sbt:35
54+
// * scala-dist / Universal-docs / configuration
55+
// +- /Users/jz/code/scala-dist/build.sbt:35
56+
// * scala-dist / Universal-src / configuration
57+
// +- /Users/jz/code/scala-dist/build.sbt:35
58+
Global / excludeLintKeys += configuration
59+
4760
// resolvers += "local" at "file:///e:/.m2/repository"
4861
// resolvers += Resolver.mavenLocal
4962
// to test, run e.g., stage, or windows:packageBin, show s3Upload::mappings

project/Docs.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ object Docs {
1616
import ScalaDist._
1717

1818
def settings: Seq[Setting[_]] = Seq(
19-
packageName in UniversalDocs := s"scala-docs-${version.value}",
19+
UniversalDocs / packageName := s"scala-docs-${version.value}",
2020
// libraryDependencies += scalaDistDep(version.value, "javadoc"), // seems not to be necessary
2121
// need updateClassifiers to get javadoc jars
22-
mappings in UniversalDocs ++= createMappingsWith(updateClassifiers.value.toSeq, universalDocsMappings)
22+
UniversalDocs / mappings ++= createMappingsWith(updateClassifiers.value.toSeq, universalDocsMappings)
2323
)
2424

2525
private def universalDocsMappings(id: ModuleID, artifact: Artifact, file: File): Seq[(File, String)] = {
2626
def includeJar = (file -> s"api/jars/${id.name}-${id.revision}-javadoc.jar")
27-
artifact match {
28-
case Artifact("scala-library" | "scala-reflect" | "scala-compiler", "doc", _, _, _, _, _) =>
27+
artifact.name match {
28+
case "scala-library" | "scala-reflect" | "scala-compiler" if artifact.`type` == "doc" =>
2929
val tmpdir = IO.createTemporaryDirectory
3030
IO.unzip(file, tmpdir)
3131
// IO.listFiles(tmpdir) does not recurse, use ** with glob "*" to find all files
@@ -35,7 +35,7 @@ object Docs {
3535
Seq(file -> s"api/${id.name}/$relative")
3636
}
3737
includeJar +: exploded
38-
case Artifact(_, "doc", _, _, _, _, _) =>
38+
case _ if artifact.`type` == "doc" =>
3939
Seq(includeJar)
4040
case _ => Seq()
4141
}

project/ScalaDist.scala

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import com.amazonaws.services.s3.model.PutObjectResult
1212
object ScalaDist {
1313
val upload=TaskKey[Seq[PutObjectResult]]("s3-upload","Uploads files to an S3 bucket.")
1414

15-
def createMappingsWith(deps: Seq[(String, ModuleID, Artifact, File)],
15+
def createMappingsWith(deps: Seq[(sbt.librarymanagement.ConfigRef, ModuleID, Artifact, File)],
1616
distMappingGen: (ModuleID, Artifact, File) => Seq[(File, String)]): Seq[(File, String)] =
1717
deps flatMap {
18-
case d@(ScalaDistConfig, id, artifact, file) => distMappingGen(id, artifact, file)
18+
case (configRef, id, artifact, file)
19+
if configRef.name == ScalaDistConfigName && id.configurations.contains("runtime") =>
20+
distMappingGen(id, artifact, file)
1921
case _ => Seq()
2022
}
2123

@@ -29,22 +31,22 @@ object ScalaDist {
2931
// s3-upload thus depends on the package tasks listed below
3032
def platformSettings =
3133
if (sys.props("os.name").toLowerCase(java.util.Locale.US) contains "windows")
32-
Wix.settings :+ (mappings in upload += uploadMapping(packageBin in Windows).value)
34+
Wix.settings :+ (upload / mappings += uploadMapping(Windows / packageBin).value)
3335
else Unix.settings ++ Seq(
34-
mappings in upload += uploadMapping(packageBin in Universal).value,
35-
mappings in upload += uploadMapping(packageZipTarball in Universal).value,
36-
mappings in upload += uploadMapping(packageBin in UniversalDocs).value,
37-
mappings in upload += uploadMapping(packageZipTarball in UniversalDocs).value,
38-
mappings in upload += uploadMapping(packageXzTarball in UniversalDocs).value,
39-
mappings in upload += uploadMapping(packageBin in Rpm).value,
36+
upload / mappings += uploadMapping(Universal / packageBin).value,
37+
upload / mappings += uploadMapping(Universal / packageZipTarball).value,
38+
upload / mappings += uploadMapping(UniversalDocs / packageBin).value,
39+
upload / mappings += uploadMapping(UniversalDocs / packageZipTarball).value,
40+
upload / mappings += uploadMapping(UniversalDocs / packageXzTarball).value,
41+
upload / mappings += uploadMapping(Rpm / packageBin).value,
4042
// Debian needs special handling because the value sbt-native-packager
41-
// gives us for `packageBin in Debian` (coming from the archiveFilename
43+
// gives us for `Debian / packageBin` (coming from the archiveFilename
4244
// method) includes the debian version and arch information,
4345
// which we historically have not included. I don't see a way to
4446
// override the filename on disk, so we re-map at upload time
45-
mappings in upload += Def.task {
46-
(packageBin in Debian).value ->
47-
s"scala/${version.value}/${(name in Debian).value}-${version.value}.deb"
47+
upload / mappings += Def.task {
48+
(Debian / packageBin).value ->
49+
s"scala/${version.value}/${(Debian / name).value}-${version.value}.deb"
4850
}.value
4951
)
5052

@@ -57,29 +59,30 @@ object ScalaDist {
5759
packageDescription := "Have the best of both worlds. Construct elegant class hierarchies for maximum code reuse and extensibility, implement their behavior using higher-order functions. Or anything in-between.",
5860
crossPaths := false,
5961

60-
ivyConfigurations += config(ScalaDistConfig),
62+
ivyConfigurations += ScalaDistConfig,
6163
libraryDependencies += scalaDistDep(version.value, "runtime"),
6264

6365
// create lib directory by resolving scala-dist's dependencies
6466
// to populate the rest of the distribution, explode scala-dist artifact itself
65-
mappings in Universal ++= createMappingsWith(update.value.toSeq, universalMappings),
67+
Universal / mappings ++= createMappingsWith(update.value.toSeq, universalMappings),
6668

6769
// work around regression in sbt-native-packager 1.0.5 where
6870
// these tasks invoke `tar` without any flags at all. the issue
6971
// was fixed in 1.1.0, so this could be revisited when we upgrade
70-
universalArchiveOptions in (UniversalDocs, packageZipTarball) := Seq("--force-local", "-pcvf"),
71-
universalArchiveOptions in (UniversalDocs, packageXzTarball ) := Seq("--force-local", "-pcvf")
72+
UniversalDocs / packageZipTarball / universalArchiveOptions := Seq("--force-local", "-pcvf"),
73+
UniversalDocs / packageXzTarball / universalArchiveOptions := Seq("--force-local", "-pcvf")
7274

7375
)
7476

7577
// private lazy val onWindows = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows")
7678
// only used for small batch files, normalize line endings in-place
7779
// private def toDosInPlace(f: File) = IO.writeLines(file, IO.readLines(file))
7880

79-
private lazy val ScalaDistConfig = "scala-dist"
81+
private lazy val ScalaDistConfigName = "scala-dist"
82+
private lazy val ScalaDistConfig = config(ScalaDistConfigName)
8083
// segregate scala-dist's compile dependencies into the scala-dist config
8184
private def scalaDistDep(v: String, config: String): ModuleID =
82-
"org.scala-lang" % "scala-dist" % v % s"${ScalaDistConfig}; ${ScalaDistConfig}->${config}"
85+
"org.scala-lang" % "scala-dist" % v % s"${ScalaDistConfigName}; ${ScalaDistConfigName}->${config}"
8386

8487
// map module to the corresponding file mappings (unzipping scala-dist in the process)
8588
private def universalMappings(id: ModuleID, artifact: Artifact, file: File): Seq[(File, String)] = id.name match {
@@ -90,7 +93,7 @@ object ScalaDist {
9093

9194
// create mappings from the unzip scala-dist zip
9295
contentOf(tmpdir) filter {
93-
case (file, dest) => !(dest.endsWith("MANIFEST.MF") || dest.endsWith("META-INF"))
96+
case (_, dest) => !(dest.endsWith("MANIFEST.MF") || dest.endsWith("META-INF"))
9497
} map {
9598
// make unix scripts executable (heuristically...)
9699
case (file, dest) if (dest startsWith "bin/") && !(dest endsWith ".bat") =>

project/Unix.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object Unix {
2727
// symlinks for s"/usr/bin/$script" --> s"${installTargetUnix.value}/bin/$script"
2828
// TODO: reuse code from native packager
2929
linuxPackageSymlinks ++= (
30-
(mappings in Universal).value collect {
30+
(Universal / mappings).value collect {
3131
case (file, name) if (name startsWith "bin/") && !(name endsWith ".bat") =>
3232
LinuxSymlink("/usr/" + name, (installTargetUnix.value / name).getAbsolutePath)
3333
}
@@ -37,13 +37,13 @@ object Unix {
3737
def home(name: String) = (installTargetUnix.value / name).getAbsolutePath
3838
def docHome(name: String) = (installTargetUnixDocs.value / name).getAbsolutePath
3939

40-
val m = (mappings in Universal).value
40+
val m = (Universal / mappings).value
4141

4242
// some mappings need special treatment (different root, perms,...)
4343
val (special, regular) = m partition { case (file, name) =>
4444
(name startsWith "bin") || (name startsWith "doc") || (name startsWith "man")
4545
}
46-
val docs = (mappings in UniversalDocs).value
46+
val docs = (UniversalDocs / mappings).value
4747

4848
Seq(
4949
// no special treatment needed
@@ -59,38 +59,38 @@ object Unix {
5959
(pkgMap(
6060
(special collect { case (file, name) if name startsWith "doc/" => file -> docHome(name drop 4) }) ++
6161
(docs map { case (file, name) => file -> docHome(name) }) :+
62-
(((sourceDirectory in Linux).value / "copyright") -> docHome("copyright")))
62+
(((Linux / sourceDirectory).value / "copyright") -> docHome("copyright")))
6363
withPerms "0644").asDocs
6464
)
6565
},
6666

6767
// RPM Specific
68-
name in Rpm := "scala",
68+
Rpm / name := "scala",
6969
rpmVendor := "lightbend",
7070
rpmUrl := Some("http://github.com/scala/scala"),
7171
rpmLicense := Some("BSD"),
7272
rpmGroup := Some("Development/Languages"),
7373

7474
// This hack lets us ignore the RPM specific versioning junks.
75-
packageBin in Rpm := {
76-
val simplified = target.value / s"${(name in Rpm).value}-${version.value}.rpm"
75+
Rpm / packageBin := {
76+
val simplified = target.value / s"${(Rpm / name).value}-${version.value}.rpm"
7777

78-
val rpm = (packageBin in Rpm).value match {
78+
val rpm = (Rpm / packageBin).value match {
7979
case reported if reported.exists => reported
8080
case _ => // hack on top of hack because RpmHelper.buildRpm is broken on Mac -- `spec.meta.arch` doesn't necessarily match the arch `rpmbuild` decided on
81-
(PathFinder(IO.listFiles((target in Rpm).value)) ** "*.rpm").get.find(file =>
82-
file.getName contains (name in Rpm).value).get
81+
(PathFinder(IO.listFiles((Rpm / target).value)) ** "*.rpm").get.find(file =>
82+
file.getName contains (Rpm / name).value).get
8383
}
8484

8585
IO.copyFile(rpm, simplified)
8686
simplified
8787
},
8888

8989
// Debian Specific
90-
name in Debian := "scala",
90+
Debian / name := "scala",
9191
debianPackageDependencies += "java8-runtime-headless",
9292

93-
linuxPackageMappings in Debian += (packageMapping(
93+
Debian / linuxPackageMappings += (packageMapping(
9494
(sourceDirectory.value / "debian" / "changelog") -> "/usr/share/doc/scala/changelog.gz"
9595
).withUser("root").withGroup("root").withPerms("0644").gzipped).asDocs()
9696

project/Versioning.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import com.typesafe.sbt.SbtNativePackager.{Windows, Debian, Rpm}
55

66
object Versioning {
77
def settings: Seq[Setting[_]] = Seq(
8-
version in Windows := makeWindowsVersion(version.value),
9-
version in Debian := toDebianVersion((version in Windows).value),
10-
version in Rpm := toRpmVersion((version in Windows).value))
8+
Windows / version := makeWindowsVersion(version.value),
9+
Debian / version := toDebianVersion((Windows / version).value),
10+
Rpm / version := toRpmVersion((Windows / version).value))
1111

1212
private def rpmBuild(version:String): String = version split "\\." match {
1313
case Array(_,_,_, b) => b

project/Wix.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ import WixHelper.{generateComponentsAndDirectoryXml, cleanFileName}
1111
object Wix {
1212
// Windows installer configuration
1313
def settings: Seq[Setting[_]] = Seq(
14-
mappings in Windows := (mappings in Universal).value,
15-
// distributionFiles in Windows += (packageMsi in Windows).value,
14+
Windows / mappings := (Universal / mappings).value,
15+
// Windows / distributionFiles += (Windows / packageMsi).value,
1616

1717
wixProductId := "7606e6da-e168-42b5-8345-b08bf774cb30",
1818
wixProductUpgradeId := "6061c134-67c7-4fb2-aff5-32b01a186968",
1919
// wixProductComments := "Scala Programming language for use in Windows.",
2020

21-
wixProductConfig := makeProductConfig((stagingDirectory in Universal).value, (stagingDirectory in UniversalDocs).value),
21+
wixProductConfig := makeProductConfig((Universal / stagingDirectory).value, (UniversalDocs / stagingDirectory).value),
2222
wixProductConfig := (wixProductConfig
23-
dependsOn (stage in Universal)
24-
dependsOn (stage in UniversalDocs)).value,
23+
dependsOn (Universal / stage)
24+
dependsOn (UniversalDocs / stage)).value,
2525

26-
packageBin in Windows := {
26+
Windows / packageBin := {
2727
val versioned = target.value / s"${name.value}-${version.value}.msi"
2828

29-
IO.copyFile((packageBin in Windows).value, versioned)
29+
IO.copyFile((Windows / packageBin).value, versioned)
3030
versioned
3131
}
3232
)
@@ -39,7 +39,7 @@ object Wix {
3939
// enable -Xfatal-warnings again in scalacOptions in project/plugins.sbt
4040
val (bin, binDirXml0) = generateComponentsAndDirectoryXml(stage / "bin")
4141
val (doc, docDirXml) = generateComponentsAndDirectoryXml(stage / "doc", "doc_")
42-
val (lib, libDirXml) = generateComponentsAndDirectoryXml(stage / "lib")
42+
val (lib, libDirXml) = generateComponentsAndDirectoryXml(stage / "lib", "lib_")
4343
val (api, apiDirXml) = generateComponentsAndDirectoryXml(stageApi / "api", "api_")
4444

4545
// add component that adds bin folder to path

project/build.properties

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

project/plugins.sbt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
scalacOptions ++= Seq("-deprecation", "-feature", "-Xlint")
1+
scalacOptions ++= Seq("-deprecation", "-feature", "-Xlint:_,-unused")
22

3-
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6")
3+
// jdeb and spotify docker are 'provided' in sbt-native-packager
4+
libraryDependencies += "org.vafer" % "jdeb" % "1.9" artifacts (Artifact("jdeb", "jar", "jar"))
5+
libraryDependencies += "com.spotify" % "docker-client" % "8.16.0"
6+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")
47

5-
libraryDependencies += "com.amazonaws" % "aws-java-sdk-s3" % "1.11.277"
8+
libraryDependencies += "com.amazonaws" % "aws-java-sdk-s3" % "1.12.5"
69

7-
// git plugin
8-
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
9-
10-
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")
10+
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1")
1111

0 commit comments

Comments
 (0)