Skip to content

[backport] Update SBT and plugins to latest versions #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ if ($env:APPVEYOR_FORCED_BUILD -eq 'true') {
clearIvyCache
# By default, test building the packages (but don't uplaod)
# Need to redirect stderr, otherwise any error output (like jvm warning) fails the build (ErrorActionPreference)
& cmd /c "sbt ""-Dproject.version=$env:version"" ""show s3Upload::mappings""" '2>&1'
& cmd /c "sbt ""-Dproject.version=$env:version"" ""show s3Upload/mappings""" '2>&1'
checkExit
}
2 changes: 1 addition & 1 deletion admin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ else
version="2.12.4"
clearIvyCache
# By default, test building the packages (but don't uplaod)
sbt -Dproject.version=$version "show s3Upload::mappings"
sbt -Dproject.version=$version "show s3Upload/mappings"
fi
25 changes: 19 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.typesafe.sbt.SbtGit._
import ScalaDist.upload

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

isSnapshot := {
git.overrideVersion(git.versionProperty.value) match {
case Some(v) => v.endsWith("-SNAPSHOT") || git.gitUncommittedChanges.value
case _ => isSnapshot.value // defined in SbtGit.scala
}
}

Versioning.settings

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

mappings in upload := Seq()
upload / mappings := Seq()

