71 protected static final String WINDOWS_BUNDLER_PREFIX =
72 BUNDLER_PREFIX + "windows" + File.separator;
73
74 private final static String EXECUTABLE_NAME = "WinLauncher.exe";
75 private final static String LIBRARY_NAME = "packager.dll";
76
77 private final static String[] VS_VERS = {"100", "110", "120"};
78 private final static String REDIST_MSVCR = "msvcrVS_VER.dll";
79 private final static String REDIST_MSVCP = "msvcpVS_VER.dll";
80
81 private final static String TEMPLATE_APP_ICON ="javalogo_white_48.ico";
82 private static final String TOOL_ICON_SWAP="IconSwap.exe";
83 private static final String TOOL_VERSION_INFO_SWAP="VersionInfoSwap.exe";
84
85 private static final String EXECUTABLE_PROPERTIES_TEMPLATE = "WinLauncher.properties";
86
87 private final Path root;
88 private final Path appDir;
89 private final Path runtimeRoot;
90 private final Path mdir;
91 private final String jimage;
92
93 private final Map<String, ? super Object> params;
94
95 public static final BundlerParamInfo<File> CONFIG_ROOT = new WindowsBundlerParam<>(
96 I18N.getString("param.config-root.name"),
97 I18N.getString("param.config-root.description"),
98 "configRoot",
99 File.class,
100 params -> {
101 File imagesRoot = new File(BUILD_ROOT.fetchFrom(params), "windows");
102 imagesRoot.mkdirs();
103 return imagesRoot;
104 },
105 (s, p) -> null);
106
107 public static final BundlerParamInfo<Boolean> REBRAND_EXECUTABLE = new WindowsBundlerParam<>(
108 I18N.getString("param.rebrand-executable.name"),
109 I18N.getString("param.rebrand-executable.description"),
110 "win.launcher.rebrand",
111 Boolean.class,
117 I18N.getString("param.icon-ico.description"),
118 "icon.ico",
119 File.class,
120 params -> {
121 File f = ICON.fetchFrom(params);
122 if (f != null && !f.getName().toLowerCase().endsWith(".ico")) {
123 Log.info(MessageFormat.format(I18N.getString("message.icon-not-ico"), f));
124 return null;
125 }
126 return f;
127 },
128 (s, p) -> new File(s));
129
130
131
132 public WindowsAppImageBuilder(Map<String, Object> config, Path imageOutDir) throws IOException {
133 super(config, imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
134
135 Objects.requireNonNull(imageOutDir);
136
137 @SuppressWarnings("unchecked")
138 String img = (String) config.get("jimage.name"); // FIXME constant
139 jimage = img == null ? "bootmodules.jimage" : img; //FIXME constant
140
141 this.params = config;
142
143 this.root = imageOutDir.resolve(APP_NAME.fetchFrom(params));
144 this.appDir = root.resolve("app");
145 this.runtimeRoot = root.resolve("runtime");
146 this.mdir = runtimeRoot.resolve("lib").resolve("modules");
147 Files.createDirectories(mdir);
148 Files.createDirectories(appDir);
149 }
150
151 private Path destFile(String dir, String filename) {
152 return runtimeRoot.resolve(dir).resolve(filename);
153 }
154
155 private void writeEntry(InputStream in, Path dstFile) throws IOException {
156 Files.createDirectories(dstFile.getParent());
157 Files.copy(in, dstFile);
158 }
159
160 private void writeSymEntry(Path dstFile, Path target) throws IOException {
161 Files.createDirectories(dstFile.getParent());
162 Files.createLink(dstFile, target);
163 }
164
165 /**
166 * chmod ugo+x file
167 */
|
71 protected static final String WINDOWS_BUNDLER_PREFIX =
72 BUNDLER_PREFIX + "windows" + File.separator;
73
74 private final static String EXECUTABLE_NAME = "WinLauncher.exe";
75 private final static String LIBRARY_NAME = "packager.dll";
76
77 private final static String[] VS_VERS = {"100", "110", "120"};
78 private final static String REDIST_MSVCR = "msvcrVS_VER.dll";
79 private final static String REDIST_MSVCP = "msvcpVS_VER.dll";
80
81 private final static String TEMPLATE_APP_ICON ="javalogo_white_48.ico";
82 private static final String TOOL_ICON_SWAP="IconSwap.exe";
83 private static final String TOOL_VERSION_INFO_SWAP="VersionInfoSwap.exe";
84
85 private static final String EXECUTABLE_PROPERTIES_TEMPLATE = "WinLauncher.properties";
86
87 private final Path root;
88 private final Path appDir;
89 private final Path runtimeRoot;
90 private final Path mdir;
91
92 private final Map<String, ? super Object> params;
93
94 public static final BundlerParamInfo<File> CONFIG_ROOT = new WindowsBundlerParam<>(
95 I18N.getString("param.config-root.name"),
96 I18N.getString("param.config-root.description"),
97 "configRoot",
98 File.class,
99 params -> {
100 File imagesRoot = new File(BUILD_ROOT.fetchFrom(params), "windows");
101 imagesRoot.mkdirs();
102 return imagesRoot;
103 },
104 (s, p) -> null);
105
106 public static final BundlerParamInfo<Boolean> REBRAND_EXECUTABLE = new WindowsBundlerParam<>(
107 I18N.getString("param.rebrand-executable.name"),
108 I18N.getString("param.rebrand-executable.description"),
109 "win.launcher.rebrand",
110 Boolean.class,
116 I18N.getString("param.icon-ico.description"),
117 "icon.ico",
118 File.class,
119 params -> {
120 File f = ICON.fetchFrom(params);
121 if (f != null && !f.getName().toLowerCase().endsWith(".ico")) {
122 Log.info(MessageFormat.format(I18N.getString("message.icon-not-ico"), f));
123 return null;
124 }
125 return f;
126 },
127 (s, p) -> new File(s));
128
129
130
131 public WindowsAppImageBuilder(Map<String, Object> config, Path imageOutDir) throws IOException {
132 super(config, imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
133
134 Objects.requireNonNull(imageOutDir);
135
136 //@SuppressWarnings("unchecked")
137 //String img = (String) config.get("jimage.name"); // FIXME constant
138
139 this.params = config;
140
141 this.root = imageOutDir.resolve(APP_NAME.fetchFrom(params));
142 this.appDir = root.resolve("app");
143 this.runtimeRoot = root.resolve("runtime");
144 this.mdir = runtimeRoot.resolve("lib");
145 Files.createDirectories(appDir);
146 }
147
148 private Path destFile(String dir, String filename) {
149 return runtimeRoot.resolve(dir).resolve(filename);
150 }
151
152 private void writeEntry(InputStream in, Path dstFile) throws IOException {
153 Files.createDirectories(dstFile.getParent());
154 Files.copy(in, dstFile);
155 }
156
157 private void writeSymEntry(Path dstFile, Path target) throws IOException {
158 Files.createDirectories(dstFile.getParent());
159 Files.createLink(dstFile, target);
160 }
161
162 /**
163 * chmod ugo+x file
164 */
|