author | herrick |
Thu, 06 Jun 2019 19:51:17 -0400 | |
branch | JDK-8200758-branch |
changeset 57396 | 3944e4c2f779 |
parent 57392 | 46d4b0aa4542 |
child 57407 | 2c14fbeff1dc |
permissions | -rw-r--r-- |
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57059
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
4 |
* |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
10 |
* |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
15 |
* accompanied this code). |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
16 |
* |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
20 |
* |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
23 |
* questions. |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
24 |
*/ |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
25 |
|
57039 | 26 |
package jdk.jpackage.internal; |
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
27 |
|
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
28 |
import java.text.MessageFormat; |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
29 |
import java.util.Map; |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
30 |
import java.util.ResourceBundle; |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
31 |
import java.util.regex.Matcher; |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
32 |
import java.util.regex.Pattern; |
57021
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
33 |
import java.io.File; |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
34 |
import java.io.IOException; |
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
35 |
|
57039 | 36 |
import static jdk.jpackage.internal.StandardBundlerParam.*; |
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
37 |
|
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
38 |
/** |
56994
b4aca2dbe2b5
8212537: Create method and class description comments for main functionality
herrick
parents:
56982
diff
changeset
|
39 |
* AbstractImageBundler |
b4aca2dbe2b5
8212537: Create method and class description comments for main functionality
herrick
parents:
56982
diff
changeset
|
40 |
* |
b4aca2dbe2b5
8212537: Create method and class description comments for main functionality
herrick
parents:
56982
diff
changeset
|
41 |
* This is the base class for each of the Application Image Bundlers. |
b4aca2dbe2b5
8212537: Create method and class description comments for main functionality
herrick
parents:
56982
diff
changeset
|
42 |
* |
b4aca2dbe2b5
8212537: Create method and class description comments for main functionality
herrick
parents:
56982
diff
changeset
|
43 |
* It contains methods and parameters common to all Image Bundlers. |
b4aca2dbe2b5
8212537: Create method and class description comments for main functionality
herrick
parents:
56982
diff
changeset
|
44 |
* |
57307 | 45 |
* Application Image Bundlers are created in "create-app-image" mode, |
57392 | 46 |
* or as an intermediate step in "create-installer" mode. |
56994
b4aca2dbe2b5
8212537: Create method and class description comments for main functionality
herrick
parents:
56982
diff
changeset
|
47 |
* |
b4aca2dbe2b5
8212537: Create method and class description comments for main functionality
herrick
parents:
56982
diff
changeset
|
48 |
* The concrete implementations are in the platform specific Bundlers. |
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
49 |
*/ |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
50 |
public abstract class AbstractImageBundler extends AbstractBundler { |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
51 |
|
56869
41e17fe9fbeb
8208522: removed unreferenced class and minor formatting of java source
herrick
parents:
56821
diff
changeset
|
52 |
private static final ResourceBundle I18N = ResourceBundle.getBundle( |
57059 | 53 |
"jdk.jpackage.internal.resources.MainResources"); |
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
54 |
|
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57392
diff
changeset
|
55 |
public void imageBundleValidation(Map<String, ? super Object> params) |
56869
41e17fe9fbeb
8208522: removed unreferenced class and minor formatting of java source
herrick
parents:
56821
diff
changeset
|
56 |
throws ConfigException { |
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57392
diff
changeset
|
57 |
StandardBundlerParam.validateMainClassInfoFromAppResources(params); |
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
58 |
|
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
59 |
} |
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
60 |
|
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57392
diff
changeset
|
61 |
protected File createRoot(Map<String, ? super Object> params, |
57256 | 62 |
File outputDirectory, boolean dependentTask, String name) |
63 |
throws PackagerException { |
|
57021
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
64 |
if (!outputDirectory.isDirectory() && !outputDirectory.mkdirs()) { |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
65 |
throw new RuntimeException(MessageFormat.format( |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
66 |
I18N.getString("error.cannot-create-output-dir"), |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
67 |
outputDirectory.getAbsolutePath())); |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
68 |
} |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
69 |
if (!outputDirectory.canWrite()) { |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
70 |
throw new RuntimeException(MessageFormat.format( |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
71 |
I18N.getString("error.cannot-write-to-output-dir"), |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
72 |
outputDirectory.getAbsolutePath())); |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
73 |
} |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
74 |
if (!dependentTask) { |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
75 |
Log.verbose(MessageFormat.format( |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
76 |
I18N.getString("message.creating-app-bundle"), |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
77 |
name, outputDirectory.getAbsolutePath())); |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
78 |
} |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
79 |
|
57389
cce526c681dc
8222901: different behavior when --name option not used
herrick
parents:
57307
diff
changeset
|
80 |
// NAME will default to CLASS, so the real problem is no MAIN_CLASS |
cce526c681dc
8222901: different behavior when --name option not used
herrick
parents:
57307
diff
changeset
|
81 |
if (name == null) { |
cce526c681dc
8222901: different behavior when --name option not used
herrick
parents:
57307
diff
changeset
|
82 |
throw new PackagerException("ERR_NoMainClass"); |
cce526c681dc
8222901: different behavior when --name option not used
herrick
parents:
57307
diff
changeset
|
83 |
} |
cce526c681dc
8222901: different behavior when --name option not used
herrick
parents:
57307
diff
changeset
|
84 |
|
57021
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
85 |
// Create directory structure |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
86 |
File rootDirectory = new File(outputDirectory, name); |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
87 |
|
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
88 |
if (rootDirectory.exists()) { |
57256 | 89 |
throw new PackagerException("error.root-exists", |
90 |
rootDirectory.getAbsolutePath()); |
|
57021
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
91 |
} |
57256 | 92 |
|
57021
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
93 |
rootDirectory.mkdirs(); |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
94 |
|
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
95 |
return rootDirectory; |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
96 |
} |
441c020bf626
8213324:jpackager deletes existing app directory without warning
herrick
parents:
57017
diff
changeset
|
97 |
|
56821
565d54ca1f41
8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff
changeset
|
98 |
} |