1 /*
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
71 import jdk.internal.module.ModulePath;
72 import jdk.internal.module.ModuleResolution;
73
74 /**
75 * Implementation for the jlink tool.
76 *
77 * ## Should use jdk.joptsimple some day.
78 */
79 public class JlinkTask {
80 static final boolean DEBUG = Boolean.getBoolean("jlink.debug");
81
82 // jlink API ignores by default. Remove when signing is implemented.
83 static final boolean IGNORE_SIGNING_DEFAULT = true;
84
85 private static final TaskHelper taskHelper
86 = new TaskHelper(JLINK_BUNDLE);
87
88 private static final Option<?>[] recognizedOptions = {
89 new Option<JlinkTask>(false, (task, opt, arg) -> {
90 task.options.help = true;
91 }, "--help", "-h"),
92 new Option<JlinkTask>(true, (task, opt, arg) -> {
93 // if used multiple times, the last one wins!
94 // So, clear previous values, if any.
95 task.options.modulePath.clear();
96 String[] dirs = arg.split(File.pathSeparator);
97 int i = 0;
98 Arrays.stream(dirs)
99 .map(Paths::get)
100 .forEach(task.options.modulePath::add);
101 }, "--module-path", "-p"),
102 new Option<JlinkTask>(true, (task, opt, arg) -> {
103 // if used multiple times, the last one wins!
104 // So, clear previous values, if any.
105 task.options.limitMods.clear();
106 for (String mn : arg.split(",")) {
107 if (mn.isEmpty()) {
108 throw taskHelper.newBadArgs("err.mods.must.be.specified",
109 "--limit-modules");
110 }
111 task.options.limitMods.add(mn);
|
1 /*
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
71 import jdk.internal.module.ModulePath;
72 import jdk.internal.module.ModuleResolution;
73
74 /**
75 * Implementation for the jlink tool.
76 *
77 * ## Should use jdk.joptsimple some day.
78 */
79 public class JlinkTask {
80 static final boolean DEBUG = Boolean.getBoolean("jlink.debug");
81
82 // jlink API ignores by default. Remove when signing is implemented.
83 static final boolean IGNORE_SIGNING_DEFAULT = true;
84
85 private static final TaskHelper taskHelper
86 = new TaskHelper(JLINK_BUNDLE);
87
88 private static final Option<?>[] recognizedOptions = {
89 new Option<JlinkTask>(false, (task, opt, arg) -> {
90 task.options.help = true;
91 }, "--help", "-h", "-?"),
92 new Option<JlinkTask>(true, (task, opt, arg) -> {
93 // if used multiple times, the last one wins!
94 // So, clear previous values, if any.
95 task.options.modulePath.clear();
96 String[] dirs = arg.split(File.pathSeparator);
97 int i = 0;
98 Arrays.stream(dirs)
99 .map(Paths::get)
100 .forEach(task.options.modulePath::add);
101 }, "--module-path", "-p"),
102 new Option<JlinkTask>(true, (task, opt, arg) -> {
103 // if used multiple times, the last one wins!
104 // So, clear previous values, if any.
105 task.options.limitMods.clear();
106 for (String mn : arg.split(",")) {
107 if (mn.isEmpty()) {
108 throw taskHelper.newBadArgs("err.mods.must.be.specified",
109 "--limit-modules");
110 }
111 task.options.limitMods.add(mn);
|