49 private final String creatorVersion; |
49 private final String creatorVersion; |
50 private final String creatorPlatform; |
50 private final String creatorPlatform; |
51 private final String launcherName; |
51 private final String launcherName; |
52 private final List<String> addLauncherNames; |
52 private final List<String> addLauncherNames; |
53 |
53 |
54 public final static String FILENAME = ".jpackage.xml"; |
54 private final static String FILENAME = ".jpackage.xml"; |
55 |
55 |
56 private final static Map<Platform, String> PLATFORM_LABELS = Map.of( |
56 private final static Map<Platform, String> PLATFORM_LABELS = Map.of( |
57 Platform.LINUX, "linux", Platform.WINDOWS, "windows", Platform.MAC, |
57 Platform.LINUX, "linux", Platform.WINDOWS, "windows", Platform.MAC, |
58 "macOS"); |
58 "macOS"); |
59 |
59 |
89 void verifyCompatible() throws ConfigException { |
89 void verifyCompatible() throws ConfigException { |
90 // Just do nothing for now. |
90 // Just do nothing for now. |
91 } |
91 } |
92 |
92 |
93 /** |
93 /** |
|
94 * Returns path to application image info file. |
|
95 * @param appImageDir - path to application image |
|
96 */ |
|
97 public static Path getPathInAppImage(Path appImageDir) { |
|
98 return appImageDir.resolve(FILENAME); |
|
99 } |
|
100 |
|
101 /** |
94 * Saves file with application image info in application image. |
102 * Saves file with application image info in application image. |
95 * @param appImageDir - path to application image |
103 * @param appImageDir - path to application image |
96 * @throws IOException |
104 * @throws IOException |
97 */ |
105 */ |
98 static void save(Path appImage, Map<String, Object> params) |
106 static void save(Path appImageDir, Map<String, Object> params) |
99 throws IOException { |
107 throws IOException { |
100 IOUtils.createXml(appImage.resolve(FILENAME), xml -> { |
108 IOUtils.createXml(getPathInAppImage(appImageDir), xml -> { |
101 xml.writeStartElement("jpackage-state"); |
109 xml.writeStartElement("jpackage-state"); |
102 xml.writeAttribute("version", getVersion()); |
110 xml.writeAttribute("version", getVersion()); |
103 xml.writeAttribute("platform", getPlatform()); |
111 xml.writeAttribute("platform", getPlatform()); |
104 |
112 |
105 xml.writeStartElement("main-launcher"); |
113 xml.writeStartElement("main-launcher"); |
124 * @return valid info about application image or null |
132 * @return valid info about application image or null |
125 * @throws IOException |
133 * @throws IOException |
126 */ |
134 */ |
127 static AppImageFile load(Path appImageDir) throws IOException { |
135 static AppImageFile load(Path appImageDir) throws IOException { |
128 try { |
136 try { |
129 Path path = appImageDir.resolve(FILENAME); |
137 Path path = getPathInAppImage(appImageDir); |
130 DocumentBuilderFactory dbf = |
138 DocumentBuilderFactory dbf = |
131 DocumentBuilderFactory.newDefaultInstance(); |
139 DocumentBuilderFactory.newDefaultInstance(); |
132 dbf.setFeature( |
140 dbf.setFeature( |
133 "http://apache.org/xml/features/nonvalidating/load-external-dtd", |
141 "http://apache.org/xml/features/nonvalidating/load-external-dtd", |
134 false); |
142 false); |
175 } |
183 } |
176 } |
184 } |
177 |
185 |
178 /** |
186 /** |
179 * Returns list of launcher names configured for the application. |
187 * Returns list of launcher names configured for the application. |
180 * The first item in the returned list is man launcher name. |
188 * The first item in the returned list is main launcher name. |
181 * Following items in the list are names of additional launchers. |
189 * Following items in the list are names of additional launchers. |
182 */ |
190 */ |
183 static List<String> getLauncherNames(Path appImageDir, |
191 static List<String> getLauncherNames(Path appImageDir, |
184 Map<String, ? super Object> params) { |
192 Map<String, ? super Object> params) { |
185 List<String> launchers = new ArrayList<>(); |
193 List<String> launchers = new ArrayList<>(); |