modules/jdk.packager/src/main/java/jdk/packager/builders/linux/LinuxAppImageBuilder.java
Print this page
@@ -24,10 +24,11 @@
*/
package jdk.packager.builders.linux;
import com.oracle.tools.packager.BundlerParamInfo;
+import com.oracle.tools.packager.IOUtils;
import com.oracle.tools.packager.Log;
import com.oracle.tools.packager.RelativeFileSet;
import com.oracle.tools.packager.StandardBundlerParam;
import com.oracle.tools.packager.linux.LinuxResources;
import jdk.packager.builders.AbstractAppImageBuilder;
@@ -66,10 +67,11 @@
private static final String LIBRARY_NAME = "libpackager.so";
private final Path root;
private final Path appDir;
private final Path runtimeDir;
+ private final Path resourcesDir;
private final Path mdir;
private final Map<String, ? super Object> params;
public static final BundlerParamInfo<File> ICON_PNG = new StandardBundlerParam<>(
@@ -93,15 +95,17 @@
Objects.requireNonNull(imageOutDir);
this.root = imageOutDir.resolve(APP_NAME.fetchFrom(config));
this.appDir = root.resolve("app");
this.runtimeDir = root.resolve("runtime");
+ this.resourcesDir = root.resolve("resources");
this.mdir = runtimeDir.resolve("lib");
this.params = new HashMap<String, Object>();
config.entrySet().stream().forEach(e -> params.put(e.getKey().toString(), e.getValue()));
Files.createDirectories(appDir);
Files.createDirectories(runtimeDir);
+ Files.createDirectories(resourcesDir);
}
private Path destFile(String dir, String filename) {
return runtimeDir.resolve(dir).resolve(filename);
}
@@ -182,11 +186,11 @@
// Copy class path entries to Java folder
copyApplication();
// Copy icon to Resources folder
-//FIXME copyIcon(resourcesDirectory);
+ copyIcon();
} catch (IOException ex) {
Log.info("Exception: " + ex);
Log.debug(ex);
}
@@ -202,10 +206,16 @@
executableFile.toFile().setWritable(true, true);
writeCfgFile(p, root.resolve(getLauncherCfgName(p)).toFile(), "$APPDIR/runtime");
}
+ private void copyIcon() throws IOException {
+ File icon = ICON_PNG.fetchFrom(params);
+ File iconTarget = new File(resourcesDir.toFile(), APP_FS_NAME.fetchFrom(params) + ".png");
+ IOUtils.copyFile(icon, iconTarget);
+ }
+
private void copyApplication() throws IOException {
List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
if (appResourcesList == null) {
throw new RuntimeException("Null app resources?");
}