diff --git a/build/conf/nsis/customInstallActions.nsi b/build/conf/nsis/customInstallActions.nsi index 28f51fdbc9c7..cf24367e4e2a 100644 --- a/build/conf/nsis/customInstallActions.nsi +++ b/build/conf/nsis/customInstallActions.nsi @@ -1,73 +1,9 @@ !include x64.nsh !define INSTALL_OPTION_ELEMENTS 5 !define JAVA_REQUIREMENT 1.8 -!define BINTRAY "https://bintray.com/jetbrains/intellij-jdk" -!define JETBRAINS "https://download.jetbrains.com" -Var linkToJre64 - -; This function does a case sensitive searches for an occurrence of a substring in a string. -; It returns the substring if it is found. -; Otherwise it returns null(""). -; http://nsis.sourceforge.net/StrContains -!macro _StrContainsConstructor OUT NEEDLE HAYSTACK - Push `${HAYSTACK}` - Push `${NEEDLE}` - Call StrContains - Pop `${OUT}` -!macroend -!define StrContains '!insertmacro "_StrContainsConstructor"' - -Var STR_HAYSTACK -Var STR_NEEDLE -Var STR_CONTAINS_VAR_1 -Var STR_CONTAINS_VAR_2 -Var STR_CONTAINS_VAR_3 -Var STR_CONTAINS_VAR_4 -Var STR_RETURN_VAR - -Function StrContains - Exch $STR_NEEDLE - Exch 1 - Exch $STR_HAYSTACK - ; Uncomment to debug - ; MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK ' - StrCpy $STR_RETURN_VAR "" - StrCpy $STR_CONTAINS_VAR_1 -1 - StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE - StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK - loop: - IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1 - StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1 - StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found - StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done - Goto loop - found: - StrCpy $STR_RETURN_VAR $STR_NEEDLE - Goto done - done: - Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the - Exch $STR_RETURN_VAR -FunctionEnd - Function customInstallActions - !insertmacro INSTALLOPTIONS_READ $R0 "Desktop.ini" "Field 4" "State" - ${If} $R0 == 1 - inetc::get $linkToJre64 "$TEMP\jre64.tar.gz" /END - Pop $0 - ${If} $0 == "OK" - untgz::extract "-d" "$INSTDIR\jre64" "$TEMP\jre64.tar.gz" - StrCmp $R0 "success" removeTempJre64 - DetailPrint "Failed to extract jre64.tar.gz" - MessageBox MB_OK|MB_ICONEXCLAMATION|MB_DEFBUTTON1 "Failed to extract $TEMP\jre64.tar.gz" -removeTempJre64: - IfFileExists "$TEMP\jre64.tar.gz" 0 done - Delete "$TEMP\jre64.tar.gz" - ${Else} - MessageBox MB_OK|MB_ICONEXCLAMATION "The $linkToJre64 download is failed: $0" - ${EndIf} - ${EndIf} -done: + DetailPrint "There are no custom install actions." FunctionEnd Function searchJava64 @@ -106,18 +42,10 @@ Function ConfirmDesktopShortcut !insertmacro INSTALLOPTIONS_WRITE "Desktop.ini" "Field 3" "Text" $R1 ; if 64-bit Win OS and jre64 for the build is available then add checkbox to Installation Options dialog ${If} ${RunningX64} - ${GetParameters} $R0 - ClearErrors - ${GetOptions} $R0 "jre64=" $R1 - ${IfNot} ${Errors} - call ValidateLinkToJre64 - StrCmp $0 "OK" addCheckBoxToDialog - ${EndIf} StrCmp "${LINK_TO_JRE64}" "null" association 0 - StrCpy $R1 ${LINK_TO_JRE64} - call ValidateLinkToJre64 + inetc::head /SILENT /TOSTACK ${LINK_TO_JRE64} "" /END + Pop $0 ${If} $0 == "OK" -addCheckBoxToDialog: !insertmacro INSTALLOPTIONS_WRITE "Desktop.ini" "Field 4" "Type" "checkbox" !insertmacro INSTALLOPTIONS_WRITE "Desktop.ini" "Field 4" "Text" "Download and install 64-bit JRE by JetBrains (will be used with 64-bit launcher)" ${EndIf} @@ -141,18 +69,4 @@ skip_association: done: !insertmacro INSTALLOPTIONS_WRITE "Desktop.ini" "Settings" "NumFields" "$R0" !insertmacro INSTALLOPTIONS_DISPLAY "Desktop.ini" -FunctionEnd - -Function ValidateLinkToJre64 - ${StrContains} $R0 ${JETBRAINS} $R1 - StrCmp $R0 "" 0 checkIfFileExists - ${StrContains} $R0 ${BINTRAY} $R1 - ${If} $R0 != "" -checkIfFileExists: - StrCpy $linkToJre64 $R1 - inetc::head /SILENT /TOSTACK $linkToJRE64 "" /END - Pop $0 - ${Else} - StrCpy $linkToJre64 "" - ${EndIf} FunctionEnd \ No newline at end of file diff --git a/build/conf/nsis/idea.nsi b/build/conf/nsis/idea.nsi index 10b3987062b0..97aa7d75c7f4 100644 --- a/build/conf/nsis/idea.nsi +++ b/build/conf/nsis/idea.nsi @@ -297,6 +297,25 @@ done: Pop $0 FunctionEnd +Function downloadJre64 + !insertmacro INSTALLOPTIONS_READ $R0 "Desktop.ini" "Field 4" "State" + ${If} $R0 == 1 + inetc::get ${LINK_TO_JRE64} "$TEMP\jre64.tar.gz" /END + Pop $0 + ${If} $0 == "OK" + untgz::extract "-d" "$INSTDIR\jre64" "$TEMP\jre64.tar.gz" + StrCmp $R0 "success" removeTempJre64 + DetailPrint "Failed to extract jre64.tar.gz" + MessageBox MB_OK|MB_ICONEXCLAMATION|MB_DEFBUTTON1 "Failed to extract $TEMP\jre64.tar.gz" +removeTempJre64: + IfFileExists "$TEMP\jre64.tar.gz" 0 done + Delete "$TEMP\jre64.tar.gz" + ${Else} + MessageBox MB_OK|MB_ICONEXCLAMATION "The ${LINK_TO_JRE64} download is failed: $0" + ${EndIf} + ${EndIf} +done: +FunctionEnd ;------------------------------------------------------------------------------ ; Variables @@ -690,7 +709,12 @@ FunctionEnd ;------------------------------------------------------------------------------ Section "IDEA Files" CopyIdeaFiles -; create shortcuts + ;download and install JRE 64 + StrCmp "${LINK_TO_JRE64}" "null" shortcuts 0 + Call downloadJre64 + +shortcuts: + ;create shortcuts !insertmacro INSTALLOPTIONS_READ $R2 "Desktop.ini" "Field 2" "State" StrCmp $R2 1 "" exe_64 StrCpy $runProductAfterInstall "32" diff --git a/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy b/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy index 907f1a15e4f1..d24522470c5d 100644 --- a/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy +++ b/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy @@ -80,7 +80,7 @@ class IdeaCommunityProperties extends BaseIdeaProperties { } @Override - String getLinkToJre64() { "https://download.jetbrains.com/idea" } + String getBaseDownloadUrlForJre64() { "https://download.jetbrains.com/idea" } } } diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/WindowsDistributionCustomizer.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/WindowsDistributionCustomizer.groovy index 770547849824..c243956f2637 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/WindowsDistributionCustomizer.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/WindowsDistributionCustomizer.groovy @@ -99,9 +99,10 @@ abstract class WindowsDistributionCustomizer { } /** - * Link to tar.gz archive of JetBrains JRE 64-bit for windows. - * The archive is used by windows installer to download and install JRE 64-bit. + * The returned string is base part of a Url to tar.gz archive of JetBrains JRE 64-bit for windows. + * The URL composed from two parts. The described base part and archive name (is generated by BundledJreManager.archiveNameJre64). + * The Url is used by windows installer to download and install JRE 64-bit. * If the option is chosen by user JRE x86 and 64-bit will be install together. */ - String getLinkToJre64() { return null } + String getBaseDownloadUrlForJre64() { return null } } diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BundledJreManager.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BundledJreManager.groovy index 36cddca12bd8..78d894519911 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BundledJreManager.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BundledJreManager.groovy @@ -66,10 +66,10 @@ class BundledJreManager { } /** - * Return path to a .tar.gz archive containing distribution of JRE for Win OS which will be bundled with the product + * Return a .tar.gz archive containing distribution of JRE for Win OS which will be bundled with the product */ - String findWinJreArchive() { - return findJreArchive("win")?.absolutePath + File findWinJreArchive() { + return findJreArchive("win") } String archiveNameJre64(BuildContext buildContext) { diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy index 3ad9283864ac..8b46f59d07f2 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy @@ -131,8 +131,8 @@ class WinExeInstallerBuilder { def extensionsList = customizer.fileAssociations def fileAssociations = extensionsList.isEmpty() ? "NoAssociation" : extensionsList.join(",") - def linkToJre64 = customizer.getLinkToJre64() != null ? - "${customizer.getLinkToJre64()}/${buildContext.bundledJreManager.archiveNameJre64(buildContext)}" : + def linkToJre64 = customizer.getBaseDownloadUrlForJre64() != null ? + "${customizer.getBaseDownloadUrlForJre64()}/${buildContext.bundledJreManager.archiveNameJre64(buildContext)}" : null new File(box, "nsiconf/strings.nsi").text = """ !define MANUFACTURER "${buildContext.applicationInfo.shortCompanyName}" diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy index f318915f841f..7a430f1828bd 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy @@ -84,21 +84,22 @@ class WindowsDistributionBuilder extends OsSpecificDistributionBuilder { def jreDirectoryPath = arch != null ? buildContext.bundledJreManager.extractWinJre(arch) : null List jreDirectoryPaths = [jreDirectoryPath]; - if (customizer.buildZipArchive) { - if (customizer.getLinkToJre64() != null && arch != JvmArchitecture.x64) { - File archive = buildContext.bundledJreManager.findJreArchive("win") - if (archive != null) { - buildContext.ant.copy(file: archive, tofile: "${buildContext.paths.artifacts}/${buildContext.bundledJreManager.archiveNameJre64(buildContext)}", overwrite: "true") - //prepare JRE64 folder for win archive - def jreDirectoryPath64 = buildContext.bundledJreManager.extractWinJre(JvmArchitecture.x64) - if (! new File("${jreDirectoryPath64}/jre64").exists()) { - buildContext.ant.move(todir: "${jreDirectoryPath64}/jre64") { - fileset(dir: "${jreDirectoryPath64}/jre") - } + if (customizer.getBaseDownloadUrlForJre64() != null && arch != JvmArchitecture.x64) { + File archive = buildContext.bundledJreManager.findWinJreArchive() + if (archive != null && archive.exists()) { + buildContext.ant.copy(file: archive, tofile: "${buildContext.paths.artifacts}/${buildContext.bundledJreManager.archiveNameJre64(buildContext)}", overwrite: "true") + //prepare JRE64 folder for win archive + def jreDirectoryPath64 = buildContext.bundledJreManager.extractWinJre(JvmArchitecture.x64) + if (! new File("${jreDirectoryPath64}/jre64").exists()) { + buildContext.ant.move(todir: "${jreDirectoryPath64}/jre64") { + fileset(dir: "${jreDirectoryPath64}/jre") } - jreDirectoryPaths = [jreDirectoryPath, jreDirectoryPath64]; } + jreDirectoryPaths = [jreDirectoryPath, jreDirectoryPath64]; } + } + + if (customizer.buildZipArchive) { buildWinZip(jreDirectoryPaths, buildContext.productProperties.buildCrossPlatformDistribution ? ".win" : "", winDistPath) }