1 /*
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
174 boolean appCDEnabled = UNLOCK_COMMERCIAL_FEATURES.fetchFrom(params) && ENABLE_APP_CDS.fetchFrom(params);
175 String appCDSCacheMode = APP_CDS_CACHE_MODE.fetchFrom(params);
176 File mainJar = JLinkBundlerHelper.getMainJar(params);
177 Module.ModuleType mainJarType = Module.ModuleType.Unknown;
178
179 if (mainJar != null) {
180 mainJarType = new Module(mainJar).getModuleType();
181 }
182
183 String mainModule = StandardBundlerParam.MODULE.fetchFrom(params);
184
185 PrintStream out = new PrintStream(cfgFileName);
186
187 out.println("[Application]");
188 out.println("app.name=" + APP_NAME.fetchFrom(params));
189 out.println("app.version=" + VERSION.fetchFrom(params));
190 out.println("app.preferences.id=" + PREFERENCES_ID.fetchFrom(params));
191 out.println("app.runtime=" + runtimeLocation);
192 out.println("app.identifier=" + IDENTIFIER.fetchFrom(params));
193 out.println("app.classpath=" + String.join(File.pathSeparator, CLASSPATH.fetchFrom(params).split("[ :;]")));
194
195 // The main app is required to be a jar, modular or unnamed.
196 if (mainJarType == Module.ModuleType.Unknown || mainJarType == Module.ModuleType.ModularJar) {
197 if (mainModule != null) {
198 out.println("app.mainmodule=" + mainModule); // TODO get app class from main module mainifest.
199 }
200 }
201 else {
202 String mainClass = JLinkBundlerHelper.getMainClass(params);
203
204 if (mainJar != null && mainClass != null) {
205 // If the app is contained in an unnamed jar then launch it the
206 // legacy way and the main class string must be of the format com/foo/Main
207 out.println("app.mainclass=" + mainClass.replaceAll("\\.", "/"));
208 out.println("app.mainjar=" + mainJar.toPath().getFileName().toString());
209 }
210 }
211
212 String version = JLinkBundlerHelper.getJDKVersion(params);
213
|
1 /*
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
174 boolean appCDEnabled = UNLOCK_COMMERCIAL_FEATURES.fetchFrom(params) && ENABLE_APP_CDS.fetchFrom(params);
175 String appCDSCacheMode = APP_CDS_CACHE_MODE.fetchFrom(params);
176 File mainJar = JLinkBundlerHelper.getMainJar(params);
177 Module.ModuleType mainJarType = Module.ModuleType.Unknown;
178
179 if (mainJar != null) {
180 mainJarType = new Module(mainJar).getModuleType();
181 }
182
183 String mainModule = StandardBundlerParam.MODULE.fetchFrom(params);
184
185 PrintStream out = new PrintStream(cfgFileName);
186
187 out.println("[Application]");
188 out.println("app.name=" + APP_NAME.fetchFrom(params));
189 out.println("app.version=" + VERSION.fetchFrom(params));
190 out.println("app.preferences.id=" + PREFERENCES_ID.fetchFrom(params));
191 out.println("app.runtime=" + runtimeLocation);
192 out.println("app.identifier=" + IDENTIFIER.fetchFrom(params));
193 out.println("app.classpath=" + String.join(File.pathSeparator, CLASSPATH.fetchFrom(params).split("[ :;]")));
194 out.println("app.application.instance=" + (SINGLETON.fetchFrom(params) ? "single" : "multiple"));
195
196 // The main app is required to be a jar, modular or unnamed.
197 if (mainJarType == Module.ModuleType.Unknown || mainJarType == Module.ModuleType.ModularJar) {
198 if (mainModule != null) {
199 out.println("app.mainmodule=" + mainModule); // TODO get app class from main module mainifest.
200 }
201 }
202 else {
203 String mainClass = JLinkBundlerHelper.getMainClass(params);
204
205 if (mainJar != null && mainClass != null) {
206 // If the app is contained in an unnamed jar then launch it the
207 // legacy way and the main class string must be of the format com/foo/Main
208 out.println("app.mainclass=" + mainClass.replaceAll("\\.", "/"));
209 out.println("app.mainjar=" + mainJar.toPath().getFileName().toString());
210 }
211 }
212
213 String version = JLinkBundlerHelper.getJDKVersion(params);
214
|