Skip to content

Commit 406cac5

Browse files
authored
Merge pull request #227 from lrytz/merg-13
Backport changes from 2.13
2 parents 05e4dfe + 56eeaa9 commit 406cac5

19 files changed

+178
-168
lines changed

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Available modes:
88
# - `release` to build native packages and upload them to S3
9-
# - `archive` to copy archives to chara (for scala-lang.org)
9+
# - `archives` to copy archives to chara (for scala-lang.org)
1010
# - `update-api` to update the scaladoc api symlinks
1111
#
1212
# (*) Using an `env: global: ...` section does not work because that overrides the default `env`
@@ -22,7 +22,8 @@ install:
2222
- sudo apt-get install -y rpm
2323

2424
language: scala
25-
jdk: openjdk8
25+
# java 11+ needed for sttp
26+
jdk: openjdk21
2627

2728
env:
2829
global:

CODE_OF_CONDUCT.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
all repositories in these organizations:
2+
3+
* [scala](https://github.com/scala)
4+
* [scalacenter](https://github.com/scalacenter)
5+
* [lampepfl](https://github.com/lampepfl)
6+
7+
are covered by the Scala Code of Conduct: https://scala-lang.org/conduct/

README.md

+13-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
1-
# The Scala 2.12.x Distribution
1+
# Scala 2.12 Distribution
22

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

66
To build a distribution, run:
77

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

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

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

21-
This packager only works for Scala 2.11+ releases,
22-
as earlier ones did not publish the `scala-dist` artifact to maven.
23-
24-
Due to limited resources, the native packages are quite rudimentary.
25-
We welcome new maintainers!
26-
27-
## Legacy
28-
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.
29-
They were moved out because they no longer ship with the Scala distribution. (New maintainers are welcome on the scala-tool-support project!)
30-
31-
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).
32-
3321
## Windows VM
22+
3423
- install Windows 7 professional N 64-bit, ensure network access to GitHub
3524
- install Oracle Java 6 JDK
3625
- install WiX v3.6 (reboot!)
@@ -42,9 +31,9 @@ The specification also used to be in this repo -- it is now a part of the main r
4231
- Git (path of git.exe)
4332
- sbt launch jar
4433

45-
## Contributing ##
46-
Please read the [Scala Pull Request Policy](https://github.com/scala/scala/wiki/Pull-Request-Policy)
47-
and sign the [CLA](http://contribute.akka.io/cla/scala).
34+
## Contributing
35+
36+
Please sign the [CLA](https://contribute.akka.io/contribute/cla/scala).
4837

49-
The branching structure mimics that of [scala/scala](https://github.com/scala/scala):
50-
branches for 2.12.x and 2.13.x.
38+
The branching structure mimics that of [scala/scala](https://github.com/scala/scala);
39+
there are branches for 2.12.x and 2.13.x.

admin/build.ps1

+7-4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ if ($env:APPVEYOR_FORCED_BUILD -eq 'true') {
3434
ensureVersion
3535
clearIvyCache
3636
if ($env:mode -eq 'release') {
37-
echo "Running a release for $env:version"
38-
$repositoriesFile="$env:APPVEYOR_BUILD_FOLDER\conf\repositories"
39-
& cmd /c "sbt ""-Dsbt.override.build.repos=true"" ""-Dsbt.repository.config=$repositoriesFile"" ""-Dproject.version=$env:version"" ""show fullResolvers"" clean update s3Upload" '2>&1'
37+
if ($env:version -match '-bin-' -or $env:version -match '-pre-') {
38+
& cmd /c "sbt ""-Dproject.version=$env:version"" clean update ""show s3Upload/mappings""" '2>&1'
39+
} else {
40+
echo "Running a release for $env:version"
41+
& cmd /c "sbt ""-Dproject.version=$env:version"" clean update ghUpload" '2>&1'
42+
}
4043
checkExit
4144
} else {
4245
echo "Unknown mode: '$env:mode'"
@@ -47,6 +50,6 @@ if ($env:APPVEYOR_FORCED_BUILD -eq 'true') {
4750
clearIvyCache
4851
# By default, test building the packages (but don't uplaod)
4952
# 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'
53+
& cmd /c "sbt ""-Dproject.version=$env:version"" ""show s3Upload/mappings""" '2>&1'
5154
checkExit
5255
}

admin/build.sh

+14-9
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,20 @@ if [[ "$TRAVIS_EVENT_TYPE" == "api" ]]; then
9090
setupSSH
9191
. scripts/jobs/release/website/update-api
9292
elif [[ "$mode" == "release" ]]; then
93-
echo "Running a release for $version"
9493
triggerMsiRelease
95-
repositoriesFile="$TRAVIS_BUILD_DIR/conf/repositories"
96-
# The log is too long for the travis UI, so remove ANSI codes to have a clean raw version
97-
sbt -Dsbt.log.noformat=true \
98-
-Dsbt.override.build.repos=true -Dsbt.repository.config="$repositoriesFile" \
99-
-Dproject.version=$version \
100-
"show fullResolvers" clean update s3Upload
101-
triggerSmoketest
94+
if [[ "$version" =~ -bin- || "$version" =~ -pre- ]]; then
95+
# The log is too long for the travis UI, so remove ANSI codes to have a clean raw version
96+
sbt -Dsbt.log.noformat=true \
97+
-Dproject.version=$version \
98+
clean update "show s3Upload/mappings"
99+
else
100+
echo "Running a release for $version"
101+
# The log is too long for the travis UI, so remove ANSI codes to have a clean raw version
102+
sbt -Dsbt.log.noformat=true \
103+
-Dproject.version=$version \
104+
clean update ghUpload
105+
triggerSmoketest
106+
fi
102107
else
103108
echo "Unknown build mode: '$mode'"
104109
exit 1
@@ -107,5 +112,5 @@ else
107112
version="2.12.4"
108113
clearIvyCache
109114
# By default, test building the packages (but don't uplaod)
110-
sbt -Dproject.version=$version "show s3Upload::mappings"
115+
sbt -Dproject.version=$version "show s3Upload/mappings"
111116
fi

appveyor.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ branches:
66
- 2.12.x
77
- 2.13.x
88

9-
image: Visual Studio 2015
9+
image: Visual Studio 2019
1010

1111
environment:
12-
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
12+
# java 11+ needed for sttp
13+
JAVA_HOME: C:\Program Files\Java\jdk21
1314
AWS_ACCESS_KEY_ID:
1415
secure: X1Ix1soRBDMtfbi8IFNPOggDP2XquhW+uKcJ+XC0kiM=
1516
AWS_SECRET_ACCESS_KEY:
@@ -18,7 +19,7 @@ environment:
1819
secure: nfWNfbyzNQwdg1eWHZX93XIJLoAhFOr1fR8+L86s7a3jdo/HydEZ8TyEKsPipQ+/
1920

2021
install:
21-
- cmd: choco install sbt --version=1.3.2 -ia "INSTALLDIR=""C:\sbt"""
22+
- cmd: choco install sbt --version=1.10.11 -ia "INSTALLDIR=""C:\sbt"""
2223
- cmd: SET PATH=C:\sbt\bin;%JAVA_HOME%\bin;%PATH%
2324

2425
build_script:

build.sbt

+61-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import com.typesafe.sbt.SbtGit._
2-
import ScalaDist.upload
1+
import ScalaDist.{s3Upload, ghUpload}
2+
3+
resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
34

45
// so we don't require a native git install
56
useJGit
@@ -9,18 +10,23 @@ useJGit
910
// For testing, the version may be overridden with -Dproject.version=...
1011
versionWithGit
1112

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

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

19-
mappings in upload := Seq()
27+
s3Upload / mappings := Seq()
2028

21-
upload := {
22-
import com.amazonaws.{ClientConfiguration, Protocol}
23-
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
29+
s3Upload := {
2430
import com.amazonaws.services.s3.AmazonS3ClientBuilder
2531
import com.amazonaws.services.s3.model.PutObjectRequest
2632
import com.amazonaws.regions.Regions
@@ -29,13 +35,50 @@ upload := {
2935
val client = AmazonS3ClientBuilder.standard.withRegion(Regions.US_EAST_1).build
3036

3137
val log = streams.value.log
32-
33-
(mappings in upload).value map { case (file, key) =>
38+
(s3Upload / mappings).value map { case (file, key) =>
3439
log.info("Uploading "+ file.getAbsolutePath() +" as "+ key)
3540
client.putObject(new PutObjectRequest("downloads.typesafe.com", key, file))
3641
}
3742
}
3843

44+
ghUpload := {
45+
import sttp.client3._
46+
import _root_.io.circe._, _root_.io.circe.parser._
47+
48+
val log = streams.value.log
49+
val ghRelease = s"v${(Universal / version).value}"
50+
51+
val token = sys.env.getOrElse("GITHUB_OAUTH_TOKEN", throw new MessageOnlyException("GITHUB_OAUTH_TOKEN missing"))
52+
53+
val backend = HttpURLConnectionBackend()
54+
55+
val rRes = basicRequest
56+
.get(uri"https://api.github.com/repos/scala/scala/releases/tags/$ghRelease")
57+
.header("Accept", "application/vnd.github+json")
58+
.header("Authorization", s"Bearer $token")
59+
.header("X-GitHub-Api-Version", "2022-11-28")
60+
.send(backend)
61+
val releaseId = rRes.body.flatMap(parse).getOrElse(Json.Null).hcursor.downField("id").as[Int].getOrElse(
62+
throw new MessageOnlyException(s"Release not found: $ghRelease"))
63+
64+
(s3Upload / mappings).value map { case (file, _) =>
65+
log.info(s"Uploading ${file.getAbsolutePath} as ${file.getName} to https://github.com/scala/scala/releases/tag/$ghRelease")
66+
67+
// https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset
68+
val request = basicRequest
69+
.post(uri"https://uploads.github.com/repos/scala/scala/releases/${releaseId}/assets?name=${file.getName}")
70+
.contentType("application/octet-stream")
71+
.header("Accept", "application/vnd.github+json")
72+
.header("Authorization", s"Bearer $token")
73+
.header("X-GitHub-Api-Version", "2022-11-28")
74+
.body(file)
75+
76+
val response = request.send(backend)
77+
if (response.code.code != 201)
78+
throw new MessageOnlyException(s"Upload failed: status=${response.code}\n${response.body}")
79+
}
80+
}
81+
3982
ScalaDist.settings
4083

4184
Docs.settings
@@ -44,6 +87,16 @@ ScalaDist.platformSettings
4487

4588
enablePlugins(UniversalPlugin, RpmPlugin, JDebPackaging, WindowsPlugin)
4689

90+
// TODO This silences a warning I don't understand.
91+
//
92+
// * scala-dist / Universal / configuration
93+
// +- /Users/jz/code/scala-dist/build.sbt:35
94+
// * scala-dist / Universal-docs / configuration
95+
// +- /Users/jz/code/scala-dist/build.sbt:35
96+
// * scala-dist / Universal-src / configuration
97+
// +- /Users/jz/code/scala-dist/build.sbt:35
98+
Global / excludeLintKeys += configuration
99+
47100
// resolvers += "local" at "file:///e:/.m2/repository"
48101
// resolvers += Resolver.mavenLocal
49102
// to test, run e.g., stage, or windows:packageBin, show s3Upload::mappings

conf/repositories

-8
This file was deleted.

project/Docs.scala

+5-5
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
}

0 commit comments

Comments
 (0)