Skip to content

Latest commit

 

History

History

scala3-examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

WiX examples with Scala 3 distribution

WiX Toolset Directory scala3-examples\ contains WiX examples written by ourself to create a Scala 3 Windows installer.
This work is mainly motivated by issue 12502 (Distribute releases as .deb and .msi) of the Dotty project.
Follow this link if you're looking for the Scala 2 Windows installer.

The WiX examples presented in the following sections

  • share the same project organisation as the WiX examples from page myexamples/README.md.
  • differ in several respects from the WiX examples from page myexamples/README.md, in particular :
    • we download and extract the application files from the Zip archive (e.g. scala3-3.3.0.zip) if they are not yet present in directory app\.
    • we do not maintain a source file Fragments.wxs in directory src\; the file target\src_gen\Fragments.wxs 1 ‒ which contains a list of links to the application files ‒ is generated on each run with GUID values inserted on the fly.

The Scala 3 Windows installer behaves in 3 different ways when it detects a Scala 3 installation on the target machine (see WiX element MajorUpgrade) :

  • if the version to be installed is newer than the version found on the machine then the Windows installer goes on (it removes the old version and install the new one).
  • if the version to be installed is older than the version found on the machine then the Windows installer does exit.
  • if the version to be installed is the same as the version found on the machine then the user is asked for a change, repair or remove operation.

Visit our Releases page to download and try the latest self-signed Scala 3 Windows installer. The document SECURITY.md provides more information about self-signed certificates.

Scala3First Example

Scala3First 2 is our first iteration to create a Windows installer (aka. .msi file) for the Scala 3 software distribution.

The project directory is organized as follows :

> cd
Y:\scala3-examples\Scala3First
 
> tree /f . | findstr /v /b [a-z]build.bat
├───app
│   ├───scala3-3.0.2
│   │       (files extracted from scala3-3.0.2.zip)
│   └───scala3-3.1.0(files extracted from scala3-3.1.0.zip)
└───srcScala3First.wxs
    └───resources
            favicon.ico
            Fragments.xslt
            repl.bat

🔎 During installation the batch file src\resources\repl.bat is added to the bin\ directory; the goal of that wrapper script is to look for a Java installation 3 before starting the Scala 3 REPL (Scala commands require either variable JAVA_HOME or variable JAVACMD to be defined).

Command build link 4 generates the Scala 3 Windows installer with file name scala3-3.3.0.msi.

> build clean link && tree /f target | findstr /v /b [a-z]
│   candle_opts.txt
│   candle_sources.txt
│   Fragments.wixobj
│   light_opts.txt
│   replace.ps1
│   scala3-3.1.0.msi
│   scala3-3.1.0.msi.md5
│   scala3-3.1.0.msi.sha256
│   scala3-3.1.0.wixpdb
│   Scala3First.wixobj
├───resources
│       favicon.ico
│       repl.bat
└───src_gen
        Fragments-cid.txt   (component identifier list)
        Fragments.wxs
        Scala3First.wxs

🔎 The above file target\src_gen\Scala3First.wxs contains the real GUIDs instead of the variables names specified in source file src\Scala3First.wxs.

Figures 1.1 to 1.5 below illustrate the updated user environment after the successful execution of the Scala 3 Windows installer.

Scala 3 directory
Figure 1.1 - Scala 3 directory
(Program Files folder).
 
Scala 3 shortcuts
Figure 1.2 - Scala 3 shortcuts
(Start Menu folder).
Start Menu
Figure 1.3 - Scala 3 shorcuts
(Start Menu folder).
 
Scala 3 REPL
Figure 1.4 - Scala 3 REPL
(JAVA_HOME defined).
Scala 3 REPL
Figure 1.5 - Scala 3 REPL
(JAVA_HOME undefined).
 
Uninstall Scala 3
Figure 1.6 - Uninstall Scala 3
(Settings window).

Scala3UI Example

Scala3UI 2 adds customizations to the graphical user interface of the Scala 3 Windows installer. Concretely, we define two images to customize the dialog windows of the Windows installer, ie. :

  • image Dialog.bmp appears in the Welcome and Completed dialog windows.
  • image BannerTop.bmp appears at the top of the other dialog windows.

The project directory is organized as follows :

> cd
Y:\scala3-examples\Scala3UI
 