upload := {
import com.amazonaws.{ClientConfiguration, Protocol}
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
import com.amazonaws.services.s3.AmazonS3ClientBuilder
import com.amazonaws.services.s3.model.PutObjectRequest
import com.amazonaws.regions.Regions
Expand All @@ -29,8 +33,7 @@ upload := {
val client = AmazonS3ClientBuilder.standard.withRegion(Regions.US_EAST_1).build

val log = streams.value.log

(mappings in upload).value map { case (file, key) =>
(upload / mappings).value map { case (file, key) =>
log.info("Uploading "+ file.getAbsolutePath() +" as "+ key)
client.putObject(new PutObjectRequest("downloads.typesafe.com", key, file))
}
Expand All @@ -44,6 +47,16 @@ ScalaDist.platformSettings

enablePlugins(UniversalPlugin, RpmPlugin, JDebPackaging, WindowsPlugin)

// TODO This silences a warning I don't understand.
//
// * scala-dist / Universal / configuration
// +- /Users/jz/code/scala-dist/build.sbt:35
// * scala-dist / Universal-docs / configuration
// +- /Users/jz/code/scala-dist/build.sbt:35
// * scala-dist / Universal-src / configuration
// +- /Users/jz/code/scala-dist/build.sbt:35
Global / excludeLintKeys += configuration

// resolvers += "local" at "file:///e:/.m2/repository"
// resolvers += Resolver.mavenLocal
// to test, run e.g., stage, or windows:packageBin, show s3Upload::mappings
10 changes: 5 additions & 5 deletions project/Docs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ object Docs {
import ScalaDist._

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

private def universalDocsMappings(id: ModuleID, artifact: Artifact, file: File): Seq[(File, String)] = {
def includeJar = (file -> s"api/jars/${id.name}-${id.revision}-javadoc.jar")
artifact match {
case Artifact("scala-library" | "scala-reflect" | "scala-compiler", "doc", _, _, _, _, _) =>
artifact.name match {
case "scala-library" | "scala-reflect" | "scala-compiler" if artifact.`type` == "doc" =>
val tmpdir = IO.createTemporaryDirectory
IO.unzip(file, tmpdir)
// IO.listFiles(tmpdir) does not recurse, use ** with glob "*" to find all files
Expand All @@ -35,7 +35,7 @@ object Docs {
Seq(file -> s"api/${id.name}/$relative")
}
includeJar +: exploded
case Artifact(_, "doc", _, _, _, _, _) =>
case _ if artifact.`type` == "doc" =>
Seq(includeJar)
case _ => Seq()
}
Expand Down
43 changes: 23 additions & 20 deletions project/ScalaDist.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import com.amazonaws.services.s3.model.PutObjectResult
object ScalaDist {
val upload=TaskKey[Seq[PutObjectResult]]("s3-upload","Uploads files to an S3 bucket.")

def createMappingsWith(deps: Seq[(String, ModuleID, Artifact, File)],
def createMappingsWith(deps: Seq[(sbt.librarymanagement.ConfigRef, ModuleID, Artifact, File)],
distMappingGen: (ModuleID, Artifact, File) => Seq[(File, String)]): Seq[(File, String)] =
deps flatMap {
case d@(ScalaDistConfig, id, artifact, file) => distMappingGen(id, artifact, file)
case (configRef, id, artifact, file)
if configRef.name == ScalaDistConfigName && id.configurations.contains("runtime") =>
distMappingGen(id, artifact, file)
case _ => Seq()
}

Expand All @@ -29,22 +31,22 @@ object ScalaDist {
// s3-upload thus depends on the package tasks listed below
def platformSettings =
if (sys.props("os.name").toLowerCase(java.util.Locale.US) contains "windows")
Wix.settings :+ (mappings in upload += uploadMapping(packageBin in Windows).value)
Wix.settings :+ (upload / mappings += uploadMapping(Windows / packageBin).value)
else Unix.settings ++ Seq(
mappings in upload += uploadMapping(packageBin in Universal).value,
mappings in upload += uploadMapping(packageZipTarball in Universal).value,
mappings in upload += uploadMapping(packageBin in UniversalDocs).value,
mappings in upload += uploadMapping(packageZipTarball in UniversalDocs).value,
mappings in upload += uploadMapping(packageXzTarball in UniversalDocs).value,
mappings in upload += uploadMapping(packageBin in Rpm).value,
upload / mappings += uploadMapping(Universal / packageBin).value,
upload / mappings += uploadMapping(Universal / packageZipTarball).value,
upload / mappings += uploadMapping(UniversalDocs / packageBin).value,
upload / mappings += uploadMapping(UniversalDocs / packageZipTarball).value,
upload / mappings += uploadMapping(UniversalDocs / packageXzTarball).value,
upload / mappings += uploadMapping(Rpm / packageBin).value,
// Debian needs special handling because the value sbt-native-packager
// gives us for `packageBin in Debian` (coming from the archiveFilename
// gives us for `Debian / packageBin` (coming from the archiveFilename
// method) includes the debian version and arch information,
// which we historically have not included. I don't see a way to
// override the filename on disk, so we re-map at upload time
mappings in upload += Def.task {
(packageBin in Debian).value ->
s"scala/${version.value}/${(name in Debian).value}-${version.value}.deb"
upload / mappings += Def.task {
(Debian / packageBin).value ->
s"scala/${version.value}/${(Debian / name).value}-${version.value}.deb"
}.value
)

Expand All @@ -57,29 +59,30 @@ object ScalaDist {
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.",
crossPaths := false,

ivyConfigurations += config(ScalaDistConfig),
ivyConfigurations += ScalaDistConfig,
libraryDependencies += scalaDistDep(version.value, "runtime"),

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

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

)

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

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

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

// create mappings from the unzip scala-dist zip
contentOf(tmpdir) filter {
case (file, dest) => !(dest.endsWith("MANIFEST.MF") || dest.endsWith("META-INF"))
case (_, dest) => !(dest.endsWith("MANIFEST.MF") || dest.endsWith("META-INF"))
} map {
// make unix scripts executable (heuristically...)
case (file, dest) if (dest startsWith "bin/") && !(dest endsWith ".bat") =>
Expand Down
24 changes: 12 additions & 12 deletions project/Unix.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object Unix {
// symlinks for s"/usr/bin/$script" --> s"${installTargetUnix.value}/bin/$script"
// TODO: reuse code from native packager
linuxPackageSymlinks ++= (
(mappings in Universal).value collect {
(Universal / mappings).value collect {
case (file, name) if (name startsWith "bin/") && !(name endsWith ".bat") =>
LinuxSymlink("/usr/" + name, (installTargetUnix.value / name).getAbsolutePath)
}
Expand All @@ -37,13 +37,13 @@ object Unix {
def home(name: String) = (installTargetUnix.value / name).getAbsolutePath
def docHome(name: String) = (installTargetUnixDocs.value / name).getAbsolutePath

val m = (mappings in Universal).value
val m = (Universal / mappings).value

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

Seq(
// no special treatment needed
Expand All @@ -59,38 +59,38 @@ object Unix {
(pkgMap(
(special collect { case (file, name) if name startsWith "doc/" => file -> docHome(name drop 4) }) ++
(docs map { case (file, name) => file -> docHome(name) }) :+
(((sourceDirectory in Linux).value / "copyright") -> docHome("copyright")))
(((Linux / sourceDirectory).value / "copyright") -> docHome("copyright")))
withPerms "0644").asDocs
)
},

// RPM Specific
name in Rpm := "scala",
Rpm / name := "scala",
rpmVendor := "lightbend",
rpmUrl := Some("http://github.com/scala/scala"),
rpmLicense := Some("BSD"),
rpmGroup := Some("Development/Languages"),

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

val rpm = (packageBin in Rpm).value match {
val rpm = (Rpm / packageBin).value match {
case reported if reported.exists => reported
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
(PathFinder(IO.listFiles((target in Rpm).value)) ** "*.rpm").get.find(file =>
file.getName contains (name in Rpm).value).get
(PathFinder(IO.listFiles((Rpm / target).value)) ** "*.rpm").get.find(file =>
file.getName contains (Rpm / name).value).get
}

IO.copyFile(rpm, simplified)
simplified
},

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

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

Expand Down
6 changes: 3 additions & 3 deletions project/Versioning.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import com.typesafe.sbt.SbtNativePackager.{Windows, Debian, Rpm}

object Versioning {
def settings: Seq[Setting[_]] = Seq(
version in Windows := makeWindowsVersion(version.value),
version in Debian := toDebianVersion((version in Windows).value),
version in Rpm := toRpmVersion((version in Windows).value))
Windows / version := makeWindowsVersion(version.value),
Debian / version := toDebianVersion((Windows / version).value),
Rpm / version := toRpmVersion((Windows / version).value))

private def rpmBuild(version:String): String = version split "\\." match {
case Array(_,_,_, b) => b
Expand Down
16 changes: 8 additions & 8 deletions project/Wix.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ import WixHelper.{generateComponentsAndDirectoryXml, cleanFileName}
object Wix {
// Windows installer configuration
def settings: Seq[Setting[_]] = Seq(
mappings in Windows := (mappings in Universal).value,
// distributionFiles in Windows += (packageMsi in Windows).value,
Windows / mappings := (Universal / mappings).value,
// Windows / distributionFiles += (Windows / packageMsi).value,

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

wixProductConfig := makeProductConfig((stagingDirectory in Universal).value, (stagingDirectory in UniversalDocs).value),
wixProductConfig := makeProductConfig((Universal / stagingDirectory).value, (UniversalDocs / stagingDirectory).value),
wixProductConfig := (wixProductConfig
dependsOn (stage in Universal)
dependsOn (stage in UniversalDocs)).value,
dependsOn (Universal / stage)
dependsOn (UniversalDocs / stage)).value,

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

IO.copyFile((packageBin in Windows).value, versioned)
IO.copyFile((Windows / packageBin).value, versioned)
versioned
}
)
Expand All @@ -39,7 +39,7 @@ object Wix {
// enable -Xfatal-warnings again in scalacOptions in project/plugins.sbt
val (bin, binDirXml0) = generateComponentsAndDirectoryXml(stage / "bin")
val (doc, docDirXml) = generateComponentsAndDirectoryXml(stage / "doc", "doc_")
val (lib, libDirXml) = generateComponentsAndDirectoryXml(stage / "lib")
val (lib, libDirXml) = generateComponentsAndDirectoryXml(stage / "lib", "lib_")
val (api, apiDirXml) = generateComponentsAndDirectoryXml(stageApi / "api", "api_")

// add component that adds bin folder to path
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.18
sbt.version=1.5.4
14 changes: 7 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
scalacOptions ++= Seq("-deprecation", "-feature", "-Xlint")
scalacOptions ++= Seq("-deprecation", "-feature", "-Xlint:_,-unused")

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

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

// git plugin
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1")