8214575: Exe installers will install application to already existing instalation JDK-8200758-branch
authorherrick
Thu, 06 Dec 2018 16:45:26 -0500
branchJDK-8200758-branch
changeset 57062 044e7a644ee3
parent 57061 ac44f38300b2
child 57063 1fa5c73d3c5a
8214575: Exe installers will install application to already existing instalation Submitten-by: almatvee Reviewed-by: herrick. kcr
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundleParams.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.iss
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.jre.iss
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Thu Dec 06 16:45:26 2018 -0500
@@ -382,7 +382,7 @@
 
         WIN_REGISTRY_NAME ("win-registry-name", OptionCategories.PLATFORM_WIN),
 
-        WIN_MSI_UPGRADE_UUID ("win-upgrade-uuid",
+        WIN_UPGRADE_UUID ("win-upgrade-uuid",
                 OptionCategories.PLATFORM_WIN),
 
         WIN_CONSOLE_HINT ("win-console", OptionCategories.PLATFORM_WIN, () -> {
@@ -664,7 +664,7 @@
                 throw new PackagerException("ERR_NoJreInstallerName");
             }
 
-            generateBundle(bp.getBundleParamsAsMap());
+            return generateBundle(bp.getBundleParamsAsMap());
         } catch (Exception e) {
             if (Log.isVerbose()) {
                 throw e;
@@ -676,7 +676,6 @@
                 return false;
             }
         }
-        return true;
     }
 
     private void validateArguments() {
@@ -713,8 +712,10 @@
         return platformBundlers;
     }
 
-    private void generateBundle(Map<String,? super Object> params)
+    private boolean generateBundle(Map<String,? super Object> params)
             throws PackagerException {
+        boolean bundleCreated = false;
+
         for (jdk.jpackage.internal.Bundler bundler : getPlatformBundlers()) {
             Map<String, ? super Object> localParams = new HashMap<>(params);
             try {
@@ -726,6 +727,7 @@
                         throw new PackagerException("MSG_BundlerFailed",
                                 bundler.getID(), bundler.getName());
                     }
+                    bundleCreated = true; // Set that at least one bundle was created
                 }
             } catch (UnsupportedPlatformException e) {
                 Log.debug(MessageFormat.format(
@@ -749,6 +751,8 @@
                 Log.debug(re);
             }
         }
+
+        return bundleCreated;
     }
 
     private void addResources(DeployParams deployParams,
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundleParams.java	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundleParams.java	Thu Dec 06 16:45:26 2018 -0500
@@ -301,31 +301,6 @@
         return ARGUMENTS.fetchFrom(params);
     }
 
-    // Validation approach:
-    //  - javac and
-    //
-    //  - /jmods dir
-    // or
-    //  - JRE marker (rt.jar)
-    //  - FX marker (jfxrt.jar)
-    //  - JDK marker (tools.jar)
-    private static boolean checkJDKRoot(File jdkRoot) {
-        String exe = (Platform.getPlatform() == Platform.WINDOWS) ?
-                ".exe" : "";
-        File javac = new File(jdkRoot, "bin/javac" + exe);
-        if (!javac.exists()) {
-            Log.verbose("javac is not found at " + javac.getAbsolutePath());
-            return false;
-        }
-
-        File jmods = new File(jdkRoot, "jmods");
-        if (!jmods.exists()) {
-            Log.verbose("jmods is not found in " + jdkRoot.getAbsolutePath());
-            return false;
-        }
-        return true;
-    }
-
     public jdk.jpackage.internal.RelativeFileSet getAppResource() {
         return fetchParam(APP_RESOURCES);
     }
@@ -378,22 +353,6 @@
     }
 
     private String mainJar = null;