> tree /f . | findstr /v /b [a-z]build.bat
├───app
│   ├───scala3-3.0.2
│   │       (files extracted from scala3-3.0.2.zip)
│   └───scala3-3.1.0(files extracted from scala3-3.1.0.zip)
│   └───scala3-3.3.0(files extracted from scala3-3.3.0.zip)
└───srcIncludes.wxiScala3UI.wxs
    └───resources
            BannerTop.bmp
            Dialog.bmp
            logo.svg
            favicon.ico
            Fragments.xslt
            LICENSE.rtf
            network.ico
            repl.bat

Figures 2.1 to 2.4 below illustrate the dialog windows of the Scala 3 Windows installer while figures 2.5 and 2.6 show the updated user environment after the successful execution of the Windows installer.

Welcome
Figure 2.1 - Welcome
(Scala 3 installer).
 
EULA
Figure 2.2 - EULA
(Scala 3 installer).
Custom Setup
Figure 2.3 - Destination folder
(Scala 3 installer).
 
Completed
Figure 2.4 - Completed installation
(Scala 3 installer).
Scala 3 directory
Figure 2.5 - Scala 3 directory
(Program Files folder).
 
Scala 3 shortcuts
Figure 2.6 - Scala 3 shortcuts
(Start Menu folder).

Scala3Localized Example

Project Scala3Localized 2 adds language localization to the WiX source files of the Scala 3 Windows installer.

This project contains the additional directory src\localizations\ with 4 WiX localization files:

> cd
Y:\scala3-examples\Scala3Localized
 
> tree /f . | findstr /v /b [a-z]build.bat
├───app
│   ├───scala3-3.0.2
│   │       (files extracted from scala3-3.0.2.zip)
│   └───scala3-3.1.0(files extracted from scala3-3.1.0.zip)
│   └───scala3-3.3.0(files extracted from scala3-3.3.0.zip)
└───srcIncludes.wxiScala3Localized.wxs
    ├───localizationsde-DE.wxlen-US.wxlfr-Fr.wxlsv-SE.wxl
    └───resources
            BannerTop.bmp
            Dialog.bmp
            logo.svg
            favicon.ico
            LICENSE.rtf
            network.ico
            repl.bat

Command build link generates a separate MSI file for each language localization, e.g. scala3-3.1.0-sv-SE.msi is the swedish version of the Scala 3 Windows installer.

> build clean link && dir /b /a-d target
candle_opts.txt
candle_sources.txt
Fragments.wixobj
light_opts.txt
replace.ps1
scala3-3.1.0.msi
scala3-3.1.0.msi.md5
scala3-3.1.0.msi.sha256
scala3-3.1.0.wixpdb
scala3-3.1.0_de-DE.msi
scala3-3.1.0_de-DE.msi.md5
scala3-3.1.0_de-DE.msi.sha256
scala3-3.1.0_de-DE.wixpdb
scala3-3.1.0_fr-FR.msi
scala3-3.1.0_fr-FR.msi.md5
scala3-3.1.0_fr-FR.msi.sha256
scala3-3.1.0_fr-FR.wixpdb
scala3-3.1.0_sv-SE.msi
scala3-3.1.0_sv-SE.msi.md5
scala3-3.1.0_sv-SE.msi.sha256
scala3-3.1.0_sv-SE.wixpdb
Scala3Localized.wixobj

Figures 3.1 to 3.4 below illustrate the "Welcome" dialog window of the Scala 3 Windows installer in english, german, french and swedish.

Welcome
Figure 3.1 - Welcome
(english version).
 
Willkommen
Figure 3.2 - Willkommen
(german version).
Bienvenue
Figure 3.3 - Bienvenue
(french version).
 
Välkommen
Figure 3.4 - Välkommen
(swedish version).

Scala3Features Example

Scala3Features 2 adds feature customization to the Scala 3 Windows installer.

Concretely the main Feature element of the WiX source file Scala3Features.wxs contains one mandatory Feature element and 3 optional Feature elements (attribute Absent="allow"):

