Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8246624: Refactor JLinkBundlerHelper and StandardBundlerParam classes
Reviewed-by: herrick, almatvee
  • Loading branch information
Alexey Semenyuk committed Jun 8, 2020
1 parent 086c5f1 commit 045d61b5e01d399c7050bfcf24b3bc9911cd97a1
Showing with 431 additions and 995 deletions.
  1. +0 −15 src/jdk.incubator.jpackage/linux/classes/jdk/incubator/jpackage/internal/LinuxAppImageBuilder.java
  2. +2 −2 src/jdk.incubator.jpackage/linux/classes/jdk/incubator/jpackage/internal/LinuxDebBundler.java
  3. +5 −69 src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacAppImageBuilder.java
  4. +0 −1 ...cubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources.properties
  5. +0 −1 ...ator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_ja.properties
  6. +0 −1 ...r.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_zh_CN.properties
  7. +22 −20 ...jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/AbstractAppImageBuilder.java
  8. +6 −16 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/AbstractImageBundler.java
  9. +0 −31 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/ArgAction.java
  10. +4 −35 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/Arguments.java
  11. +1 −60 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/BundleParams.java
  12. +3 −53 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java
  13. +15 −153 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/JLinkBundlerHelper.java
  14. +281 −0 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/LauncherData.java
  15. +0 −120 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/ModFile.java
  16. +0 −80 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/RelativeFileSet.java
  17. +66 −306 src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/StandardBundlerParam.java
  18. +4 −1 ...cubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources.properties
  19. +4 −1 ...ator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_ja.properties
  20. +4 −1 ...r.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_zh_CN.properties
  21. +3 −1 src/jdk.incubator.jpackage/windows/classes/jdk/incubator/jpackage/internal/WinMsiBundler.java
  22. +0 −18 ...dk.incubator.jpackage/windows/classes/jdk/incubator/jpackage/internal/WindowsAppImageBuilder.java
  23. +8 −6 test/jdk/tools/jpackage/junit/jdk/incubator/jpackage/internal/AppImageFileTest.java
  24. +1 −2 test/jdk/tools/jpackage/junit/jdk/incubator/jpackage/internal/DeployParamsTest.java
  25. +2 −2 test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest.java
@@ -147,19 +147,4 @@ private void createLauncherForEntryPoint(Map<String, ? super Object> params,
iconResource.saveToFile(iconTarget);
}
}

