diff --git a/.github/workflows/build-msi.yml b/.github/workflows/build-msi.yml new file mode 100644 index 000000000000..8e3ac5eeb78b --- /dev/null +++ b/.github/workflows/build-msi.yml @@ -0,0 +1,36 @@ +################################################################################################### +### THIS IS A REUSABLE WORKFLOW TO BUILD SCALA MSI ### +### HOW TO USE: ### +### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ### +### - IT WILL UPLOAD TO GITHUB THE MSI FILE FOR SCALA UNDER THE 'scala.msi' NAME ### +### ### +### NOTE: ### +### - WE SHOULD BUILD SCALA USING JAVA 8 ### +################################################################################################### + +name: Build the MSI Package + +on: + workflow_call: + +env: + # NECESSARY FLAG TO CORRECTLY CONFIGURE THE VERSION FOR SCALA + RELEASEBUILD: yes + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: '8' + cache: 'sbt' + - name: Build MSI package + run: sbt 'dist-win-x86_64/Windows/packageBin' + - name: Upload MSI Artifact + uses: actions/upload-artifact@v4 + with: + name: scala.msi + path: ./dist/win-x86_64/target/windows/scala.msi diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2747830fb7d6..74c4741c1ab4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,8 +87,8 @@ jobs: run: cp -vf .github/workflows/repositories /root/.sbt/ ; true - name: Test - # DON'T add dist/pack! - # Adding dist/pack bootstraps the compiler + # DON'T add dist/Universal/stage! + # Adding dist/Universal/stage bootstraps the compiler # which undermines the point of these tests: # to quickly run the tests without the cost of bootstrapping # and also to run tests when the compiler doesn't bootstrap @@ -231,7 +231,7 @@ jobs: shell: cmd - name: build binary - run: sbt "dist-win-x86_64/pack" & bash -version + run: sbt "dist-win-x86_64/Universal/stage" & bash -version shell: cmd - name: cygwin tests @@ -271,7 +271,7 @@ jobs: uses: actions/checkout@v4 - name: build binary - run: sbt "dist-win-x86_64/pack" + run: sbt "dist-win-x86_64/Universal/stage" shell: cmd - name: Test @@ -1008,3 +1008,8 @@ jobs: WORKFLOW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} with: filename: .github/workflows/issue_nightly_failed.md + + build-msi-package: + uses: ./.github/workflows/build-msi.yml + if : github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_msi]') + # TODO: ADD A JOB THAT DEPENDS ON THIS TO TEST THE MSI diff --git a/.github/workflows/launchers.yml b/.github/workflows/launchers.yml index 818e3b72b06b..036b4f2966e8 100644 --- a/.github/workflows/launchers.yml +++ b/.github/workflows/launchers.yml @@ -90,7 +90,7 @@ jobs: distribution: 'temurin' cache: 'sbt' - name: Build the launcher command - run: sbt "dist-win-x86_64/pack" + run: sbt "dist-win-x86_64/Universal/stage" - name: Run the launcher command tests run: './project/scripts/native-integration/winTests.bat' shell: cmd diff --git a/README.md b/README.md index 7a2bda3f8073..7410c914a898 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ To try it in your project see also the [Getting Started User Guide](https://docs Building a Local Distribution ============================= -1. `sbt dist/packArchive` +1. `sbt dist/Universal/packageBin` 2. Find the newly-built distributions in `dist/target/` Code of Conduct diff --git a/bin/common b/bin/common index 37b2ebd1ff93..ad179412f590 100755 --- a/bin/common +++ b/bin/common @@ -13,14 +13,14 @@ shift # Mutates $@ by deleting the first element ($1) source "$ROOT/bin/common-platform" # Marker file used to obtain the date of latest call to sbt-back -version="$ROOT/$DIST_DIR/target/pack/VERSION" +version="$ROOT/$DIST_DIR/target/universal/stage/VERSION" # Create the target if absent or if file changed in ROOT/compiler new_files="$(find "$ROOT/compiler" \( -iname "*.scala" -o -iname "*.java" \) -newer "$version" 2> /dev/null)" if [ ! -f "$version" ] || [ ! -z "$new_files" ]; then echo "Building Dotty..." - (cd $ROOT && sbt "$DIST_PROJECT/pack") + (cd $ROOT && sbt "$DIST_PROJECT/Universal/stage") fi -"$ROOT/$DIST_DIR/target/pack/bin/$target" "$@" +"$ROOT/$DIST_DIR/target/universal/stage/bin/$target" "$@" diff --git a/compiler/test/dotty/tools/scripting/ClasspathTests.scala b/compiler/test/dotty/tools/scripting/ClasspathTests.scala index a946e509aeb3..0244e208af3c 100755 --- a/compiler/test/dotty/tools/scripting/ClasspathTests.scala +++ b/compiler/test/dotty/tools/scripting/ClasspathTests.scala @@ -67,7 +67,7 @@ class ClasspathTests: (hashbangJars.toSet -- packlibJars.toSet , "only in hashbang classpath") } // verify that the script hasbang classpath setting was effective at supplementing the classpath - // (a minimal subset of jars below dist*/target/pack/lib are always be in the classpath) + // (a minimal subset of jars below dist*/target/universal/stage/lib are always be in the classpath) val missingClasspathEntries = if hashbangClasspathJars.size != packlibJars.size then printf("packlib dir [%s]\n", packlibDir) printf("hashbangClasspathJars: %s\n", hashbangJars.map { _.relpath.norm }.mkString("\n ", "\n ", "")) diff --git a/compiler/test/dotty/tools/scripting/ScriptTestEnv.scala b/compiler/test/dotty/tools/scripting/ScriptTestEnv.scala index dd1cc04bb58a..771c3ba14af0 100644 --- a/compiler/test/dotty/tools/scripting/ScriptTestEnv.scala +++ b/compiler/test/dotty/tools/scripting/ScriptTestEnv.scala @@ -16,7 +16,7 @@ import scala.jdk.CollectionConverters.* /** * Common Code for supporting scripting tests. * To override the path to the bash executable, set TEST_BASH= - * To specify where `dist[*]/target/pack/bin` resides, set TEST_CWD= + * To specify where `dist[*]/target/universal/stage/bin` resides, set TEST_CWD= * Test scripts run in a bash env, so paths are converted to forward slash via .norm. */ object ScriptTestEnv { @@ -48,7 +48,7 @@ object ScriptTestEnv { } lazy val nativePackDir: Option[String] = { - def nativeDir(os: String, arch: String) = Some(s"dist/$os-$arch/target/pack") + def nativeDir(os: String, arch: String) = Some(s"dist/$os-$arch/target/universal/stage") def nativeOs(os: String) = archNorm match case arch @ ("aarch64" | "x86_64") => nativeDir(os, arch) case _ => None @@ -61,7 +61,7 @@ object ScriptTestEnv { def jvmPackDir() = println("warning: unknown OS architecture combination, defaulting to JVM launcher.") - "dist/target/pack" + "dist/target/universal/stage" def packDir: String = nativePackDir.getOrElse(jvmPackDir()) @@ -302,7 +302,7 @@ object ScriptTestEnv { // use optional TEST_BASH if defined, otherwise, bash must be in PATH // envScalaHome is: - // dist[*]/target/pack, if present + // dist[*]/target/universal/stage, if present // else, SCALA_HOME if defined // else, not defined lazy val envScalaHome = diff --git a/dist/LICENSE.rtf b/dist/LICENSE.rtf new file mode 100644 index 000000000000..c2c7feee2921 --- /dev/null +++ b/dist/LICENSE.rtf @@ -0,0 +1,41 @@ +{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033 +{\fonttbl{\f0\fswiss\fcharset0 Arial;}} +{\*\generator Riched20 10.0.18362}\viewkind4\uc1 +\pard\sa200\sl276\slmult1\b\f0\fs32 Apache License\par +\b0\fs28 Version 2.0, January 2004\par +\ul http://www.apache.org/licenses/\ulnone\par +\pard\sa200\sl276\slmult1\b\fs24 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\par +\pard\sa200\sl276\slmult1\b0\fs20 1. Definitions.\par +\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 + "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.\par + "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 + "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.\par + "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.\par + "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 + "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 + "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 + "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 + "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 +\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 +\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 +\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 + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and\par + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and\par + (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 + (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 + 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 +\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 +\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 +\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 +\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 +\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 +\pard\sa200\sl276\slmult1\qc\b END OF TERMS AND CONDITIONS\par +\pard\sa200\sl276\slmult1\b0\fs20 APPENDIX: How to apply the Apache License to your work.\par +\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 + Copyright [yyyy] [name of copyright owner]\par + Licensed under the Apache License, Version 2.0 (the "License");\par + you may not use this file except in compliance with the License.\par + You may obtain a copy of the License at\par +\pard\sa200\sl276\slmult1\li720 \ul http://www.apache.org/licenses/LICENSE-2.0\ulnone\par +\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 +} diff --git a/pkgs/msi/README.md b/pkgs/msi/README.md new file mode 100644 index 000000000000..7904ef383277 --- /dev/null +++ b/pkgs/msi/README.md @@ -0,0 +1,9 @@ + +## Important information + +- We can only build `msi` packages with stable version number (no RCs, nor Nightlies). +Example of the error message when building with an RC + +``` +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 +``` diff --git a/project/Build.scala b/project/Build.scala index 54b4a6bf7801..09080bba370d 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1,27 +1,31 @@ import java.io.File import java.nio.file._ - import Process._ import Modes._ import ScaladocGeneration._ import com.jsuereth.sbtpgp.PgpKeys -import sbt.Keys._ -import sbt._ +import sbt.Keys.* +import sbt.* import complete.DefaultParsers._ import pl.project13.scala.sbt.JmhPlugin import pl.project13.scala.sbt.JmhPlugin.JmhKeys.Jmh +import com.typesafe.sbt.packager.Keys._ +import com.typesafe.sbt.packager.MappingsHelper.directory +import com.typesafe.sbt.packager.universal.UniversalPlugin +import com.typesafe.sbt.packager.universal.UniversalPlugin.autoImport.Universal +import com.typesafe.sbt.packager.windows.WindowsPlugin +import com.typesafe.sbt.packager.windows.WindowsPlugin.autoImport.Windows import sbt.Package.ManifestAttributes import sbt.PublishBinPlugin.autoImport._ import dotty.tools.sbtplugin.RepublishPlugin import dotty.tools.sbtplugin.RepublishPlugin.autoImport._ import sbt.plugins.SbtPlugin import sbt.ScriptedPlugin.autoImport._ -import xerial.sbt.pack.PackPlugin -import xerial.sbt.pack.PackPlugin.autoImport._ import xerial.sbt.Sonatype.autoImport._ import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport._ import org.scalajs.sbtplugin.ScalaJSPlugin import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ + import sbtbuildinfo.BuildInfoPlugin import sbtbuildinfo.BuildInfoPlugin.autoImport._ import sbttastymima.TastyMiMaPlugin @@ -88,7 +92,9 @@ object Build { val referenceVersion = "3.4.2-RC1" - val baseVersion = "3.6.0-RC1" + val baseVersion = "3.6.0" + // Will be required by some automation later + val prereleaseVersion = s"$baseVersion-RC1" // LTS or Next val versionLine = "Next" @@ -169,9 +175,9 @@ object Build { if (isRelease) baseVersion else if (isNightly) - baseVersion + "-bin-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY" + baseVersion + "-RC1-bin-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY" else - baseVersion + "-bin-SNAPSHOT" + baseVersion + "-RC1-bin-SNAPSHOT" } val dottyNonBootstrappedVersion = { // Make sure sbt always computes the scalaBinaryVersion correctly @@ -2128,25 +2134,27 @@ object Build { ) lazy val commonDistSettings = Seq( - packMain := Map(), publishArtifact := false, - packGenerateMakefile := false, republishRepo := target.value / "republish", - packResourceDir += (republishRepo.value / "bin" -> "bin"), - packResourceDir += (republishRepo.value / "maven2" -> "maven2"), - packResourceDir += (republishRepo.value / "lib" -> "lib"), - republishCommandLibs += - ("scala" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core")), - republishCommandLibs += - ("with_compiler" -> List("scala3-staging", "scala3-tasty-inspector", "^!scala3-interfaces", "^!scala3-compiler", "^!scala3-library", "^!tasty-core")), - republishCommandLibs += - ("scaladoc" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core", "scala3-tasty-inspector", "scaladoc")), - Compile / pack := republishPack.value, + Universal / packageName := packageName.value, + // ======== + Universal / stage := (Universal / stage).dependsOn(republish).value, + Universal / packageBin := (Universal / packageBin).dependsOn(republish).value, + Universal / packageZipTarball := (Universal / packageZipTarball).dependsOn(republish).value, + // ======== + Universal / mappings ++= directory(republishRepo.value / "bin"), + Universal / mappings ++= directory(republishRepo.value / "maven2"), + Universal / mappings ++= directory(republishRepo.value / "lib"), + Universal / mappings += (republishRepo.value / "VERSION") -> "VERSION", + // ======== + republishCommandLibs += ("scala" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core")), + republishCommandLibs += ("with_compiler" -> List("scala3-staging", "scala3-tasty-inspector", "^!scala3-interfaces", "^!scala3-compiler", "^!scala3-library", "^!tasty-core")), + republishCommandLibs += ("scaladoc" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core", "scala3-tasty-inspector", "scaladoc")), ) lazy val dist = project.asDist(Bootstrapped) + .settings(packageName := "scala3-" + dottyVersion) .settings( - packArchiveName := "scala3-" + dottyVersion, republishBinDir := baseDirectory.value / "bin", republishCoursier += ("coursier.jar" -> s"https://github.com/coursier/coursier/releases/download/v$coursierJarVersion/coursier.jar"), @@ -2155,9 +2163,9 @@ object Build { ) lazy val `dist-mac-x86_64` = project.in(file("dist/mac-x86_64")).asDist(Bootstrapped) + .settings(packageName := (dist / packageName).value + "-x86_64-apple-darwin") .settings( republishBinDir := (dist / republishBinDir).value, - packArchiveName := (dist / packArchiveName).value + "-x86_64-apple-darwin", republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides", republishFetchCoursier := (dist / republishFetchCoursier).value, republishLaunchers += @@ -2165,9 +2173,9 @@ object Build { ) lazy val `dist-mac-aarch64` = project.in(file("dist/mac-aarch64")).asDist(Bootstrapped) + .settings(packageName := (dist / packageName).value + "-aarch64-apple-darwin") .settings( republishBinDir := (dist / republishBinDir).value, - packArchiveName := (dist / packArchiveName).value + "-aarch64-apple-darwin", republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides", republishFetchCoursier := (dist / republishFetchCoursier).value, republishLaunchers += @@ -2175,21 +2183,37 @@ object Build { ) lazy val `dist-win-x86_64` = project.in(file("dist/win-x86_64")).asDist(Bootstrapped) + .enablePlugins(WindowsPlugin) // TO GENERATE THE `.msi` installer + .settings(packageName := (dist / packageName).value + "-x86_64-pc-win32") .settings( republishBinDir := (dist / republishBinDir).value, - packArchiveName := (dist / packArchiveName).value + "-x86_64-pc-win32", republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides", republishFetchCoursier := (dist / republishFetchCoursier).value, republishExtraProps += ("cli_version" -> scalaCliLauncherVersion), - mappings += (republishRepo.value / "EXTRA_PROPERTIES" -> "EXTRA_PROPERTIES"), republishLaunchers += ("scala-cli.exe" -> s"zip+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersionWindows/scala-cli-x86_64-pc-win32.zip!/scala-cli.exe") ) + .settings( + Universal / mappings += (republishRepo.value / "EXTRA_PROPERTIES" -> "EXTRA_PROPERTIES"), + ) + .settings( + Windows / name := "scala", + Windows / mappings := (Universal / mappings).value, + Windows / packageBin := (Windows / packageBin).dependsOn(republish).value, + Windows / wixFiles := (Windows / wixFiles).dependsOn(republish).value, + // Additional information: https://wixtoolset.org/docs/schema/wxs/package/ + maintainer := "The Scala Programming Language", // The displayed maintainer of the package + packageSummary := s"Scala $dottyVersion", // The displayed name of the package + packageDescription := """Installer for the Scala Programming Language""", // The displayed description of the package + wixProductId := "*", // Unique ID for each generated MSI; will change for each generated msi + wixProductUpgradeId := "3E5A1A82-CA67-4353-94FE-5BDD400AF66B", // Unique ID to identify the package; used to manage the upgrades + wixProductLicense := Some(dist.base / "LICENSE.rtf") // Link to the LICENSE to show during the installation (keep in sync with ../LICENSE) + ) lazy val `dist-linux-x86_64` = project.in(file("dist/linux-x86_64")).asDist(Bootstrapped) + .settings(packageName := (dist / packageName).value + "-x86_64-pc-linux") .settings( republishBinDir := (dist / republishBinDir).value, - packArchiveName := (dist / packArchiveName).value + "-x86_64-pc-linux", republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides", republishFetchCoursier := (dist / republishFetchCoursier).value, republishLaunchers += @@ -2197,9 +2221,9 @@ object Build { ) lazy val `dist-linux-aarch64` = project.in(file("dist/linux-aarch64")).asDist(Bootstrapped) + .settings(packageName := (dist / packageName).value + "-aarch64-pc-linux") .settings( republishBinDir := (dist / republishBinDir).value, - packArchiveName := (dist / packArchiveName).value + "-aarch64-pc-linux", republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides", republishFetchCoursier := (dist / republishFetchCoursier).value, republishLaunchers += @@ -2337,7 +2361,7 @@ object Build { settings(scala3PresentationCompilerBuildInfo) def asDist(implicit mode: Mode): Project = project. - enablePlugins(PackPlugin, RepublishPlugin). + enablePlugins(UniversalPlugin, RepublishPlugin). withCommonSettings. settings(commonDistSettings). dependsOn( @@ -2433,7 +2457,7 @@ object ScaladocConfigs { } lazy val DefaultGenerationConfig = Def.task { - def distLocation = (dist / Compile / pack).value + def distLocation = (dist / Universal / stage).value DefaultGenerationSettings.value } diff --git a/project/RepublishPlugin.scala b/project/RepublishPlugin.scala index 5611af798b33..ff469e8fda56 100644 --- a/project/RepublishPlugin.scala +++ b/project/RepublishPlugin.scala @@ -1,22 +1,18 @@ package dotty.tools.sbtplugin -import sbt._ -import xerial.sbt.pack.PackPlugin -import xerial.sbt.pack.PackPlugin.autoImport.{packResourceDir, packDir} -import sbt.Keys._ +import com.typesafe.sbt.packager.universal.UniversalPlugin +import sbt.* +import sbt.Keys.* import sbt.AutoPlugin import sbt.PublishBinPlugin -import sbt.PublishBinPlugin.autoImport._ +import sbt.PublishBinPlugin.autoImport.* import sbt.io.Using -import sbt.util.CacheImplicits._ +import sbt.util.CacheImplicits.* -import scala.collection.mutable import java.nio.file.Files - import java.nio.file.attribute.PosixFilePermission -import java.nio.file.{Files, Path} - -import scala.jdk.CollectionConverters._ +import java.nio.file.Path +import scala.jdk.CollectionConverters.* /** This local plugin provides ways of publishing a project classpath and library dependencies to * .a local repository */ @@ -53,7 +49,7 @@ object RepublishPlugin extends AutoPlugin { } override def trigger = allRequirements - override def requires = super.requires && PublishBinPlugin && PackPlugin + override def requires = super.requires && PublishBinPlugin && UniversalPlugin object autoImport { val republishProjectRefs = taskKey[Seq[ProjectRef]]("fetch the classpath deps from the project.") @@ -346,6 +342,65 @@ object RepublishPlugin extends AutoPlugin { allLaunchers.toSet } + private def generateVersionFile() = Def.task[Unit] { + import scala.util.Try + import java.time.format.DateTimeFormatterBuilder + import java.time.format.SignStyle + import java.time.temporal.ChronoField.* + import java.time.ZoneId + import java.time.Instant + import java.time.ZonedDateTime + import java.time.ZonedDateTime + import java.util.Locale + import java.util.Date + + val base: File = new File(".") // Using the working directory as base for readability + val s = streams.value + val log = s.log + val progVersion = version.value + val distDir = republishRepo.value + + def write(path: String, content: String) { + val p = distDir / path + IO.write(p, content) + } + + val humanReadableTimestampFormatter = new DateTimeFormatterBuilder() + .parseCaseInsensitive() + .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) + .appendLiteral('-') + .appendValue(MONTH_OF_YEAR, 2) + .appendLiteral('-') + .appendValue(DAY_OF_MONTH, 2) + .appendLiteral(' ') + .appendValue(HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(MINUTE_OF_HOUR, 2) + .appendLiteral(':') + .appendValue(SECOND_OF_MINUTE, 2) + .appendOffset("+HHMM", "Z") + .toFormatter(Locale.US) + + // Retrieve build time + val systemZone = ZoneId.systemDefault().normalized() + val timestamp = ZonedDateTime.ofInstant(Instant.ofEpochMilli(new Date().getTime), systemZone) + val buildTime = humanReadableTimestampFormatter.format(timestamp) + + // Check the current Git revision + val gitRevision: String = Try { + if ((base / ".git").exists()) { + log.info("[republish] Checking the git revision of the current project") + sys.process.Process("git rev-parse HEAD").!! + } else { + "unknown" + } + }.getOrElse("unknown").trim + + + // Output the version number and Git revision + write("VERSION", s"version:=${progVersion}\nrevision:=${gitRevision}\nbuildTime:=${buildTime}\n") + } + override val projectSettings: Seq[Def.Setting[_]] = Def.settings( republishCoursierDir := republishRepo.value / "coursier", republishLaunchers := Seq.empty, @@ -470,88 +525,8 @@ object RepublishPlugin extends AutoPlugin { val artifacts = republishClasspath.value val launchers = republishFetchLaunchers.value val extraProps = republishWriteExtraProps.value + val versionFile = generateVersionFile().value cacheDir }, - republishPack := { - val cacheDir = republish.value - val s = streams.value - val log = s.log - val distDir = target.value / packDir.value - val progVersion = version.value - - IO.createDirectory(distDir) - for ((path, dir) <- packResourceDir.value) { - val target = distDir / dir - IO.copyDirectory(path, target) - } - - locally { - // everything in this block is copied from sbt-pack plugin - import scala.util.Try - import java.time.format.DateTimeFormatterBuilder - import java.time.format.SignStyle - import java.time.temporal.ChronoField.* - import java.time.ZoneId - import java.time.Instant - import java.time.ZonedDateTime - import java.time.ZonedDateTime - import java.util.Locale - import java.util.Date - val base: File = new File(".") // Using the working directory as base for readability - - // Copy explicitly added dependencies - val mapped: Seq[(File, String)] = mappings.value - log.info("[republish] Copying explicit dependencies:") - val explicitDepsJars = for ((file, path) <- mapped) yield { - log.info(file.getPath) - val dest = distDir / path - IO.copyFile(file, dest, true) - dest - } - - def write(path: String, content: String) { - val p = distDir / path - IO.write(p, content) - } - - val humanReadableTimestampFormatter = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) - .appendLiteral('-') - .appendValue(MONTH_OF_YEAR, 2) - .appendLiteral('-') - .appendValue(DAY_OF_MONTH, 2) - .appendLiteral(' ') - .appendValue(HOUR_OF_DAY, 2) - .appendLiteral(':') - .appendValue(MINUTE_OF_HOUR, 2) - .appendLiteral(':') - .appendValue(SECOND_OF_MINUTE, 2) - .appendOffset("+HHMM", "Z") - .toFormatter(Locale.US) - - // Retrieve build time - val systemZone = ZoneId.systemDefault().normalized() - val timestamp = ZonedDateTime.ofInstant(Instant.ofEpochMilli(new Date().getTime), systemZone) - val buildTime = humanReadableTimestampFormatter.format(timestamp) - - // Check the current Git revision - val gitRevision: String = Try { - if ((base / ".git").exists()) { - log.info("[republish] Checking the git revision of the current project") - sys.process.Process("git rev-parse HEAD").!! - } else { - "unknown" - } - }.getOrElse("unknown").trim - - - // Output the version number and Git revision - write("VERSION", s"version:=${progVersion}\nrevision:=${gitRevision}\nbuildTime:=${buildTime}\n") - } - - - distDir - } ) } diff --git a/project/plugins.sbt b/project/plugins.sbt index 59e58007a4a0..bb0693ced132 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -12,8 +12,6 @@ addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21") addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") -addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.17") - addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.5") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") @@ -21,3 +19,5 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.2") addSbtPlugin("ch.epfl.scala" % "sbt-tasty-mima" % "1.0.0") + +addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0") diff --git a/project/scripts/bootstrappedOnlyCmdTests b/project/scripts/bootstrappedOnlyCmdTests index 11c35a7028cc..6f5c75ceb922 100755 --- a/project/scripts/bootstrappedOnlyCmdTests +++ b/project/scripts/bootstrappedOnlyCmdTests @@ -15,13 +15,13 @@ echo "testing scala.quoted.Expr.run from sbt scala" grep -qe "val a: scala.Int = 3" "$tmp" # setup for `scalac`/`scala` script tests -"$SBT" "$DIST_PROJECT/pack" +"$SBT" "$DIST_PROJECT/Universal/stage" -echo "capturing scala version from $DIST_DIR/target/pack/VERSION" -IFS=':=' read -ra versionProps < "$ROOT/$DIST_DIR/target/pack/VERSION" # temporarily set IFS to ':=' to split versionProps +echo "capturing scala version from $DIST_DIR/target/universal/stage/VERSION" +IFS=':=' read -ra versionProps < "$ROOT/$DIST_DIR/target/universal/stage/VERSION" # temporarily set IFS to ':=' to split versionProps [ ${#versionProps[@]} -eq 3 ] && \ [ ${versionProps[0]} = "version" ] && \ - [ -n ${versionProps[2]} ] || die "Expected non-empty 'version' property in $ROOT/$DIST_DIR/target/pack/VERSION" + [ -n ${versionProps[2]} ] || die "Expected non-empty 'version' property in $ROOT/$DIST_DIR/target/universal/stage/VERSION" scala_version=${versionProps[2]} # check that `scalac` compiles and `scala` runs it @@ -77,7 +77,7 @@ echo "testing sbt scalac with suspension" clear_out "$OUT" "$SBT" "scala3-compiler-bootstrapped/scalac -d $OUT tests/pos-macros/macros-in-same-project-1/Bar.scala tests/pos-macros/macros-in-same-project-1/Foo.scala" > "$tmp" -# echo ":quit" | ./$DIST_DIR/target/pack/bin/scala # not supported by CI +# echo ":quit" | ./$DIST_DIR/target/universal/stage/bin/scala # not supported by CI echo "testing ./bin/scaladoc" clear_out "$OUT1" diff --git a/project/scripts/buildScalaBinary b/project/scripts/buildScalaBinary index 7fc5275e5d8d..9451dbdd2a07 100755 --- a/project/scripts/buildScalaBinary +++ b/project/scripts/buildScalaBinary @@ -9,4 +9,4 @@ SBT="$ROOT/project/scripts/sbt" # if run on CI source "$ROOT/bin/common-platform" # build the scala/scalac/scaladoc binary, where scala is native for the current platform. -"$SBT" "$DIST_PROJECT/pack" +"$SBT" "$DIST_PROJECT/Universal/stage" diff --git a/project/scripts/cmdScaladocTests b/project/scripts/cmdScaladocTests index 06353af693f1..b54789032ad2 100755 --- a/project/scripts/cmdScaladocTests +++ b/project/scripts/cmdScaladocTests @@ -20,7 +20,7 @@ SOURCE_LINKS_REPOSITORY="scala/scala3" SOURCE_LINKS_VERSION="${GITHUB_SHA:-$DOTTY_BOOTSTRAPPED_VERSION}" "$SBT" "scaladoc/generateTestcasesDocumentation" > "$tmp" 2>&1 || echo "generated testcases project with sbt" -dist/target/pack/bin/scaladoc \ +dist/target/universal/stage/bin/scaladoc \ -d "$OUT1" \ -project "scaladoc testcases" \ -source-links:out/bootstrap/scala2-library-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/scala-library-src=github://scala/scala/v"${STDLIB_VERSION}"#src/library \ diff --git a/project/scripts/native-integration/bashTests b/project/scripts/native-integration/bashTests index 5fb77355238c..c71e81ac183b 100755 --- a/project/scripts/native-integration/bashTests +++ b/project/scripts/native-integration/bashTests @@ -19,7 +19,7 @@ die () { exit 1 } -PROG_HOME="$DIST_DIR/target/pack" +PROG_HOME="$DIST_DIR/target/universal/stage" SOURCE="$ROOT/tests/pos/HelloWorld.scala" SOURCE_VERSION="$ROOT/project/scripts/native-integration/reportScalaVersion.scala" @@ -42,7 +42,7 @@ clear_cli_dotfiles() # *---------------*/ # build the distribution -"$SBT" "$DIST_PROJECT/pack" +"$SBT" "$DIST_PROJECT/Universal/stage" SCALA_VERSION="" # iterate through lines in VERSION_SRC diff --git a/project/scripts/native-integration/winTests.bat b/project/scripts/native-integration/winTests.bat index a85b2c8c2531..18e406423ebd 100755 --- a/project/scripts/native-integration/winTests.bat +++ b/project/scripts/native-integration/winTests.bat @@ -2,7 +2,7 @@ setlocal @rem paths are relative to the root project directory -set "_PREFIX=dist\win-x86_64\target\pack" +set "_PREFIX=dist\win-x86_64\target\universal\stage" set "_SOURCE=tests\pos\HelloWorld.scala" set "_OUT_DIR=out" diff --git a/project/scripts/winCmdTests b/project/scripts/winCmdTests index fe6a43c7f68f..dbdaed218558 100644 --- a/project/scripts/winCmdTests +++ b/project/scripts/winCmdTests @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -PREFIX="dist/win-x86_64/target/pack" +PREFIX="dist/win-x86_64/target/universal/stage" SOURCE="tests/pos/HelloWorld.scala" $PREFIX/bin/scalac @project/scripts/options "$SOURCE" $PREFIX/bin/scalac -d out "$SOURCE" diff --git a/project/scripts/winCmdTests.bat b/project/scripts/winCmdTests.bat index 903f74d7ab98..097c05839205 100644 --- a/project/scripts/winCmdTests.bat +++ b/project/scripts/winCmdTests.bat @@ -2,7 +2,7 @@ setlocal @rem paths are relative to the root project directory -set "_PREFIX=dist\win-x86_64\target\pack" +set "_PREFIX=dist\win-x86_64\target\universal\stage" set "_SOURCE=tests\pos\HelloWorld.scala" set "_OUT_DIR=out" set "_SITE_DIR=_site"