8217793: Modular jars in jpackage are not working JDK-8200758-branch
authorherrick
Wed, 30 Jan 2019 10:42:19 -0500
branchJDK-8200758-branch
changeset 57125 846d4865b362
parent 57119 b3dda8d77d8a
child 57126 8041f62342f0
8217793: Modular jars in jpackage are not working Reviewed-by: almatvee
src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java	Tue Jan 29 09:40:14 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java	Wed Jan 30 10:42:19 2019 -0500
@@ -165,8 +165,7 @@
 
             if (index > 0) {
                 result = mainModule.substring(0, index);
-            }
-            else {
+            } else {
                 result = mainModule;
             }
         }
@@ -271,16 +270,6 @@
                 mainJarType == ModFile.ModType.ModularJar) {
             String mainModule = getMainModule(params);
             addModules.add(mainModule);
-
-            // Error if any of the srcfiles are modular jars.
-            Set<String> modularJars =
-                    getResourceFileJarList(params, ModFile.JarType.ModularJar);
-
-            if (!modularJars.isEmpty()) {
-                throw new Exception(MessageFormat.format(I18N.getString(
-                        "error.srcfiles.contain.modules"),
-                        modularJars.toString()));
-            }
         }
         addModules.addAll(getValidModules(
                 modulePath, addModules, limitModules, false));
@@ -351,45 +340,6 @@
         return result;
     }
 
-    private static Set<String> getResourceFileJarList(
-            Map<String, ? super Object> params, ModFile.JarType Query) {
-        Set<String> files = new LinkedHashSet<String>();
-
-        String srcdir = StandardBundlerParam.SOURCE_DIR.fetchFrom(params);
-
-        for (RelativeFileSet appResources :
-                StandardBundlerParam.APP_RESOURCES_LIST.fetchFrom(params)) {
-            for (String resource : appResources.getIncludedFiles()) {
-                if (resource.endsWith(".jar")) {
-                    String filename = srcdir + File.separator + resource;
-
-                    switch (Query) {
-                        case All: {
-                            files.add(filename);
-                            break;
-                        }
-                        case ModularJar: {
-                            ModFile mod = new ModFile(new File(filename));
-                            if (mod.getModType() == ModFile.ModType.ModularJar) {
-                                files.add(filename);
-                            }
-                            break;
-                        }
-                        case UnnamedJar: {
-                            ModFile mod = new ModFile(new File(filename));
-                            if (mod.getModType() == ModFile.ModType.UnnamedJar) {
-                                files.add(filename);
-                            }
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-
-        return files;
-    }
-
     private static Set<String> removeInvalidModules(
             List<Path> modulePath, Set<String> modules) {
         Set<String> result = new LinkedHashSet<String>();
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties	Tue Jan 29 09:40:14 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties	Wed Jan 30 10:42:19 2019 -0500
@@ -142,7 +142,6 @@
 error.no-application-class.advice=Please specify main application class.
 error.no-main-module=Main application module is missing.
 error.no-main-module.advice=Make sure to use fx\:module task to create modular application.
-error.srcfiles.contain.modules=Error: Modules are not allowed in srcfiles: {0}.
 error.no-main-class-with-main-jar=An application class was not specified nor was one found in the jar {0}
 error.no-main-class-with-main-jar.advice=Please specify a application class or ensure that the jar {0} specifies one in the manifest.
 error.no-main-class=An application class was not specified nor was one found in the supplied application resources
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties	Tue Jan 29 09:40:14 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties	Wed Jan 30 10:42:19 2019 -0500
@@ -142,7 +142,6 @@
 error.no-application-class.advice=Please specify main application class.
 error.no-main-module=Main application module is missing.
 error.no-main-module.advice=Make sure to use fx\:module task to create modular application.
-error.srcfiles.contain.modules=Error: Modules are not allowed in srcfiles: {0}.
 error.no-main-class-with-main-jar=An application class was not specified nor was one found in the jar {0}
 error.no-main-class-with-main-jar.advice=Please specify a application class or ensure that the jar {0} specifies one in the manifest.
 error.no-main-class=An application class was not specified nor was one found in the supplied application resources
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties	Tue Jan 29 09:40:14 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties	Wed Jan 30 10:42:19 2019 -0500
@@ -142,7 +142,6 @@
 error.no-application-class.advice=Please specify main application class.
 error.no-main-module=Main application module is missing.
 error.no-main-module.advice=Make sure to use fx\:module task to create modular application.
-error.srcfiles.contain.modules=Error: Modules are not allowed in srcfiles: {0}.
 error.no-main-class-with-main-jar=An application class was not specified nor was one found in the jar {0}
 error.no-main-class-with-main-jar.advice=Please specify a application class or ensure that the jar {0} specifies one in the manifest.
 error.no-main-class=An application class was not specified nor was one found in the supplied application resources