All Downloads are FREE. Search and download functionalities are using the official Maven repository.

packager.windows.WindowsWixConfig.scala Maven / Gradle / Ivy

The newest version!
package packager.windows

import packager.windows.wix._
import java.nio.charset.Charset

import scala.io.Codec

case class WindowsWixConfig(
  packageName: String,
  sourcePath: os.Path,
  iconPath: Option[os.Path],
  bannerPath: Option[os.Path],
  dialogPath: Option[os.Path],
  licensePath: os.Path,
  exitDialog: Option[String],
  productName: String,
  version: String,
  maintainer: String,
  launcherAppName: String,
  extraConfigs: List[String],
  is64Bits: Boolean,
  installerVersion: Option[String],
  wixUpgradeCodeGuid: Option[String]
) {

  lazy val extraConfig: Option[String] =
    if (extraConfigs.isEmpty) None
    else
      Some {
        extraConfigs
          .map { path =>
            val path0 = os.Path(path, os.pwd)
            os.read(path0, Codec(Charset.defaultCharset()))
          }
          .mkString(System.lineSeparator())
      }

  lazy val wixExitDialog =
    exitDialog
      .map(txt => Property(id = WIXUI_EXITDIALOGOPTIONALTEXT, value = txt))
      .map(_.generate)
      .getOrElse("")

  lazy val wixBannerBmp = bannerPath
    .map(path => WixVariable(id = WixUIBannerBmp, value = path.toString()))
    .map(_.generate)
    .getOrElse("")

  lazy val wixDialogBmp = dialogPath
    .map(path => WixVariable(id = WixUIDialogBmp, value = path.toString()))
    .map(_.generate)
    .getOrElse("")

  lazy val wixPropertyIcon = iconPath
    .map(_ => Property(id = ARPPRODUCTICON, value = "logo_ico"))
    .map(_.generate)
    .getOrElse("")

  lazy val wixIcon = iconPath
    .map(path => Icon(id = "logo_ico", sourceFile = path.toString()))
    .map(_.generate)
    .getOrElse("")

  def randomGuid: String = java.util.UUID.randomUUID.toString

  private def extraPackage =
    if (is64Bits) """Platform="x64""""
    else ""
  private def programFiles =
    if (is64Bits) "ProgramFiles64Folder"
    else "ProgramFilesFolder"

  def generateContent(): String =
    s"""
    
    
      
      


      
        
          
            
              
            
          
        
      

      
        
          
          
        
      

      

      
        
        
        
        
      

      
      

      $wixExitDialog
      $wixBannerBmp
      $wixDialogBmp
      $wixPropertyIcon
      $wixIcon

      

      ${extraConfig.getOrElse("")}

    
    
   """

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy