author | herrick |
Fri, 18 Oct 2019 14:14:37 -0400 | |
branch | JDK-8200758-branch |
changeset 58696 | 61c44899b4eb |
parent 58416 | f09bf58c1f17 |
child 58888 | d802578912f3 |
permissions | -rw-r--r-- |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
1 |
/* |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
4 |
* |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
8 |
* |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
13 |
* accompanied this code). |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
14 |
* |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
18 |
* |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
21 |
* questions. |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
22 |
*/ |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
23 |
package jdk.jpackage.test; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
24 |
|
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
25 |
import java.nio.file.Path; |
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
26 |
import java.util.HashMap; |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
27 |
import java.util.Map; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
28 |
|
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
29 |
|
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
30 |
final public class FileAssociations { |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
31 |
public FileAssociations(String faSuffixName) { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
32 |
suffixName = faSuffixName; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
33 |
setFilename("fa"); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
34 |
setDescription("jpackage test extention"); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
35 |
} |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
36 |
|
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
37 |
public void createFile() { |
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
38 |
Map<String, String> entries = new HashMap<>(Map.of( |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
39 |
"extension", suffixName, |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
40 |
"mime-type", getMime(), |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
41 |
"description", description |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
42 |
)); |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
43 |
if (icon != null) { |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
44 |
if (TKit.isWindows()) { |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
45 |
entries.put("icon", icon.toString().replace("\\", "/")); |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
46 |
} else { |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
47 |
entries.put("icon", icon.toString()); |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
48 |
} |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
49 |
} |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
50 |
TKit.createPropertiesFile(file, entries); |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
51 |
} |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
52 |
|
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
53 |
public FileAssociations setFilename(String v) { |
58416 | 54 |
file = TKit.workDir().resolve(v + ".properties"); |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
55 |
return this; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
56 |
} |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
57 |
|
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
58 |
public FileAssociations setDescription(String v) { |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
59 |
description = v; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
60 |
return this; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
61 |
} |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
62 |
|
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
63 |
public FileAssociations setIcon(Path v) { |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
64 |
icon = v; |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
65 |
return this; |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
66 |
} |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
67 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
68 |
public Path getPropertiesFile() { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
69 |
return file; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
70 |
} |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
71 |
|
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
72 |
public String getSuffix() { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
73 |
return "." + suffixName; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
74 |
} |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
75 |
|
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
76 |
public String getMime() { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
77 |
return "application/x-jpackage-" + suffixName; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
78 |
} |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
79 |
|
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
80 |
private Path file; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
81 |
final private String suffixName; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
82 |
private String description; |
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58416
diff
changeset
|
83 |
private Path icon; |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
diff
changeset
|
84 |
} |