WiX examples with Scala 2 distribution ⬆
Directory scala2-examples\ contains WiX examples written by ourself to create a Scala 2 Windows installer.Follow this link if you're looking for the Scala 3 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 :- application files are downloaded and extracted from the Zip archive (e.g.
scala-2.13.8.zip
) if not yet present in directoryapp\
. - we do not maintain a source file
Fragments.wxs
in directorysrc\
; the filetarget\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.
- application files are downloaded and extracted from the Zip archive (e.g.
The Scala 2 Windows installer behaves in 3 different ways when it detects a Scala 2 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 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 2 Windows installer. The document
SECURITY.md
provides more information about self-signed certificates.
Scala2First
2 is our first iteration to create a Windows installer (aka. .msi
file) for the Scala 2 software distribution.
This project has the following directory structure :
> cd Y:\scala2-examples\Scala2First > tree /f . | findstr /v /b [a-z] │ build.bat ├───app │ ├───scala-2.12.15 │ │ (files extracted from scala-2.12.15.zip) │ └───scala-2.13.8 │ (files extracted from scala-2.13.8.zip) └───src │ Scala2First.wxs └───resources favicon.ico repl.bat
🔎 During installation the batch file
src\resources\repl.bat
is added to thebin\
directory; the goal of that wrapper script is to look for a Java installation 3 before starting the Scala 2 REPL (Scala commands require either variableJAVA_HOME
or variableJAVACMD
to be defined).
Command build link
4 generates the Scala 2 Windows installer with file name scala-2.13.7.msi
.
> build clean link && tree /f target | findstr /v /b [a-z] │ candle_opts.txt │ candle_sources.txt │ Fragments.wixobj │ light_opts.txt │ scala-2.13.8.msi │ scala-2.13.8.msi.md5 │ scala-2.13.8.msi.sha256 │ scala-2.13.8.wixpdb │ Scala2First.wixobj ├───resources │ favicon.ico │ repl.bat └───src_gen Fragments-cid.txt (component identifier list) Fragments.wxs Scala2First.wxs
🔎 The above file
target\src_gen\Scala2First.wxs
contains the real GUIDs instead of the symbol names defined in source filesrc\Scala2First.wxs
.
Figures 1.1 to 1.4 below illustrate the updated user environment after the successful execution of the Scala 2 Windows installer.
Figure 1.4 - Uninstall Scala 2 (Settings window). |
Scala2Sbt
Example ▴
Scala2Sbt
2 relies on the sbt Windows Plugin to generate the Scala 2 Windows installer; this is the way the Scala team at Lightbend publishes the Scala 2 Windows installer (see Scala Archive).
Figures 2.1 to 2.4 below illustrate the dialog windows of the Windows installer while Figure 2.5 shows the updated user environment after the successful execution of the Scala 2 Windows installer.
Scala2UI
2 adds customizations to the graphical user interface of the Scala 2 Windows installer. Concretely, we can 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:\scala-examples\Scala2UI > tree /f . | findstr /v /b [a-z] │ build.bat ├───app │ ├───scala-2.12.15 │ │ (files extracted from scala-2.12.15.zip) │ └───scala-2.13.8 │ (files extracted from scala-2.13.8.zip) └───src │ Includes.wxi │ Scala2UI.wxs └───resources BannerTop.bmp Dialog.bmp favicon.ico Fragments.xslt License.rtf logo.svg LICENSE.rtf network.ico repl.bat rtf.ico
Command build link
generates the Scala 2 Windows installer with file name scala-2.13.8.msi
.
> build -verbose link && tree /f target | findstr /v /b [a-z] Generate auxiliary file "target\src_gen\Fragments.wxs.txt" Saved 40 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 top banner image "target\resources\BannerTop.bmp" Add logo to dialog image "target\resources\Dialog.bmp" Compiling 2 WiX source files to directory "target" Create Windows installer "target\scala-2.13.8.msi" │ candle_opts.txt │ candle_sources.txt │ Fragments.wixobj │ light_opts.txt │ replace.ps1 │ scala-2.13.8.msi │ scala-2.13.8.msi.md5 │ scala-2.13.8.msi.sha256 │ scala-2.13.8.wixpdb │ Scala2UI.wixobj ├───resources │ BannerTop.bmp │ Dialog.bmp │ favicon.ico │ License.rtf │ network.ico │ repl.bat │ rtf.ico └───src_gen Fragments-cid.txt Fragments.wxs Includes.wxi Scala2UI.wxs
Figures 3.1 to 3.4 below illustrate the dialog windows of our Windows installer while Figures 3.5 and 3.6 show the updated user environment after the successful execution of the Scala 2 Windows installer.
Scala2Localized
Example ▴
Scala2Localized
2 adds language localization to the WiX source files of the Scala 2 Windows installer.
This project contains the additional directory src\localizations\
with 4 WiX localization files:
> cd Y:\scala2-examples\Scala2Localized > tree /f . | findstr /v /b [a-z] │ build.bat ├───app │ ├───scala-2.12.15 │ │ (files extracted from scala-2.12.15.zip) │ └───scala-2.13.8 │ (files extracted from scala-2.13.8.zip) └───src │ Includes.wxi │ Scala2Localized.wxs ├───localizations │ de-DE.wxl │ en-US.wxl │ fr-Fr.wxl │ sv-SE.wxl └───resources BannerTop.bmp Dialog.bmp favicon.ico Fragments.xslt LICENSE.rtf logo.svg network.ico repl.bat rtf.ico
Command build link
generates a separate MSI file for each language localization, e.g. scala-2.13.8-sv-SE.msi
is the swedish version of the Scala 2 Windows installer.
> build clean link && dir /b /a-d target candle_opts.txt candle_sources.txt Fragments.wixobj light_opts.txt replace.ps1 scala-2.13.8.msi scala-2.13.8.msi.md5 scala-2.13.8.msi.sha256 scala-2.13.8.wixpdb scala-2.13.8_de-DE.msi scala-2.13.8_de-DE.msi.md5 scala-2.13.8_de-DE.msi.sha256 scala-2.13.8_de-DE.wixpdb scala-2.13.8_fr-FR.msi scala-2.13.8_fr-FR.msi.md5 scala-2.13.8_fr-FR.msi.sha256 scala-2.13.8_fr-FR.wixpdb scala-2.13.8_sv-SE.msi scala-2.13.8_sv-SE.msi.md5 scala-2.13.8_sv-SE.msi.sha256 scala-2.13.8_sv-SE.wixpdb Scala2Localized.wixobj
Figures 4.1 to 4.4 below illustrate the "Welcome" dialog window of the Scala 2 Windows installer in english, german, french and swedish.
Figure 4.1 - Welcome
(english version). Figure 4.2 - Willkommen
(german version). |
Figure 4.3 - Bienvenue
(french version). Figure 4.4 - Välkommen
(swedish version). |
Scala2Features
Example ▴
Scala2Features
2 adds feature customization to the Scala 2 Windows installer.
Concretely the main Feature
element of the WiX source file Scala2Features.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 scala-2.13.8.msi
with the two checksum files scala-2.13.8.msi.md5
and scala-2.13.8.msi.sha256
.
> build -verbose clean link Delete directory "target" Generate auxiliary file "target\src_gen\Fragments.wxs" Saved 41 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 3 WiX source files to directory "target" Create Windows installer "target\scala-2.13.8.msi"
Figures 5.1 to 5.4 below illustrate the dialog windows of our Windows installer while Figures 5.5 and 5.6 show how the Windws installer behaves when a Scala 2 installation is already present on the target machine.
Footnotes ▴
[1] Fragments.wxs
↩
-
In the above projects we not just call the
heat
tool to generate the filetarget\src_gen\Fragments.wxs
, 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 2 Windows installer generated in projects
Scala2Sbt
,Scala2UI
,Scala2Localized
andScala2Features
(but notScala2First
) will update the system environment as follows : -
> set | findstr SCALA SCALA_HOME=C:\Program Files\Scala 2\ > where scala C:\Program Files\Scala 2\bin\scala C:\Program Files\Scala 2\bin\scala.bat > set JAVA_HOME=c:\opt\jdk-bellsoft-1.8.0u312 > scala -version Scala code runner version 2.13.11 -- Copyright 2002-2023, LAMP/EPFL and Lightbend, Inc.
[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
ImplementationDefault location
in%ProgramFiles%
folderAmazon Corretto 11 Amazon Corretto\jdk11.0.20_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.342.1\
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
prints 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 scala link create Windows installer from WXS/WXI/WXL files remove remove installed program (same as uninstall) uninstall remove installed program