< prev index next >
modules/jdk.packager/src/main/java/com/oracle/tools/packager/StandardBundlerParam.java
Print this page
*** 640,653 ****
new StandardBundlerParam<>(
I18N.getString("param.module-path.name"),
I18N.getString("param.module-path.description"),
"module-path",
(Class<List<Path>>) (Object)List.class,
! p -> {setupDefaultModulePathIfNecessary(p); return new ArrayList();},
! (s, p) -> Arrays.asList(s.split("[;:]")).stream()
.map(ss -> new File(ss).toPath())
! .collect(Collectors.toList()));
@SuppressWarnings("unchecked")
public static final BundlerParamInfo<String> MODULE =
new StandardBundlerParam<>(
I18N.getString("param.main.module.name"),
--- 640,679 ----
new StandardBundlerParam<>(
I18N.getString("param.module-path.name"),
I18N.getString("param.module-path.description"),
"module-path",
(Class<List<Path>>) (Object)List.class,
! p -> { return getDefaultModulePath(); },
! (s, p) -> {
! List<Path> modulePath = Arrays.asList(s.split("[;:]")).stream()
.map(ss -> new File(ss).toPath())
! .collect(Collectors.toList());
! Path userDefinedJdkModulePath = null;
! if (modulePath != null) {
! userDefinedJdkModulePath = JLinkBundlerHelper.findPathOfModule(modulePath, "java.base.jmod");
! }
! else {
! modulePath = new ArrayList();
! }
!
! // Add the default JDK module path to the module path.
! if (userDefinedJdkModulePath == null) {
! List<Path> jdkModulePath = getDefaultModulePath();
!
! if (jdkModulePath != null) {
! modulePath.addAll(jdkModulePath);
! }
! }
!
! Path javaBasePath = findPathOfModule(modulePath, "java.base.jmod");
!
! if (javaBasePath == null || !javaBasePath.toFile().exists()) {
! com.oracle.tools.packager.Log.info(String.format(I18N.getString("warning.no.jdk.modules.found")));
! }
!
! return modulePath;
! });
@SuppressWarnings("unchecked")
public static final BundlerParamInfo<String> MODULE =
new StandardBundlerParam<>(
I18N.getString("param.main.module.name"),
*** 665,695 ****
I18N.getString("param.add-modules.name"),
I18N.getString("param.add-modules.description"),
"add-modules",
(Class<Set<String>>) (Object) Set.class,
p -> new LinkedHashSet(),
! (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split("[,;: ]+"))));
@SuppressWarnings("unchecked")
public static final BundlerParamInfo<Set<String>> LIMIT_MODULES =
new StandardBundlerParam<>(
I18N.getString("param.limit-modules.name"),
I18N.getString("param.limit-modules.description"),
"limit-modules",
(Class<Set<String>>) (Object) Set.class,
p -> new LinkedHashSet(),
! (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split("[,;: ]+"))));
@SuppressWarnings("unchecked")
public static final BundlerParamInfo<Boolean> STRIP_NATIVE_COMMANDS =
new StandardBundlerParam<>(
I18N.getString("param.strip-executables.name"),
I18N.getString("param.strip-executables.description"),
"strip-native-commands",
Boolean.class,
p -> Boolean.TRUE,
! (s, p) -> Boolean.valueOf(s));
public static void extractMainClassInfoFromAppResources(Map<String, ? super Object> params) {
boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
--- 691,724 ----
I18N.getString("param.add-modules.name"),
I18N.getString("param.add-modules.description"),
"add-modules",
(Class<Set<String>>) (Object) Set.class,
p -> new LinkedHashSet(),
! (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split("[,;: ]+")))
! );
@SuppressWarnings("unchecked")
public static final BundlerParamInfo<Set<String>> LIMIT_MODULES =
new StandardBundlerParam<>(
I18N.getString("param.limit-modules.name"),
I18N.getString("param.limit-modules.description"),
"limit-modules",
(Class<Set<String>>) (Object) Set.class,
p -> new LinkedHashSet(),
! (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split("[,;: ]+")))
! );
@SuppressWarnings("unchecked")
public static final BundlerParamInfo<Boolean> STRIP_NATIVE_COMMANDS =
new StandardBundlerParam<>(
I18N.getString("param.strip-executables.name"),
I18N.getString("param.strip-executables.description"),
"strip-native-commands",
Boolean.class,
p -> Boolean.TRUE,
! (s, p) -> Boolean.valueOf(s)
! );
public static void extractMainClassInfoFromAppResources(Map<String, ? super Object> params) {
boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
*** 870,912 ****
}
}
return result;
}
- private static boolean setupDefaultModulePath = false;
-
- private static void setupDefaultModulePathIfNecessary(Map<String, ? super Object> params) {
- if (!setupDefaultModulePath) {
- setupDefaultModulePath = true;
- Path userDefinedJdkModulePath = null;
- List<Path> modulePath = MODULE_PATH.fetchFrom(params, false);
-
- if (modulePath != null) {
- userDefinedJdkModulePath = findPathOfModule(modulePath, "java.base.jmod");
- }
- else {
- modulePath = new ArrayList();
- }
-
- // Add the default JDK module path to the module path.
- if (userDefinedJdkModulePath == null) {
- Path jdkModulePath = Paths.get(System.getProperty("java.home"), "jmods").toAbsolutePath();
-
- if (jdkModulePath != null && Files.exists(jdkModulePath)) {
- modulePath.add(jdkModulePath);
- params.put(MODULE_PATH.getID(), listOfPathToString(modulePath));
- }
- }
-
- Path javaBasePath = findPathOfModule(modulePath, "java.base.jmod");
-
- if (javaBasePath == null || !javaBasePath.toFile().exists()) {
- Log.info(String.format(I18N.getString("warning.no.jdk.modules.found")));
- }
- }
- }
-
private static RelativeFileSet getMainJar(String moduleName, Map<String, ? super Object> params) {
for (RelativeFileSet rfs : APP_RESOURCES_LIST.fetchFrom(params)) {
File appResourcesRoot = rfs.getBaseDirectory();
File mainJarFile = new File(appResourcesRoot, moduleName);
--- 899,908 ----
*** 926,931 ****
--- 922,938 ----
throw new IllegalArgumentException(
new ConfigException(
MessageFormat.format(I18N.getString("error.main-jar-does-not-exist"), moduleName),
I18N.getString("error.main-jar-does-not-exist.advice")));
}
+
+ public static List<Path> getDefaultModulePath() {
+ List<Path> result = new ArrayList();
+ Path jdkModulePath = Paths.get(System.getProperty("java.home"), "jmods").toAbsolutePath();
+
+ if (jdkModulePath != null && Files.exists(jdkModulePath)) {
+ result.add(jdkModulePath);
+ }
+
+ return result;
+ }
}
< prev index next >