<Feature Id="AppComponents" Absent="disallow" ...>
  <Feature Id="AppCore" Absent="disallow" ...>
    <ComponentGroupRef Id='PackFiles' />
    <ComponentRef Id="ApplicationShortcuts" />
  </Feature>
  <Feature Id="ScalaHome" Absent="allow" ...>
    <ComponentRef Id="ApplicationScalaHome" />
  </Feature>
  <Feature Id="UpdatePath" Absent="allow" ...>
    <ComponentRef Id="ApplicationUpdatePath" />
  </Feature>
  <Feature Id="AppDocumentation" Absent="allow" ...>
    <ComponentGroupRef Id="APIFiles" />
    <ComponentRef Id="DocumentationShortcuts" />
  </Feature>
</Feature>

As before command build link generates the MSI file scala3-3.1.0.msi with the two checksum files scala3-3.1.0.msi.md5 and scala3-3.1.0.msi.sha256.

> build -verbose clean link
Delete directory "target"
Generate auxiliary file "target\src_gen\Fragments.wxs"
Saved 54 component identifiers to file "target\src_gen\Fragments-cid.txt"
Execute PowerShell script "target\replace.ps1"
Copy .bat files to directory "target\resources"
Copy .ico files to directory "target\resources"
Use banner image found in directory "src\resources"
Add logo to banner image "target\resources\BannerTop.bmp"
Add logo to dialog image "target\resources\Dialog.bmp"
Set copyright information in file "target\resources\LICENSE.rtf"
Compiling 2 WiX source files to directory "target"
Create Windows installer "target\scala3-3.1.0.msi"
Welcome
Figure 4.1 - Custom Setup
(Scala3 installer).
 

Footnotes

[1] Fragments.wxs

When we run the heat tool to generate the file target\src_gen\Fragments.wxs in the above projects, we also specify the option -t src\resources\Fragments.xslt to apply a few XML transformations to the generated WiX source file (eg. addition of component element "repl.bat").

[2] Environment variables

The Scala 3 Windows installer generated in projects Scala3UI, Scala3Localized and Scala3Features (but not Scala3First) will update the system environment as follows :
> set | findstr SCALA
SCALA3_HOME=C:\Program Files\Scala 3\
 
> where scala
C:\Program Files\Scala 3\bin\scala
C:\Program Files\Scala 3\bin\scala.bat
 
> set JAVA_HOME=c:\opt\jdk-bellsoft-1.8.0u312
 
> scala -version
Scala code runner version 3.3.0 -- Copyright 2002-2023, LAMP/EPFL

[3] Default Java Location

OpenJDK implementations are available either as Zip files (.zip) or as Windows installers (.msi).
Unfortunately each Windows installer suggests a different default installation location and follows inconsistent naming conventions:
OpenJDK
Implementation
Default location
in directory %ProgramFiles%
Amazon Corretto 11 Amazon Corretto\jdk11.0.16_8\
Amazon Corretto 17 Amazon Corretto\ ⇦⇦ !!
Azul Zulu 8 Zulu\zulu-8\
Azul Zulu 11 Zulu\zulu-11\
Azul Zulu 17 Zulu\zulu-17\
Eclipse Temurin 8 Eclipse Adoptium\jdk-8.0.312.7-hotspot\
Eclipse Temurin 11 Eclipse Adoptium\jdk-11.0.13.8-hotspot\
Eclipse Temurin 17 Eclipse Adoptium\jdk-17.0.1.12-hotspot\
Microsoft 11 Microsoft\jdk-11.0.13.8-hotspot\
Microsoft 17 Microsoft\jdk-17.0.1.12-hotspot\
RedHat 8 RedHat\java-1.8.0-openjdk-1.8.0.312.2\
RedHat 11 RedHat\java-11-openjdk-11.0.13-1\
RedHat 17 RedHat\java-17-openjdk-17.0.1.0.12-1\
SapMachine 11 SapMachine\JDK\11\
SapMachine 17 SapMachine\JDK\17\

[4] Batch file build.bat

Command build help displays the batch file options and subcommands :
> build help
Usage: build { <option> | <subcommand> }
 
  Options:
    -debug       print commands executed by this script
    -timer       print total execution time
    -verbose     print progress messages
 
  Subcommands:
    clean        delete generated files
    help         print this help message
    install      execute Windows installer scala3
    link         create Windows installer from WXS/WXI/WXL files
    remove       remove installed program (same as uninstall)
    uninstall    remove installed program

mics/July 2024