Skip to content

Commit a212ff0

Browse files
authored
Use sbt-native-packager instead of sbt-pack (#20547)
This PR is based on #20351. The idea is to use `sbt-native-packager` instead of `sbt-pack` since it has the ability to generate `.msi` files. [test_msi]
2 parents 97a711c + a0f502e commit a212ff0

19 files changed

+235
-147
lines changed

.github/workflows/build-msi.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO BUILD SCALA MSI ###
3+
### HOW TO USE: ###
4+
### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ###
5+
### - IT WILL UPLOAD TO GITHUB THE MSI FILE FOR SCALA UNDER THE 'scala.msi' NAME ###
6+
### ###
7+
### NOTE: ###
8+
### - WE SHOULD BUILD SCALA USING JAVA 8 ###
9+
###################################################################################################
10+
11+
name: Build the MSI Package
12+
13+
on:
14+
workflow_call:
15+
16+
env:
17+
# NECESSARY FLAG TO CORRECTLY CONFIGURE THE VERSION FOR SCALA
18+
RELEASEBUILD: yes
19+
20+
jobs:
21+
build:
22+
runs-on: windows-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-java@v4
26+
with:
27+
distribution: 'adopt'
28+
java-version: '8'
29+
cache: 'sbt'
30+
- name: Build MSI package
31+
run: sbt 'dist-win-x86_64/Windows/packageBin'
32+
- name: Upload MSI Artifact
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: scala.msi
36+
path: ./dist/win-x86_64/target/windows/scala.msi

.github/workflows/ci.yaml

+9-4
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ jobs:
8787
run: cp -vf .github/workflows/repositories /root/.sbt/ ; true
8888

8989
- name: Test
90-
# DON'T add dist/pack!
91-
# Adding dist/pack bootstraps the compiler
90+
# DON'T add dist/Universal/stage!
91+
# Adding dist/Universal/stage bootstraps the compiler
9292
# which undermines the point of these tests:
9393
# to quickly run the tests without the cost of bootstrapping
9494
# and also to run tests when the compiler doesn't bootstrap
@@ -231,7 +231,7 @@ jobs:
231231
shell: cmd
232232

233233
- name: build binary
234-
run: sbt "dist-win-x86_64/pack" & bash -version
234+
run: sbt "dist-win-x86_64/Universal/stage" & bash -version
235235
shell: cmd
236236

237237
- name: cygwin tests
@@ -271,7 +271,7 @@ jobs:
271271
uses: actions/checkout@v4
272272

273273
- name: build binary
274-
run: sbt "dist-win-x86_64/pack"
274+
run: sbt "dist-win-x86_64/Universal/stage"
275275
shell: cmd
276276

277277
- name: Test
@@ -1008,3 +1008,8 @@ jobs:
10081008
WORKFLOW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
10091009
with:
10101010
filename: .github/workflows/issue_nightly_failed.md
1011+
1012+
build-msi-package:
1013+
uses: ./.github/workflows/build-msi.yml
1014+
if : github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_msi]')
1015+
# TODO: ADD A JOB THAT DEPENDS ON THIS TO TEST THE MSI

.github/workflows/launchers.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
distribution: 'temurin'
9191
cache: 'sbt'
9292
- name: Build the launcher command
93-
run: sbt "dist-win-x86_64/pack"
93+
run: sbt "dist-win-x86_64/Universal/stage"
9494
- name: Run the launcher command tests
9595
run: './project/scripts/native-integration/winTests.bat'
9696
shell: cmd

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ To try it in your project see also the [Getting Started User Guide](https://docs
1111

1212
Building a Local Distribution
1313
=============================
14-
1. `sbt dist/packArchive`
14+
1. `sbt dist/Universal/packageBin`
1515
2. Find the newly-built distributions in `dist/target/`
1616

1717
Code of Conduct

bin/common

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ shift # Mutates $@ by deleting the first element ($1)
1313
source "$ROOT/bin/common-platform"
1414

1515
# Marker file used to obtain the date of latest call to sbt-back
16-
version="$ROOT/$DIST_DIR/target/pack/VERSION"
16+
version="$ROOT/$DIST_DIR/target/universal/stage/VERSION"
1717

1818
# Create the target if absent or if file changed in ROOT/compiler
1919
new_files="$(find "$ROOT/compiler" \( -iname "*.scala" -o -iname "*.java" \) -newer "$version" 2> /dev/null)"
2020

2121
if [ ! -f "$version" ] || [ ! -z "$new_files" ]; then
2222
echo "Building Dotty..."
23-
(cd $ROOT && sbt "$DIST_PROJECT/pack")
23+
(cd $ROOT && sbt "$DIST_PROJECT/Universal/stage")
2424
fi
2525

26-
"$ROOT/$DIST_DIR/target/pack/bin/$target" "$@"
26+
"$ROOT/$DIST_DIR/target/universal/stage/bin/$target" "$@"

compiler/test/dotty/tools/scripting/ClasspathTests.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ClasspathTests:
6767
(hashbangJars.toSet -- packlibJars.toSet , "only in hashbang classpath")
6868
}
6969
// verify that the script hasbang classpath setting was effective at supplementing the classpath
70-
// (a minimal subset of jars below dist*/target/pack/lib are always be in the classpath)
70+
// (a minimal subset of jars below dist*/target/universal/stage/lib are always be in the classpath)
7171
val missingClasspathEntries = if hashbangClasspathJars.size != packlibJars.size then
7272
printf("packlib dir [%s]\n", packlibDir)
7373
printf("hashbangClasspathJars: %s\n", hashbangJars.map { _.relpath.norm }.mkString("\n ", "\n ", ""))

