You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by di...@apache.org on 2003/10/14 08:33:09 UTC
cvs commit: maven-plugins/nsis/src/plugin-resources/templates project.jelly setup.jelly
dion 2003/10/13 23:33:09
Added: nsis/src/plugin-resources GetJRE.nsh BrandingImage.nsh
Environment.nsh JDK.nsh
nsis plugin.properties plugin.jelly project.xml
project.properties .cvsignore
nsis/src/plugin-resources/templates project.jelly
setup.jelly
Log:
Start of nsis plugin.
NOT YET FUNCTIONAL.
Please help with it!!!
Revision Changes Path
1.1 maven-plugins/nsis/src/plugin-resources/GetJRE.nsh
Index: GetJRE.nsh
===================================================================
;
; Found in the NSIS Archives http://nsis.sourceforge.net/archive/nsisweb.php?page=326&instances=0,64
;
Function GetJRE
;
; Find JRE (Java.exe)
; 1 - in .\jre directory (JRE Installed with application)
; 2 - in JAVA_HOME environment variable
; 3 - in the registry
; 4 - assume java.exe in current dir or PATH
Push $R0
Push $R1
ClearErrors
StrCpy $R0 "$EXEDIR\jre\bin\java.exe"
IfFileExists $R0 JreFound
StrCpy $R0 ""
ClearErrors
ReadEnvStr $R0 "JAVA_HOME"
StrCpy $R0 "$R0\bin\java.exe"
IfErrors 0 JreFound
ClearErrors
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment"
"CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1"
"JavaHome"
StrCpy $R0 "$R0\bin\java.exe"
IfErrors 0 JreFound
StrCpy $R0 "java.exe"
JreFound:
Pop $R1
Exch $R0
FunctionEnd
1.1 maven-plugins/nsis/src/plugin-resources/BrandingImage.nsh
Index: BrandingImage.nsh
===================================================================
; macro for the image on the install screen
!macro BrandingImage IMAGE PARMS
Push $0
GetTempFileName $0
File /oname=$0 "${IMAGE}"
SetBrandingImage ${PARMS} $0
Delete $0
Pop $0
!macroend
1.1 maven-plugins/nsis/src/plugin-resources/Environment.nsh
Index: Environment.nsh
===================================================================
;
; From NSISArchives http://nsis.sourceforge.net/archive/nsisweb.php?page=156&instances=0,11
;
!include WinMessages.nsh
!ifdef ALL_USERS
!define WriteEnvStr_RegKey \
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!else
!define WriteEnvStr_RegKey 'HKCU "Environment"'
!endif
#
# WriteEnvStr - Writes an environment variable
# Note: Win9x systems requires reboot
#
# Example:
# Push "HOMEDIR" # name
# Push "C:\New Home Dir\" # value
# Call WriteEnvStr
#
Function WriteEnvStr
Exch $1 ; $1 has environment variable value
Exch
Exch $0 ; $0 has environment variable name
Push $2
Call IsNT
Pop $2
StrCmp $2 1 WriteEnvStr_NT
; Not on NT
StrCpy $2 $WINDIR 2 ; Copy drive of windows (c:)
FileOpen $2 "$2\autoexec.bat" a
FileSeek $2 0 END
FileWrite $2 "$\r$\nSET $0=$1$\r$\n"
FileClose $2
SetRebootFlag true
Goto WriteEnvStr_done
WriteEnvStr_NT:
WriteRegExpandStr ${WriteEnvStr_RegKey} $0 $1
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} \
0 "STR:Environment" /TIMEOUT=5000
WriteEnvStr_done:
Pop $2
Pop $1
Pop $0
FunctionEnd
#
# un.DeleteEnvStr - Removes an environment variable
# Note: Win9x systems requires reboot
#
# Example:
# Push "HOMEDIR" # name
# Call un.DeleteEnvStr
#
Function un.DeleteEnvStr
Exch $0 ; $0 now has the name of the variable
Push $1
Push $2
Push $3
Push $4
Push $5
Call un.IsNT
Pop $1
StrCmp $1 1 DeleteEnvStr_NT
; Not on NT
StrCpy $1 $WINDIR 2
FileOpen $1 "$1\autoexec.bat" r
GetTempFileName $4
FileOpen $2 $4 w
StrCpy $0 "SET $0="
SetRebootFlag true
DeleteEnvStr_dosLoop:
FileRead $1 $3
StrLen $5 $0
StrCpy $5 $3 $5
StrCmp $5 $0 DeleteEnvStr_dosLoop
StrCmp $5 "" DeleteEnvStr_dosLoopEnd
FileWrite $2 $3
Goto DeleteEnvStr_dosLoop
DeleteEnvStr_dosLoopEnd:
FileClose $2
FileClose $1
StrCpy $1 $WINDIR 2
Delete "$1\autoexec.bat"
CopyFiles /SILENT $4 "$1\autoexec.bat"
Delete $4
Goto DeleteEnvStr_done
DeleteEnvStr_NT:
DeleteRegValue ${WriteEnvStr_RegKey} $0
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} \
0 "STR:Environment" /TIMEOUT=5000
DeleteEnvStr_done:
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
#
# [un.]IsNT - Pushes 1 if running on NT, 0 if not
#
# Example:
# Call IsNT
# Pop $0
# StrCmp $0 1 +3
# MessageBox MB_OK "Not running on NT!"
# Goto +2
# MessageBox MB_OK "Running on NT!"
#
!macro IsNT UN
Function ${UN}IsNT
Push $0
ReadRegStr $0 HKLM \
"SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
StrCmp $0 "" 0 IsNT_yes
; we are not NT.
Pop $0
Push 0
Return
IsNT_yes:
; NT!!!
Pop $0
Push 1
FunctionEnd
!macroend
!insertmacro IsNT ""
!insertmacro IsNT "un."
1.1 maven-plugins/nsis/src/plugin-resources/JDK.nsh
Index: JDK.nsh
===================================================================
Function AssertJavaHome
ClearErrors
ReadEnvStr $0 "JAVA_HOME"
IfErrors 0 Found
ClearErrors
MessageBox MB_OK|MB_ICONSTOP "The JAVA_HOME environment variable must be set. Please set JAVA_HOME to the location of your JDK and try installing again"
Abort
Found:
FunctionEnd
1.1 maven-plugins/nsis/plugin.properties
Index: plugin.properties
===================================================================
# -------------------------------------------------------------------
# P L U G I N P R O P E R I E S
# -------------------------------------------------------------------
# NSIS plugin.
# -------------------------------------------------------------------
#
# This is the jelly template used to create the project.nsh file
#
maven.nsis.project.template=${plugin.resources}/templates/project.jelly
#
# This is the jelly template used to create the project.nsh file
#
maven.nsis.setup.template=${plugin.resources}/templates/setup.jelly
#
# FIXME: Should be able to get this from the POM.
#
maven.nsis.license.text=This program is Licensed under The Apache Software License, Version 1.1.
#
# location of makensis.exe
#
maven.nsis.exe=C:/Program Files/NSIS/makensis.exe
#
# source of extra files for nsis
#
maven.nsis.src=${basedir}/src/nsis
1.1 maven-plugins/nsis/plugin.jelly
Index: plugin.jelly
===================================================================
<?xml version="1.0"?>
<project
xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
xmlns:dist="dist"
xmlns:license="license"
xmlns:util="jelly:util">
<!--==================================================================-->
<!-- Generate NSIS Instller.exe file -->
<!--==================================================================-->
<goal name="nsis"
description="Generate NSIS Installer .exe"
prereqs="nsis:installer">
<ant:echo>FIXME: Not Finished</ant:echo>
</goal>
<goal name="nsis:generate-project"
description="Generate NSIS project.nsh file">
<j:set var="generatedFileName" value="${maven.build.dir}/project.nsh"/>
<ant:echo>Creating ${generatedFileName} ...</ant:echo>
<j:file name="${generatedFileName}" prettyPrint="false" xmlns="dummy" omitXmlDeclaration="true" escapeText="false">
<j:import file="${maven.nsis.project.template}" inherit="true"/>
</j:file>
</goal>
<goal name="nsis:generate-setup"
description="Generate NSIS .nsi file">
<j:set var="generatedFileName" value="${maven.build.dir}/setup.nsi"/>
<ant:echo>Creating ${generatedFileName} ...</ant:echo>
<j:file name="${generatedFileName}" prettyPrint="false" xmlns="dummy" omitXmlDeclaration="true" escapeText="false">
<j:import file="${maven.nsis.setup.template}" inherit="true"/>
</j:file>
</goal>
<!--==================================================================-->
<!-- Generate NSIS .exe file -->
<!--==================================================================-->
<goal name="nsis:installer"
description="Generate NSIS .exe file"
prereqs="nsis:generate-project">
<j:set var="script" value="${maven.build.dir}/setup.nsi"/>
<!-- call makensis.exe with the setup.nsh file -->
<ant:exec executable="${maven.nsis.exe}">
<arg value="${script}"/>
</ant:exec>
</goal>
</project>
1.1 maven-plugins/nsis/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>../project.xml</extend>
<pomVersion>3</pomVersion>
<id>maven-nsis-plugin</id>
<name>Maven NSIS Plug-in</name>
<currentVersion>1.0-SNAPSHOT</currentVersion>
<description>A plugin to generate Win32 installer programs using NSIS</description>
<shortDescription>NSIS Plugin for Maven</shortDescription>
<url>http://maven.apache.org/reference/plugins/nsis/</url>
<siteDirectory>/www/maven.apache.org/reference/plugins/nsis/</siteDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/nsis/</connection>
<url>http://cvs.apache.org/viewcvs/maven-plugins/nsis/</url>
</repository>
<versions>
<version>
<id>1.0</id>
<name>1.0</name>
<tag>HEAD</tag>
</version>
</versions>
<developers>
<developer>
<name>dIon Gillard</name>
<id>dion</id>
<email>dion@multitask.com.au</email>
<organization>Multitask Consulting</organization>
<roles>
<role>Java Developer</role>
</roles>
</developer>
</developers>
</project>
1.1 maven-plugins/nsis/project.properties
Index: project.properties
===================================================================
# -------------------------------------------------------------------
# P R O J E C T P R O P E R T I E S
# -------------------------------------------------------------------
maven.xdoc.date=left
maven.xdoc.version=${pom.currentVersion}
maven.license.licenseFile=${basedir}/../LICENSE.txt
1.1 maven-plugins/nsis/.cvsignore
Index: .cvsignore
===================================================================
target
velocity.log
maven.log
.classpath
.project
1.1 maven-plugins/nsis/src/plugin-resources/templates/project.jelly
Index: project.jelly
===================================================================
<j:jelly
xmlns:ant="jelly:ant"
xmlns:j="jelly:core"
xmlns:maven="jelly:maven"
xmlns:util="jelly:util"
xmlns="dummy">
<maven:makeAbsolutePath var="license" basedir="${basedir}"
path="${pom.getPluginContext('maven-license-plugin').getVariable('maven.license.licenseFile')}"/>
<maven:makeAbsolutePath var="build" basedir="${basedir}" path="${maven.build.dir}"/>
<maven:makeAbsolutePath var="dist" basedir="${basedir}" path="${maven.dist.bin.assembly.dir}"/>
<ant:tstamp />
; template for project details
; generated by ${user.name} from project.xml version ${pom.currentVersion}
; on date ${TODAY}, time ${TSTAMP}
!define ORGANIZATION "${pom.organization}"
!define PROJECT_BUILD_DIR "${build}"
!define PROJECT_FINAL_NAME "${maven.final.name}"
!define PROJECT_LICENSE_FILE "${license}"
!define PROJECT_LICENSE_TEXT "${maven.nsis.license.text}"
!define PROJECT_NAME "${pom.name}"
!define PROJECT_REG_KEY "SOFTWARE\${pom.organization}\${pom.name}\${pom.currentVersion}"
!define PROJECT_REG_UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${pom.name} ${pom.version}"
!define PROJECT_STARTMENU_FOLDER "$$SMPROGRAMS\${pom.organization}\${pom.name} ${pom.currentVersion}"
!define PROJECT_VERSION "${pom.currentVersion}"
!define PROJECT_DIST_DIR "${maven.dist.bin.assembly.dir}"
</j:jelly>
1.1 maven-plugins/nsis/src/plugin-resources/templates/setup.jelly
Index: setup.jelly
===================================================================
<j:jelly
xmlns:ant="jelly:ant"
xmlns:j="jelly:core"
xmlns:maven="jelly:maven"
xmlns:util="jelly:util"
xmlns="dummy">
; Author Kristen Gillard
; Author Dion Gillard
; Installation Script for Maven
; http://maven.apache.org/
; add directories for the source if it exists, and the plugin
<util:available file="${maven.nsis.src}">
; add project source onto the include list
!addincludedir "${maven.nsis.src}"
</util:available>
!addincludedir "${maven.build.dir}"
!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_BUILD_DIR}\${PROJECT_FINAL_NAME}.exe"
; Adds an XP manifest to the installer
XPStyle on
; branding with maven logo
AddBrandingImage left 70|267
; Sets the font of the installer
SetFont "Arial" 8
; License Information
LicenseText "This program is Licensed under The Apache Software License, Version 1.1."
LicenseData "${PROJECT_LICENSE_FILE}"
; The default installation directory
InstallDir "$PROGRAMFILES\${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_DIR}\*.*"
; Write the installation path into the registry
WriteRegStr HKLM "${PROJECT_REG_KEY}" "Install_Dir" "$INSTDIR"
; Write the environment variables to the Registry
; ${MAVEN_HOME}
Push "MAVEN_HOME"
Push "$INSTDIR"
Call WriteEnvStr
; TODO - Add MAVEN_HOME to the path
; TODO Prompt and write other environment variables to the Registry
; WriteRegStr HKCU "Environment" "MAVEN_LOCAL_HOME" "$INSTDIR"
; 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)"
; it would be nice to get all this from navigation.xml :-)
CreateDirectory "${PROJECT_STARTMENU_FOLDER}"
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Maven.lnk" "$INSTDIR\bin\maven.bat" "" "$INSTDIR\bin\maven.bat" 0
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Install Maven Repository.lnk" "$INSTDIR\bin\install_repo.bat" "" "$INSTDIR\install_repo.bat" 0
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Uninstall.lnk" "$INSTDIR\Uninst.exe" "" "$INSTDIR\Uninst.exe" 0
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Homepage.lnk" "http://maven.apache.org/"
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\User Guide.lnk" "http://maven.apache.org/reference/user-guide.html"
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Core Plugins.lnk" "http://maven.apache.org/reference/plugins/core-plugins.html"
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Optional Plugins.lnk" "http://maven.apache.org/reference/plugins/optional/optional.html"
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Reference.lnk" "http://maven.apache.org/reference/index.html"
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Report a Bug.lnk" "http://jira.codehaus.org/secure/BrowseProject.jspa?id=10030"
CreateShortCut "${PROJECT_STARTMENU_FOLDER}\Frequently Asked Questions.lnk" "http://maven.apache.org/faq.html"
SectionEnd
; OPTIONAL Desktop Shortcut
; Section "Create Desktop Shortcut"
; CreateShortCut "$DESKTOP\Maven.lnk" "$INSTDIR\bin\maven.bat" "" "$INSTDIR\bin\maven.bat"
;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}"
; Remove ${MAVEN_HOME}
Push "MAVEN_HOME"
Call un.DeleteEnvStr
; remove files
Delete $INSTDIR\*.*
; MUST REMOVE UNINSTALLER, too
Delete $INSTDIR\Uninst.exe
; remove shortcuts, if any.
Delete "${PROJECT_STARTMENU_FOLDER}\*.*"
RMDir "${PROJECT_STARTMENU_FOLDER}"
; Delete "$DESKTOP\Maven.lnk"
; Recursively remove files and directories used
; this should also take care of the installer
RMDir /r "$INSTDIR"
; MessageBox MB_OK|MB_ICONEXCLAMATION "Maven has been 'Uninstalled'"
SectionEnd
; -------------------------------------------------------------- Add Images to the Installer / UnInstaller
Function .onGUIInit
!insertmacro BrandingImage "maven.bmp" ""
; TODO Check for a JAVA_HOME environment variable
Call AssertJavaHome
FunctionEnd
; add the maven logo to the un-installer
Function un.onGUIInit
!insertmacro BrandingImage "maven.bmp" ""
FunctionEnd
; -------------------------------------------------------------- End of File
</j:jelly>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org