Skip to content

Commit

Permalink
Prompt for Java install if missing (qzind#608)
Browse files Browse the repository at this point in the history
Prompt for Java install if missing
Closes qzind#606
  • Loading branch information
tresf authored Mar 20, 2020
1 parent e5d4fb1 commit ea2a21f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ant/apple/apple-preinstall.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ set -e
DIR=$(cd "$(dirname "$0")" && pwd)
pushd "$DIR/payload/Contents/MacOS/"

# Offer to download Java if missing
if ! ./"${project.name}" --version; then
osascript -e "tell app \"Installer\" to display dialog \"Java is required. Please install Java and try again.\""
sudo -u "$USER" open "${java.download}"
exit 1
fi

./"${project.name}" preinstall
27 changes: 27 additions & 0 deletions ant/windows/windows-installer.nsi.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,39 @@ RequestExecutionLevel admin
${EndIf}
!macroend

!macro VerifyJava jumpto
; Test java executable
nsExec::ExecToLog '"$java" -version"'
Pop $0
${If} "$0" == "0"
Goto Resume
${EndIf}

; Offer to download Java if missing and non-silent install
${IfNot} ${Silent}
MessageBox MB_YESNO "Java is required. Download now?" IDYES Website IDNO Resume

; Visit Java website
Website:
ExecShell "open" "${java.download}"
MessageBox MB_OK "Click OK after Java is installed"

; Check again for Java
Goto ${jumpto}
${EndIf}
Resume:
!macroend

Section
; Set environmental variable for silent install to be picked up by Java
${If} ${Silent}
System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("${vendor.name}_silent", "1").r0'
${EndIf}

; Set the $java variable
TryAgain:
Call FindJava
!insertmacro VerifyJava "TryAgain"

; Create the uninstaller
SetOutPath $INSTDIR
Expand Down Expand Up @@ -82,7 +107,9 @@ Section "Uninstall"
DetailPrint "Uninstalling..."

; Set the $java variable
TryAgain:
Call un.FindJava
!insertmacro VerifyJava "TryAgain"

; Run uninstall tasks
SetOutPath $INSTDIR
Expand Down

0 comments on commit ea2a21f

Please sign in to comment.