< prev index next >

src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java

Print this page

        

*** 66,76 **** public abstract void prepareApplicationFiles() throws IOException; public abstract void prepareJreFiles() throws IOException; public abstract Path getAppDir(); public abstract Path getAppModsDir(); - public abstract String getRelativeModsDir(); public Path getRoot() { return this.root; } --- 66,75 ----
*** 171,181 **** return result; } } public void writeCfgFile(Map<String, ? super Object> params, ! File cfgFileName, String runtimeLocation) throws IOException { cfgFileName.delete(); File mainJar = JLinkBundlerHelper.getMainJar(params); ModFile.ModType mainJarType = ModFile.ModType.Unknown; if (mainJar != null) { --- 170,180 ---- return result; } } public void writeCfgFile(Map<String, ? super Object> params, ! File cfgFileName) throws IOException { cfgFileName.delete(); File mainJar = JLinkBundlerHelper.getMainJar(params); ModFile.ModType mainJarType = ModFile.ModType.Unknown; if (mainJar != null) {
*** 187,199 **** 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=" + runtimeLocation); out.println("app.identifier=" + IDENTIFIER.fetchFrom(params)); ! out.println("app.classpath=" + CLASSPATH.fetchFrom(params)); // The main app is required to be a jar, modular or unnamed. if (mainModule != null && (mainJarType == ModFile.ModType.Unknown || mainJarType == ModFile.ModType.ModularJar)) { --- 186,199 ---- 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.identifier=" + IDENTIFIER.fetchFrom(params)); ! out.println("app.classpath=" ! + getCfgClassPath(CLASSPATH.fetchFrom(params))); // The main app is required to be a jar, modular or unnamed. if (mainModule != null && (mainJarType == ModFile.ModType.Unknown || mainJarType == ModFile.ModType.ModularJar)) {
*** 202,217 **** String mainClass = JLinkBundlerHelper.getMainClass(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) { ! out.println("app.mainjar=" + mainJar.toPath().getFileName().toString()); } if (mainClass != null) { out.println("app.mainclass=" ! + mainClass.replaceAll("\\.", "/")); } } out.println(); out.println("[JavaOptions]"); --- 202,217 ---- String mainClass = JLinkBundlerHelper.getMainClass(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) { ! out.println("app.mainjar=" + getCfgAppDir() + mainJar.toPath().getFileName().toString()); } if (mainClass != null) { out.println("app.mainclass=" ! + mainClass.replace("\\", "/")); } } out.println(); out.println("[JavaOptions]");
*** 221,231 **** } Path modsDir = getAppModsDir(); if (modsDir != null && modsDir.toFile().exists()) { out.println("--module-path"); ! out.println("$APPDIR/" + getRelativeModsDir()); } out.println(); out.println("[ArgOptions]"); List<String> args = ARGUMENTS.fetchFrom(params); --- 221,231 ---- } Path modsDir = getAppModsDir(); if (modsDir != null && modsDir.toFile().exists()) { out.println("--module-path"); ! out.println(getCfgAppDir().replace("\\","/") + "mods"); } out.println(); out.println("[ArgOptions]"); List<String> args = ARGUMENTS.fetchFrom(params);
*** 239,244 **** --- 239,269 ---- } } } } + String getCfgAppDir() { + return "$APPDIR" + File.separator + + getAppDir().getFileName() + File.separator; + } + + String getCfgRuntimeDir() { + return "$APPDIR" + File.separator + "runtime"; + } + + String getCfgClassPath(String classpath) { + String cfgAppDir = getCfgAppDir(); + + StringBuilder sb = new StringBuilder(); + for (String path : classpath.split("[:;]")) { + if (path.length() > 0) { + sb.append(cfgAppDir); + sb.append(path); + sb.append(File.pathSeparator); + } + } + if (sb.length() > 0) { + sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } }
< prev index next >