; Author Kristen Gillard
; Author Dion Gillard
; Setup Script for NSIS
; http://maven.apache.org/maven-1.x/reference/plugins/nsis/
; add directories for the source if it exists, and the plugin
; add project source onto the include list
!addincludedir "${maven.nsis.src}"
; add generated files onto the include list
!addincludedir "${maven.build.dir}"
; add plugin supplied files onto the include list
!addincludedir "${plugin.resources}"
; macro for the image on the install screen
!include "BrandingImage.nsh"
!include "JDK.nsh"
!include "Environment.nsh"
; include project specific details
!include "project.nsh"
; Do a Cyclic Redundancy Check to make sure the installer is not corrupt
CRCCheck on
; The name of the installer
Name "$${PROJECT_NAME}"
; Maven Setup executable
OutFile "$${PROJECT_DIST_DIR}\$${PROJECT_FINAL_NAME}.exe"
; Adds an XP manifest to the installer
XPStyle on
; branding with logo
!ifdef PROJECT_LOGO
AddBrandingImage ${maven.nsis.logo.position} ${maven.nsis.logo.widthHeight}
!endif
; Sets the font of the installer
SetFont "Arial" 8
!ifdef PROJECT_LICENSE_FILE
; License Information
LicenseText "$${PROJECT_LICENSE_TEXT}"
LicenseData "$${PROJECT_LICENSE_FILE}"
!endif
; The default installation directory
InstallDir "$$PROGRAMFILES\$${PROJECT_ORGANIZATION}\$${PROJECT_NAME} $${PROJECT_VERSION}"
; Registry key to check for directory (so if you upgrade, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "$${PROJECT_REG_KEY}" "Install_Dir"
; The text to prompt the user to enter a directory
ComponentText "This will install $${PROJECT_NAME} on your computer."
; The text to prompt the user to enter a directory
DirText "$${PROJECT_NAME} Home Directory"
; -------------------------------------------------------------- Package up the files to be installed
Section "$${PROJECT_NAME} v$${PROJECT_VERSION} Binaries"
; Set output path to the installation directory.
SetOutPath $$INSTDIR
; Put files and directories there
; the script will be run from a directory below Maven
File /r "$${PROJECT_DIST_BIN_DIR}\*.*"
; Write the installation path into the registry
WriteRegStr HKLM "$${PROJECT_REG_KEY}" "Install_Dir" "$$INSTDIR"
; Write the environment variables to the Registry
!include "registry.nsh"
; Write the uninstall keys for Windows
WriteRegStr HKLM "$${PROJECT_REG_UNINSTALL_KEY}" "DisplayName" "$${PROJECT_NAME} $${PROJECT_VERSION} (remove only)"
WriteRegStr HKLM "$${PROJECT_REG_UNINSTALL_KEY}" "UninstallString" '"$$INSTDIR\Uninst.exe"'
SectionEnd
; -------------------------------------------------------------- Create Shortcuts
Section "Create Start Menu Shortcut(s)"
CreateDirectory "$${PROJECT_STARTMENU_FOLDER}"
!include "startmenu-shortcuts.nsh"
SectionEnd
; OPTIONAL Desktop Shortcut
Section "Create Desktop Shortcut"
!include "desktop-shortcuts.nsh"
SectionEnd
; -------------------------------------------------------------- Section to Install the Uninstaller
Section "Install Uninstaller"
; write the uninstaller to the installation directory
WriteUninstaller "$$INSTDIR\Uninst.exe"
SectionEnd
; -------------------------------------------------------------- Maven Uninstaller
Section "Uninstall"
; remove registry keys
DeleteRegKey HKLM "$${PROJECT_REG_UNINSTALL_KEY}"
DeleteRegKey HKLM "$${PROJECT_REG_KEY}"
!include "registry-uninstall.nsh"
; remove files
Delete $$INSTDIR\*.*
; MUST REMOVE UNINSTALLER, too
Delete $$INSTDIR\Uninst.exe
; remove shortcuts, if any.
Delete "$${PROJECT_STARTMENU_FOLDER}\*.*"
RMDir "$${PROJECT_STARTMENU_FOLDER}"
; Recursively remove files and directories used
; this should also take care of the installer
RMDir /r "$$INSTDIR"
MessageBox MB_OK|MB_ICONEXCLAMATION "$${PROJECT_NAME} has been uninstalled"
SectionEnd
; -------------------------------------------------------------- Add Images to the Installer / UnInstaller
Function .onGUIInit
!ifdef PROJECT_LOGO
!insertmacro BrandingImage "$${PROJECT_LOGO}" ""
!endif
!include "before-install.nsh"
FunctionEnd
; add the logo to the un-installer
Function un.onGUIInit
!ifdef PROJECT_LOGO
!insertmacro BrandingImage "$${PROJECT_LOGO}" ""
!endif
FunctionEnd
; -------------------------------------------------------------- End of File