compiler/test/dotty/tools/scripting/ScriptTestEnv.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import scala.jdk.CollectionConverters.*
1616
/**
1717
* Common Code for supporting scripting tests.
1818
* To override the path to the bash executable, set TEST_BASH=<path-to-bash.exe>
19-
* To specify where `dist[*]/target/pack/bin` resides, set TEST_CWD=<working-directory>
19+
* To specify where `dist[*]/target/universal/stage/bin` resides, set TEST_CWD=<working-directory>
2020
* Test scripts run in a bash env, so paths are converted to forward slash via .norm.
2121
*/
2222
object ScriptTestEnv {
@@ -48,7 +48,7 @@ object ScriptTestEnv {
4848
}
4949

5050
lazy val nativePackDir: Option[String] = {
51-
def nativeDir(os: String, arch: String) = Some(s"dist/$os-$arch/target/pack")
51+
def nativeDir(os: String, arch: String) = Some(s"dist/$os-$arch/target/universal/stage")
5252
def nativeOs(os: String) = archNorm match
5353
case arch @ ("aarch64" | "x86_64") => nativeDir(os, arch)
5454
case _ => None
@@ -61,7 +61,7 @@ object ScriptTestEnv {
6161

6262
def jvmPackDir() =
6363
println("warning: unknown OS architecture combination, defaulting to JVM launcher.")
64-
"dist/target/pack"
64+
"dist/target/universal/stage"
6565

6666
def packDir: String = nativePackDir.getOrElse(jvmPackDir())
6767

@@ -302,7 +302,7 @@ object ScriptTestEnv {
302302
// use optional TEST_BASH if defined, otherwise, bash must be in PATH
303303

304304
// envScalaHome is:
305-
// dist[*]/target/pack, if present
305+
// dist[*]/target/universal/stage, if present
306306
// else, SCALA_HOME if defined
307307
// else, not defined
308308
lazy val envScalaHome =

dist/LICENSE.rtf

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033
2+
{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
3+
{\*\generator Riched20 10.0.18362}\viewkind4\uc1
4+
\pard\sa200\sl276\slmult1\b\f0\fs32 Apache License\par
5+
\b0\fs28 Version 2.0, January 2004\par
6+
\ul http://www.apache.org/licenses/\ulnone\par
7+
\pard\sa200\sl276\slmult1\b\fs24 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\par
8+
\pard\sa200\sl276\slmult1\b0\fs20 1. Definitions.\par
9+
\pard\sa200\sl276\slmult1 "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.\par
10+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.\par
11+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50\%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.\par
12+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.\par
13+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.\par
14+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.\par
15+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).\par
16+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.\par
17+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."\par
18+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.\par
19+
\pard\sa200\sl276\slmult1\b 2. Grant of Copyright License. \b0 Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.\par
20+
\pard\sa200\sl276\slmult1\b 3. Grant of Patent License. \b0 Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.\par
21+
\pard\sa200\sl276\slmult1\b 4. Redistribution. \b0 You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:\par
22+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and\par
23+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and\par
24+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and\par
25+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.\par
26+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.\par
27+
\pard\sa200\sl276\slmult1\b 5. Submission of Contributions. \b0 Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.\par
28+
\pard\sa200\sl276\slmult1\b 6. Trademarks. \b0 This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.\par
29+
\pard\sa200\sl276\slmult1\b 7. Disclaimer of Warranty. \b0 Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.\par
30+
\pard\sa200\sl276\slmult1\b 8. Limitation of Liability. \b0 In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.\par
31+
\pard\sa200\sl276\slmult1\b 9. Accepting Warranty or Additional Liability. \b0 While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.\par
32+
\pard\sa200\sl276\slmult1\qc\b END OF TERMS AND CONDITIONS\par
33+
\pard\sa200\sl276\slmult1\b0\fs20 APPENDIX: How to apply the Apache License to your work.\par
34+
\pard\sa200\sl276\slmult1 To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.\par
35+
Copyright [yyyy] [name of copyright owner]\par
36+
Licensed under the Apache License, Version 2.0 (the "License");\par
37+
you may not use this file except in compliance with the License.\par
38+
You may obtain a copy of the License at\par
39+
\pard\sa200\sl276\slmult1\li720 \ul http://www.apache.org/licenses/LICENSE-2.0\ulnone\par
40+
\pard\sa200\sl276\slmult1 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\par
41+
}

pkgs/msi/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
## Important information
3+
4+
- We can only build `msi` packages with stable version number (no RCs, nor Nightlies).
5+
Example of the error message when building with an RC
6+
7+
```
8+
error CNDL0108 : The Product/@Version attribute's value, '3.5.1-RC1', is not a valid version. Legal version values should look like 'x.x.x.x' where x is an integer from 0 to 65534
9+
```

0 commit comments

Comments
 (0)