Skip to content

Commit

Permalink
Windows distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
naku committed Apr 17, 2013
1 parent 2a05617 commit 79be6a0
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 0 deletions.
4 changes: 4 additions & 0 deletions reader-distribution-windows/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.settings
/target
/.classpath
/.project
80 changes: 80 additions & 0 deletions reader-distribution-windows/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
<groupId>com.sismics.reader</groupId>
<artifactId>reader-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../reader-parent</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>reader-distribution-windows</artifactId>
<packaging>jar</packaging>
<name>Reader Windows Distribution</name>

<dependencies>
<dependency>
<groupId>com.sismics.reader</groupId>
<artifactId>reader-distribution-standalone</artifactId>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/nsis</directory>
<filtering>true</filtering>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.sismics.reader</groupId>
<artifactId>reader-distribution-standalone</artifactId>
<version>${reader.version}</version>
<type>tar.gz</type>
<classifier>dist</classifier>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nsis-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>generate-project</goal>
<goal>compile</goal>
</goals>
<configuration>
<makensisBin>${nsis.home}/makensis</makensisBin>
<setupScript>target/classes/reader.nsi</setupScript>
<outputFile>${project.build.directory}/${project.build.finalName}.exe</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Binary file not shown.
127 changes: 127 additions & 0 deletions reader-distribution-windows/src/main/nsis/reader.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# reader.nsi

!include "WordFunc.nsh"
!include "MUI.nsh"

!insertmacro VersionCompare

# The name of the installer
Name "Reader"

# The default installation directory
InstallDir $PROGRAMFILES\Reader

# Registry key to check for directory (so if you install again, it will
# overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Reader" "Install_Dir"

#--------------------------------
#Interface Configuration

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange.bmp"
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Getting Started.html"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "View Getting Started document"

#--------------------------------
# Pages

# This page checks for JRE
Page custom CheckInstalledJRE

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

# Languages
!insertmacro MUI_LANGUAGE "English"

Section "Reader"

SectionIn RO

# Install for all users
SetShellVarContext "all"

# Silently uninstall existing version.
ExecWait '"$INSTDIR\uninstall.exe" /S _?=$INSTDIR'

# Set output path to the installation directory.
SetOutPath $INSTDIR

# Write files.
File ..\reader-distribution-standalone-${reader.version}\reader.bat
File ..\reader-distribution-standalone-${reader.version}\reader-standalone.jar
File ..\reader-distribution-standalone-${reader.version}\sismicsreader.war

# Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\Reader "Install_Dir" "$INSTDIR"

# Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reader" "DisplayName" "Reader"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reader" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reader" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reader" "NoRepair" 1
WriteUninstaller "uninstall.exe"

SectionEnd


Section "Start Menu Shortcuts"

CreateDirectory "$SMPROGRAMS\Reader"
CreateShortCut "$SMPROGRAMS\Reader\Open Reader.lnk" "$INSTDIR\reader.url" "" "$INSTDIR\reader.bat" 0
CreateShortCut "$SMPROGRAMS\Reader\Uninstall Reader.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0

SectionEnd


# Uninstaller

Section "Uninstall"

# Uninstall for all users
SetShellVarContext "all"

# Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reader"
DeleteRegKey HKLM SOFTWARE\Reader

# Remove files.
Delete "$SMSTARTUP\Reader.lnk"
RMDir /r "$SMPROGRAMS\Reader"
Delete "$INSTDIR\reader.bat"
Delete "$INSTDIR\reader-standalone.jar"
Delete "$INSTDIR\sismicsreader.war"
Delete "$INSTDIR\uninstall.exe"
RMDir /r "$INSTDIR\log"
RMDir "$INSTDIR"

SectionEnd


Function CheckInstalledJRE
# Read the value from the registry into the $0 register
ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" CurrentVersion

# Check JRE version. At least 1.6 is required.
# $1=0 Versions are equal
# $1=1 Installed version is newer
# $1=2 Installed version is older (or non-existent)
${VersionCompare} $0 "1.6" $1
IntCmp $1 2 InstallJRE 0 0
Return

InstallJRE:
# Launch Java web installer.
MessageBox MB_OK "Java was not found and will now be installed."
File /oname=$TEMP\jre-setup.exe jre-7u21-windows-i586.exe
ExecWait '"$TEMP\jre-setup.exe"' $0
Delete "$TEMP\jre-setup.exe"

FunctionEnd
44 changes: 44 additions & 0 deletions reader-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<org.mortbay.jetty.jetty-maven-plugin.version>8.1.2.v20120308</org.mortbay.jetty.jetty-maven-plugin.version>
<org.vafer.jdeb.version>1.0.1</org.vafer.jdeb.version>
<org.codehaus.mojo.rpm-maven-plugin.version>2.1-alpha-2</org.codehaus.mojo.rpm-maven-plugin.version>
<org.codehaus.mojo.nsis-maven-plugin.version>1.0-SNAPSHOT</org.codehaus.mojo.nsis-maven-plugin.version>
<com.samaxes.maven.minify-maven-plugin.version>1.7</com.samaxes.maven.minify-maven-plugin.version>
</properties>

Expand Down Expand Up @@ -140,6 +141,12 @@
<version>${org.codehaus.mojo.rpm-maven-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nsis-maven-plugin</artifactId>
<version>${org.codehaus.mojo.nsis-maven-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand All @@ -166,6 +173,29 @@
<module>../reader-distribution-redhat</module>
</modules>
</profile>

<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<nsis.home>C:\Program Files (x86)\nsis</nsis.home>
</properties>
</profile>
<profile>
<id>linux</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<nsis.home>/user/makensis</nsis.home>
</properties>
</profile>
</profiles>

<dependencyManagement>
Expand Down Expand Up @@ -496,4 +526,18 @@
</dependency>
</dependencies>
</dependencyManagement>

<pluginRepositories>
<!-- Codehause Snapshots (NSIS) -->
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://nexus.codehaus.org/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled> <!-- Workaround for MNG-2974 -->
</releases>
</pluginRepository>
</pluginRepositories>
</project>

0 comments on commit 79be6a0

Please sign in to comment.