-    private String mainJarClassPath = null;
-    private boolean useFXPackaging = true;
-
-    // For regular executable Jars we need to take care of classpath
-    // For JavaFX executable jars we do not need to pay attention to
-    // ClassPath entry in manifest
-    public String getAppClassPath() {
-        if (mainJar == null) {
-            // this will find out answer
-            getMainApplicationJar();
-        }
-        if (useFXPackaging || mainJarClassPath == null) {
-            return "";
-        }
-        return mainJarClassPath;
-    }
 
     // assuming that application was packaged according to the rules
     // we must have application jar, i.e. jar where we embed launcher
@@ -442,8 +401,6 @@
 
                     if (javaMain) {
                         mainJar = fname;
-                        mainJarClassPath = attrs.getValue(
-                               Attributes.Name.CLASS_PATH);
                         return mainJar;
                     }
                 }
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java	Thu Dec 06 16:45:26 2018 -0500
@@ -86,10 +86,6 @@
         return id;
     }
 
-    public void setId(String id) {
-        this.id = id;
-    }
-
     public Class<T> getValueType() {
         return valueType;
     }
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java	Thu Dec 06 16:45:26 2018 -0500
@@ -97,10 +97,6 @@
     // raw arguments to the bundler
     Map<String, ? super Object> bundlerArguments = new LinkedHashMap<>();
 
-    public void setId(String id) {
-        this.id = id;
-    }
-
     public void setCategory(String category) {
         this.category = category;
     }
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java	Thu Dec 06 16:45:26 2018 -0500
@@ -137,7 +137,7 @@
                     CLIOptions.WIN_PER_USER_INSTALLATION);
             add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_DIR_CHOOSER);
             add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_REGISTRY_NAME);
-            add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_MSI_UPGRADE_UUID);
+            add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_UPGRADE_UUID);
             add(CLIOptions.CREATE_INSTALLER, CLIOptions.CATEGORY);
             add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_CONSOLE_HINT);
         }
@@ -178,7 +178,7 @@
                     CLIOptions.WIN_PER_USER_INSTALLATION);
             add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.WIN_DIR_CHOOSER);
             add(CLIOptions.CREATE_JRE_INSTALLER,
-                    CLIOptions.WIN_MSI_UPGRADE_UUID);
+                    CLIOptions.WIN_UPGRADE_UUID);
             add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.DESCRIPTION);
             add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.VENDOR);
         }
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java	Thu Dec 06 16:45:26 2018 -0500
@@ -91,6 +91,14 @@
             null,
             (s, p) -> null);
 
+    public static final BundlerParamInfo<UUID> UPGRADE_UUID =
+            new WindowsBundlerParam<>(
+            I18N.getString("param.upgrade-uuid.name"),
+            I18N.getString("param.upgrade-uuid.description"),
+            Arguments.CLIOptions.WIN_UPGRADE_UUID.getId(),
+            UUID.class,
+            params -> UUID.randomUUID(),
+            (s, p) -> UUID.fromString(s));
 
     public static final StandardBundlerParam<Boolean> EXE_SYSTEM_WIDE  =
             new StandardBundlerParam<>(
@@ -134,8 +142,6 @@
                        "null".equalsIgnoreCase(s))? false : Boolean.valueOf(s)
         );
 
-
-
     private final static String DEFAULT_EXE_PROJECT_TEMPLATE = "template.iss";
     private final static String DEFAULT_JRE_EXE_TEMPLATE = "template.jre.iss";
     private static final String TOOL_INNO_SETUP_COMPILER = "iscc.exe";
