; Author Arnaud Heritier ; Setup Script for NSIS using Modern UI ; http://maven.apache.org/maven-1.x/plugins/nsis/ ; Do a Cyclic Redundancy Check to make sure the installer is not corrupt CRCCheck on ; Compress options SetCompress force SetCompressor /SOLID lzma SetDatablockOptimize on ; add directories for the source if it exists, and the plugin ; add project source onto the include list !addincludedir "${maven.nsis.src}" ; Directory to search NSIS plugins !addplugindir "${maven.nsis.src}" ; add generated files onto the include list !addincludedir "${maven.build.dir}" ; Directory to search NSIS plugins !addplugindir "${maven.build.dir}" ; add plugin supplied files onto the include list !addincludedir "${plugin.resources}" ; Directory to search NSIS plugins !addplugindir "${plugin.resources}" ; macro to check if the jdk is installed !include "JDK.nsh" ; Functions to set/remove environment variables !include "Environment.nsh" ; include project specific details !include "project.nsh" ; We have a problem with maven installer which create its env variable in the user's scope !define ALL_USERS ; Extensions / Plugins !include "MUI.nsh" ; Functions defined in natively in NSIS !include "FileFunc.nsh" ;Options Name "$${PROJECT_NAME} $${PROJECT_VERSION}" OutFile "$${PROJECT_DIST_DIR}\$${PROJECT_FINAL_NAME}.exe" ; 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" ; Adds an XP manifest to the installer XPStyle on ;Interface Settings !define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit !define MUI_HEADERIMAGE !define MUI_ICON "${icon}" !define MUI_UNICON "${unicon}" !define MUI_HEADERIMAGE_BITMAP "${headerbitmap}" !define MUI_HEADERIMAGE_UNBITMAP "${unheaderbitmap}" !define MUI_WELCOMEFINISHPAGE_BITMAP "${welcomebitmap}" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${unwelcomebitmap}" !define MUI_ABORTWARNING !define MUI_UNABORTWARNING !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_UNFINISHPAGE_NOAUTOCLOSE ; Pages ; Install !insertmacro MUI_PAGE_WELCOME !ifdef PROJECT_LICENSE_FILE !insertmacro MUI_PAGE_LICENSE "$${PROJECT_LICENSE_FILE}" !endif !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH ; Uninstall !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ;Languages ${maven.nsis.mui.languages} !insertmacro MUI_LANGUAGE "${language}" ; -------------------------------------------------------------- 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(s)" !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 ; -------------------------------------------------------------- Uninstaller Section "Uninstall" DetailPrint "Remove files" Delete $$INSTDIR\*.* ; MUST REMOVE UNINSTALLER, too Delete "$$INSTDIR\Uninst.exe" !include "remove-shortcuts.nsh" ; Recursively remove files and directories used ; this should also take care of the installer RMDir /r "$$INSTDIR" DetailPrint "Remove registry keys" DeleteRegKey HKLM "$${PROJECT_REG_UNINSTALL_KEY}" DeleteRegKey HKLM "$${PROJECT_REG_KEY}" !include "registry-uninstall.nsh" SectionEnd ; -------------------------------------------------------------- Functions Function .onInit !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd Function myGUIInit !include "before-install.nsh" FunctionEnd Function un.onInit !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd ; -------------------------------------------------------------- End of File