Skip to content

Backport changes from 2.13 #227

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 14 commits into from
May 9, 2025
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
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Available modes:
# - `release` to build native packages and upload them to S3
# - `archive` to copy archives to chara (for scala-lang.org)
# - `archives` to copy archives to chara (for scala-lang.org)
# - `update-api` to update the scaladoc api symlinks
#
# (*) Using an `env: global: ...` section does not work because that overrides the default `env`
Expand All @@ -22,7 +22,8 @@ install:
- sudo apt-get install -y rpm

language: scala
jdk: openjdk8
# java 11+ needed for sttp
jdk: openjdk21

env:
global:
Expand Down
7 changes: 7 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all repositories in these organizations:

* [scala](https://github.com/scala)
* [scalacenter](https://github.com/scalacenter)
* [lampepfl](https://github.com/lampepfl)

are covered by the Scala Code of Conduct: https://scala-lang.org/conduct/
37 changes: 13 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
# The Scala 2.12.x Distribution
# Scala 2.12 Distribution

This project morphs the `"org.scala-lang" % "scala-dist" % $version` maven artifact
into a Scala `$version` distribution (zip, tar.gz, deb, rpm, and msi).

To build a distribution, run:

* `universal:packageBin` - Builds the universal zip installer
* `universal-docs:packageBin` - Builds the universal documentation zip
* `debian:packageBin` - Builds the Debian DEB file. *requires dpkg-deb*
* `rpm:packageBin` - Builds the yum RPM file. *requires rpmbuild*
* `windows:packageBin` - Builds the Windows MSI. *requires WiX 3.6*
* `Universal/packageBin` - Builds the universal zip installer
* `UniversalDocs/packageBin` - Builds the universal documentation zip
* `Debian/packageBin` - Builds the Debian DEB file. *requires dpkg-deb*
* `Rpm/packageBin` - Builds the yum RPM file. *requires rpmbuild*
* `Windows/packageBin` - Builds the Windows MSI. *requires WiX 3.6*

Alternatively, the `s3Upload` task's mappings are configured based on the platform
the installer is running on. On Windows, it builds the MSI; on another platform,
it'll create and upload the other packages in the above list. (Use `s3Upload::mappings` for a dry-run.)
it'll create and upload the other packages in the above list. (Use `s3Upload/mappings` for a dry-run.)

The version of Scala to package is derived from the most recent git tag,
or you can specify it using `-Dproject.version`.

This packager only works for Scala 2.11+ releases,
as earlier ones did not publish the `scala-dist` artifact to maven.

Due to limited resources, the native packages are quite rudimentary.
We welcome new maintainers!

## Legacy
If you're looking for the editor configurations that used to be in the tool-support directory, please see https://github.com/scala/scala-tool-support.
They were moved out because they no longer ship with the Scala distribution. (New maintainers are welcome on the scala-tool-support project!)

The specification also used to be in this repo -- it is now a part of the main repository over at [scala/scala](https://github.com/scala/scala/tree/2.11.x/spec).

## Windows VM

- install Windows 7 professional N 64-bit, ensure network access to GitHub
- install Oracle Java 6 JDK
- install WiX v3.6 (reboot!)
Expand All @@ -42,9 +31,9 @@ The specification also used to be in this repo -- it is now a part of the main r
- Git (path of git.exe)
- sbt launch jar

## Contributing ##
Please read the [Scala Pull Request Policy](https://github.com/scala/scala/wiki/Pull-Request-Policy)
and sign the [CLA](http://contribute.akka.io/cla/scala).
## Contributing

Please sign the [CLA](https://contribute.akka.io/contribute/cla/scala).

The branching structure mimics that of [scala/scala](https://github.com/scala/scala):
branches for 2.12.x and 2.13.x.
The branching structure mimics that of [scala/scala](https://github.com/scala/scala);
there are branches for 2.12.x and 2.13.x.
11 changes: 7 additions & 4 deletions admin/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ if ($env:APPVEYOR_FORCED_BUILD -eq 'true') {
ensureVersion
clearIvyCache
if ($env:mode -eq 'release') {
echo "Running a release for $env:version"
$repositoriesFile="$env:APPVEYOR_BUILD_FOLDER\conf\repositories"
& cmd /c "sbt ""-Dsbt.override.build.repos=true"" ""-Dsbt.repository.config=$repositoriesFile"" ""-Dproject.version=$env:version"" ""show fullResolvers"" clean update s3Upload" '2>&1'
if ($env:version -match '-bin-' -or $env:version -match '-pre-') {
& cmd /c "sbt ""-Dproject.version=$env:version"" clean update ""show s3Upload/mappings""" '2>&1'
} else {
echo "Running a release for $env:version"
& cmd /c "sbt ""-Dproject.version=$env:version"" clean update ghUpload" '2>&1'
}
checkExit
} else {
echo "Unknown mode: '$env:mode'"
Expand All @@ -47,6 +50,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
}
23 changes: 14 additions & 9 deletions admin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,20 @@ if [[ "$TRAVIS_EVENT_TYPE" == "api" ]]; then
setupSSH
. scripts/jobs/release/website/update-api
elif [[ "$mode" == "release" ]]; then
echo "Running a release for $version"
triggerMsiRelease
repositoriesFile="$TRAVIS_BUILD_DIR/conf/repositories"
# The log is too long for the travis UI, so remove ANSI codes to have a clean raw version
sbt -Dsbt.log.noformat=true \
-Dsbt.override.build.repos=true -Dsbt.repository.config="$repositoriesFile" \
-Dproject.version=$version \
"show fullResolvers" clean update s3Upload
triggerSmoketest
if [[ "$version" =~ -bin- || "$version" =~ -pre- ]]; then
# The log is too long for the travis UI, so remove ANSI codes to have a clean raw version
sbt -Dsbt.log.noformat=true \
-Dproject.version=$version \
clean update "show s3Upload/mappings"
else
echo "Running a release for $version"
# The log is too long for the travis UI, so remove ANSI codes to have a clean raw version
sbt -Dsbt.log.noformat=true \
-Dproject.version=$version \
clean update ghUpload
triggerSmoketest
fi
else
echo "Unknown build mode: '$mode'"
exit 1
Expand All @@ -107,5 +112,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
7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ branches:
- 2.12.x
- 2.13.x

image: Visual Studio 2015
image: Visual Studio 2019

environment:
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
# java 11+ needed for sttp
JAVA_HOME: C:\Program Files\Java\jdk21
AWS_ACCESS_KEY_ID:
secure: X1Ix1soRBDMtfbi8IFNPOggDP2XquhW+uKcJ+XC0kiM=
AWS_SECRET_ACCESS_KEY:
Expand All @@ -18,7 +19,7 @@ environment:
secure: nfWNfbyzNQwdg1eWHZX93XIJLoAhFOr1fR8+L86s7a3jdo/HydEZ8TyEKsPipQ+/

install:
- cmd: choco install sbt --version=1.3.2 -ia "INSTALLDIR=""C:\sbt"""
- cmd: choco install sbt --version=1.10.11 -ia "INSTALLDIR=""C:\sbt"""
- cmd: SET PATH=C:\sbt\bin;%JAVA_HOME%\bin;%PATH%

build_script:
Expand Down
69 changes: 61 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.typesafe.sbt.SbtGit._
import ScalaDist.upload
import ScalaDist.{s3Upload, ghUpload}

resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"

// so we don't require a native git install
useJGit
Expand All @@ -9,18 +10,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()
s3Upload / mappings := Seq()

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

val log = streams.value.log

(mappings in upload).value map { case (file, key) =>
(s3Upload / mappings).value map { case (file, key) =>
log.info("Uploading "+ file.getAbsolutePath() +" as "+ key)
client.putObject(new PutObjectRequest("downloads.typesafe.com", key, file))
}
}

ghUpload := {
import sttp.client3._
import _root_.io.circe._, _root_.io.circe.parser._

val log = streams.value.log
val ghRelease = s"v${(Universal / version).value}"

val token = sys.env.getOrElse("GITHUB_OAUTH_TOKEN", throw new MessageOnlyException("GITHUB_OAUTH_TOKEN missing"))

val backend = HttpURLConnectionBackend()

val rRes = basicRequest
.get(uri"https://github.com/api/repos/scala/scala/releases/tags/$ghRelease")
.header("Accept", "application/vnd.github+json")
.header("Authorization", s"Bearer $token")
.header("X-GitHub-Api-Version", "2022-11-28")
.send(backend)
val releaseId = rRes.body.flatMap(parse).getOrElse(Json.Null).hcursor.downField("id").as[Int].getOrElse(
throw new MessageOnlyException(s"Release not found: $ghRelease"))

(s3Upload / mappings).value map { case (file, _) =>
log.info(s"Uploading ${file.getAbsolutePath} as ${file.getName} to https://github.com/scala/scala/releases/tag/$ghRelease")

// https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset
val request = basicRequest
.post(uri"https://uploads.github.com/repos/scala/scala/releases/${releaseId}/assets?name=${file.getName}")
.contentType("application/octet-stream")
.header("Accept", "application/vnd.github+json")
.header("Authorization", s"Bearer $token")
.header("X-GitHub-Api-Version", "2022-11-28")
.body(file)

val response = request.send(backend)
if (response.code.code != 201)
throw new MessageOnlyException(s"Upload failed: status=${response.code}\n${response.body}")
}
}

ScalaDist.settings

Docs.settings
Expand All @@ -44,6 +87,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
8 changes: 0 additions & 8 deletions conf/repositories

This file was deleted.

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
Loading