@@ -511,11 +517,7 @@
     }
 
     private String getAppIdentifier(Map<String, ? super Object> p) {
-        String nm = IDENTIFIER.fetchFrom(p);
-
-        if (nm == null) {
-            nm = APP_NAME.fetchFrom(p);
-        }
+        String nm = UPGRADE_UUID.fetchFrom(p).toString();
 
         // limitation of innosetup
         if (nm.length() > 126) {
@@ -526,7 +528,6 @@
         return nm;
     }
 
-
     private String getLicenseFile(Map<String, ? super Object> p) {
         List<String> licenseFiles = LICENSE_FILE.fetchFrom(p);
         if (licenseFiles == null || licenseFiles.isEmpty()) {
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java	Thu Dec 06 16:45:26 2018 -0500
@@ -128,10 +128,9 @@
             new WindowsBundlerParam<>(
             I18N.getString("param.upgrade-uuid.name"),
             I18N.getString("param.upgrade-uuid.description"),
-            Arguments.CLIOptions.WIN_MSI_UPGRADE_UUID.getId(),
+            Arguments.CLIOptions.WIN_UPGRADE_UUID.getId(),
             UUID.class,
-            params -> UUID.randomUUID(), // TODO check to see
-                    // if identifier is a valid UUID during default
+            params -> UUID.randomUUID(),
             (s, p) -> UUID.fromString(s));
 
     private static final String TOOL_CANDLE = "candle.exe";
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.iss	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.iss	Thu Dec 06 16:45:26 2018 -0500
@@ -1,7 +1,7 @@
 ;This file will be executed next to the application bundle image
 ;I.e. current directory will contain folder INSTALLER_NAME with application files
 [Setup]
-AppId={{PRODUCT_APP_IDENTIFIER}}
+AppId=PRODUCT_APP_IDENTIFIER
 AppName=INSTALLER_NAME
 AppVersion=APPLICATION_VERSION
 AppVerName=INSTALLER_NAME APPLICATION_VERSION
@@ -19,7 +19,7 @@
 ;Optional License
 LicenseFile=APPLICATION_LICENSE_FILE
 ;WinXP or above
-MinVersion=0,5.1 
+MinVersion=0,5.1
 OutputBaseFilename=INSTALLER_FILE_NAME
 Compression=lzma
 SolidCompression=yes
@@ -28,7 +28,7 @@
 UninstallDisplayIcon={app}\LAUNCHER_NAME.ico
 UninstallDisplayName=INSTALLER_NAME
 WizardImageStretch=No
-WizardSmallImageFile=INSTALLER_NAME-setup-icon.bmp   
+WizardSmallImageFile=INSTALLER_NAME-setup-icon.bmp
 ArchitecturesInstallIn64BitMode=ARCHITECTURE_BIT_MODE
 FILE_ASSOCIATIONS
 
@@ -69,4 +69,4 @@
 //   if version less or same => just launch app
 //   if upgrade => check if same app is running and wait for it to exit
   Result := True;
-end;  
+end;
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.jre.iss	Wed Dec 05 17:05:42 2018 -0500
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.jre.iss	Thu Dec 06 16:45:26 2018 -0500
@@ -1,7 +1,7 @@
 ;This file will be executed next to the application bundle image
 ;I.e. current directory will contain folder INSTALLER_NAME with application files
 [Setup]
-AppId={{PRODUCT_APP_IDENTIFIER}}
+AppId=PRODUCT_APP_IDENTIFIER
 AppName=INSTALLER_NAME
 AppVersion=APPLICATION_VERSION
 AppVerName=INSTALLER_NAME APPLICATION_VERSION
@@ -19,7 +19,7 @@
 ;Optional License
 LicenseFile=APPLICATION_LICENSE_FILE
 ;WinXP or above
-MinVersion=0,5.1 
+MinVersion=0,5.1
 OutputBaseFilename=INSTALLER_FILE_NAME
 Compression=lzma
 SolidCompression=yes
@@ -28,7 +28,7 @@
 UninstallDisplayIcon=
 UninstallDisplayName=INSTALLER_NAME
 WizardImageStretch=No
-WizardSmallImageFile=INSTALLER_NAME-setup-icon.bmp   
+WizardSmallImageFile=INSTALLER_NAME-setup-icon.bmp
 ArchitecturesInstallIn64BitMode=ARCHITECTURE_BIT_MODE
 FILE_ASSOCIATIONS
 
@@ -52,4 +52,4 @@
 function InitializeSetup(): Boolean;
 begin
   Result := True;
-end;  
+end;