private void copyApplication(Map<String, ? super Object> params)
throws IOException {
for (RelativeFileSet appResources :
APP_RESOURCES_LIST.fetchFrom(params)) {
if (appResources == null) {
throw new RuntimeException("Null app resources?");
}
File srcdir = appResources.getBaseDirectory();
for (String fname : appResources.getIncludedFiles()) {
copyEntry(appLayout.appDirectory(), srcdir, fname);
}
}
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -118,7 +118,7 @@ public class LinuxDebBundler extends LinuxPackageBundler {

private static final BundlerParamInfo<String> MAINTAINER =
new StandardBundlerParam<> (
BundleParams.PARAM_MAINTAINER,
Arguments.CLIOptions.LINUX_DEB_MAINTAINER.getId() + ".internal",
String.class,
params -> VENDOR.fetchFrom(params) + " <"
+ EMAIL.fetchFrom(params) + ">",
@@ -218,7 +218,7 @@ public void prepareApplicationFiles(Map<String, ? super Object> params)
}

// Copy class path entries to Java folder
copyClassPathEntries(appDir, params);
copyApplication(params);

/*********** Take care of "config" files *******/

@@ -312,35 +312,14 @@ static void prepareEntitlements(Map<String, ? super Object> params)
}

private static String getLauncherName(Map<String, ? super Object> params) {
if (APP_NAME.fetchFrom(params) != null) {
return APP_NAME.fetchFrom(params);
} else {
return MAIN_CLASS.fetchFrom(params);
}
return APP_NAME.fetchFrom(params);
}

public static String getLauncherCfgName(
Map<String, ? super Object> params) {
return "Contents/app/" + APP_NAME.fetchFrom(params) + ".cfg";
}

private void copyClassPathEntries(Path javaDirectory,
Map<String, ? super Object> params) throws IOException {
List<RelativeFileSet> resourcesList =
APP_RESOURCES_LIST.fetchFrom(params);
if (resourcesList == null) {
throw new RuntimeException(
I18N.getString("message.null-classpath"));
}

for (RelativeFileSet classPath : resourcesList) {
File srcdir = classPath.getBaseDirectory();
for (String fname : classPath.getIncludedFiles()) {
copyEntry(javaDirectory, srcdir, fname);
}
}
}

private String getBundleName(Map<String, ? super Object> params) {
if (MAC_CF_BUNDLE_NAME.fetchFrom(params) != null) {
String bn = MAC_CF_BUNDLE_NAME.fetchFrom(params);
@@ -399,50 +378,6 @@ private void writeInfoPlist(File file, Map<String, ? super Object> params)
data.put("DEPLOY_BUNDLE_SHORT_VERSION", VERSION.fetchFrom(params));
data.put("DEPLOY_BUNDLE_CFBUNDLE_VERSION", VERSION.fetchFrom(params));

boolean hasMainJar = MAIN_JAR.fetchFrom(params) != null;
boolean hasMainModule =
StandardBundlerParam.MODULE.fetchFrom(params) != null;

if (hasMainJar) {
data.put("DEPLOY_MAIN_JAR_NAME", MAIN_JAR.fetchFrom(params).
getIncludedFiles().iterator().next());
}
else if (hasMainModule) {
data.put("DEPLOY_MODULE_NAME",
StandardBundlerParam.MODULE.fetchFrom(params));
}

StringBuilder sb = new StringBuilder();
List<String> jvmOptions = JAVA_OPTIONS.fetchFrom(params);

String newline = ""; //So we don't add extra line after last append
for (String o : jvmOptions) {
sb.append(newline).append(
" <string>").append(o).append("</string>");
newline = "\n";
}

data.put("DEPLOY_JAVA_OPTIONS", sb.toString());

sb = new StringBuilder();
List<String> args = ARGUMENTS.fetchFrom(params);
newline = "";
// So we don't add unneccessary extra line after last append

for (String o : args) {
sb.append(newline).append(" <string>").append(o).append(
"</string>");
newline = "\n";
}
data.put("DEPLOY_ARGUMENTS", sb.toString());

newline = "";

data.put("DEPLOY_LAUNCHER_CLASS", MAIN_CLASS.fetchFrom(params));

data.put("DEPLOY_APP_CLASSPATH",
getCfgClassPath(CLASSPATH.fetchFrom(params)));

StringBuilder bundleDocumentTypes = new StringBuilder();
StringBuilder exportedTypes = new StringBuilder();
for (Map<String, ? super Object>
@@ -788,8 +723,9 @@ static void signAppBundle(
}
Path frameworkPath = appLocation.resolve("Contents/Frameworks");
if (Files.isDirectory(frameworkPath)) {
Files.list(frameworkPath)
.forEach(signIdentifiedByPList);
try (var fileList = Files.list(frameworkPath)) {
fileList.forEach(signIdentifiedByPList);
}

ioe = toThrow.get();
if (ioe != null) {
@@ -58,7 +58,6 @@ resource.pkg-background-image=pkg background image


message.bundle-name-too-long-warning={0} is set to ''{1}'', which is longer than 16 characters. For a better Mac experience consider shortening it.
message.null-classpath=Null app resources?
message.preparing-info-plist=Preparing Info.plist: {0}.
message.icon-not-icns= The specified icon "{0}" is not an ICNS file and will not be used. The default icon will be used in it's place.
message.version-string-too-many-components=Version sting may have between 1 and 3 numbers: 1, 1.2, 1.2.3.
@@ -59,7 +59,6 @@ resource.pkg-background-image=pkg\u80CC\u666F\u30A4\u30E1\u30FC\u30B8


message.bundle-name-too-long-warning={0}\u304C16\u6587\u5B57\u3092\u8D85\u3048\u308B''{1}''\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059\u3002Mac\u3067\u306E\u64CD\u4F5C\u6027\u3092\u3088\u308A\u826F\u304F\u3059\u308B\u305F\u3081\u306B\u77ED\u304F\u3059\u308B\u3053\u3068\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002
message.null-classpath=Null\u306E\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30FB\u30EA\u30BD\u30FC\u30B9\u3067\u3059\u304B\u3002
message.preparing-info-plist=Info.plist\u3092\u6E96\u5099\u3057\u3066\u3044\u307E\u3059: {0}\u3002
message.icon-not-icns= \u6307\u5B9A\u3057\u305F\u30A2\u30A4\u30B3\u30F3"{0}"\u306FICNS\u30D5\u30A1\u30A4\u30EB\u3067\u306F\u306A\u304F\u3001\u4F7F\u7528\u3055\u308C\u307E\u305B\u3093\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30A2\u30A4\u30B3\u30F3\u304C\u305D\u306E\u4F4D\u7F6E\u306B\u4F7F\u7528\u3055\u308C\u307E\u3059\u3002
message.version-string-too-many-components=\u30D0\u30FC\u30B8\u30E7\u30F3\u6587\u5B57\u5217\u306B\u306F\u30011\u30011.2\u30011.2.3\u306A\u30691\u304B\u30893\u306E\u6570\u5B57\u3092\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002
@@ -59,7 +59,6 @@ resource.pkg-background-image=pkg \u80CC\u666F\u56FE\u50CF


message.bundle-name-too-long-warning={0}\u5DF2\u8BBE\u7F6E\u4E3A ''{1}'', \u5176\u957F\u5EA6\u8D85\u8FC7\u4E86 16 \u4E2A\u5B57\u7B26\u3002\u4E3A\u4E86\u83B7\u5F97\u66F4\u597D\u7684 Mac \u4F53\u9A8C, \u8BF7\u8003\u8651\u5C06\u5176\u7F29\u77ED\u3002
message.null-classpath=\u662F\u5426\u4E3A\u7A7A\u5E94\u7528\u7A0B\u5E8F\u8D44\u6E90?
message.preparing-info-plist=\u6B63\u5728\u51C6\u5907 Info.plist: {0}\u3002
message.icon-not-icns= \u6307\u5B9A\u7684\u56FE\u6807 "{0}" \u4E0D\u662F ICNS \u6587\u4EF6, \u4E0D\u4F1A\u4F7F\u7528\u3002\u5C06\u4F7F\u7528\u9ED8\u8BA4\u56FE\u6807\u4EE3\u66FF\u3002
message.version-string-too-many-components=\u7248\u672C\u5B57\u7B26\u4E32\u53EF\u4EE5\u5305\u542B 1 \u5230 3 \u4E2A\u6570\u5B57: 1, 1.2, 1.2.3\u3002
@@ -89,42 +89,36 @@ public void writeCfgFile(Map<String, ? super Object> params,
File cfgFileName) throws IOException {
cfgFileName.getParentFile().mkdirs();
cfgFileName.delete();
File mainJar = JLinkBundlerHelper.getMainJar(params);
ModFile.ModType mainJarType = ModFile.ModType.Unknown;

if (mainJar != null) {
mainJarType = new ModFile(mainJar).getModType();
}

String mainModule = StandardBundlerParam.MODULE.fetchFrom(params);
LauncherData launcherData = StandardBundlerParam.LAUNCHER_DATA.fetchFrom(
params);

try (PrintStream out = new PrintStream(cfgFileName)) {

out.println("[Application]");
out.println("app.name=" + APP_NAME.fetchFrom(params));
out.println("app.version=" + VERSION.fetchFrom(params));
out.println("app.runtime=" + getCfgRuntimeDir());
out.println("app.classpath="
+ getCfgClassPath(CLASSPATH.fetchFrom(params)));

for (var path : launcherData.classPath()) {
out.println("app.classpath=" + getCfgAppDir()
+ path.toString().replace("\\", "/"));
}

// The main app is required to be a jar, modular or unnamed.
if (mainModule != null &&
(mainJarType == ModFile.ModType.Unknown ||
mainJarType == ModFile.ModType.ModularJar)) {
out.println("app.mainmodule=" + mainModule);
if (launcherData.isModular()) {
out.println("app.mainmodule=" + launcherData.moduleName() + "/"
+ launcherData.qualifiedClassName());
} else {
String mainClass =
StandardBundlerParam.MAIN_CLASS.fetchFrom(params);
// If the app is contained in an unnamed jar then launch it the
// legacy way and the main class string must be
// of the format com/foo/Main
if (mainJar != null) {
if (launcherData.mainJarName() != null) {
out.println("app.classpath=" + getCfgAppDir()
+ mainJar.toPath().getFileName().toString());
}
if (mainClass != null) {
out.println("app.mainclass=" + mainClass);
+ launcherData.mainJarName().toString());
}

out.println("app.mainclass=" + launcherData.qualifiedClassName());
}

out.println();
@@ -149,6 +143,14 @@ public void writeCfgFile(Map<String, ? super Object> params,
}
}

protected void copyApplication(Map<String, ? super Object> params)
throws IOException {
Path inputPath = StandardBundlerParam.SOURCE_DIR.fetchFrom(params);
if (inputPath != null) {
IOUtils.copyRecursive(SOURCE_DIR.fetchFrom(params), getAppDir());
}
}

File getRuntimeImageDir(File runtimeImageTop) {
return runtimeImageTop;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,11 +27,7 @@

import java.text.MessageFormat;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.File;
import java.io.IOException;

import static jdk.incubator.jpackage.internal.StandardBundlerParam.*;

@@ -49,13 +45,12 @@
*/
public abstract class AbstractImageBundler extends AbstractBundler {

private static final ResourceBundle I18N = ResourceBundle.getBundle(
"jdk.incubator.jpackage.internal.resources.MainResources");

public void imageBundleValidation(Map<String, ? super Object> params)
protected void imageBundleValidation(Map<String, ? super Object> params)
throws ConfigException {
StandardBundlerParam.validateMainClassInfoFromAppResources(params);

if (!params.containsKey(PREDEFINED_APP_IMAGE.getID())
&& !StandardBundlerParam.isRuntimeInstaller(params)) {
StandardBundlerParam.LAUNCHER_DATA.fetchFrom(params);
}
}

protected File createRoot(Map<String, ? super Object> params,
@@ -70,11 +65,6 @@ protected File createRoot(Map<String, ? super Object> params,
name, outputDirectory.getAbsolutePath()));
}

// NAME will default to CLASS, so the real problem is no MAIN_CLASS
if (name == null) {
throw new PackagerException("ERR_NoMainClass");
}

// Create directory structure
File rootDirectory = new File(outputDirectory, name);

This file was deleted.

0 comments on commit 045d61b

Please sign in to comment.