8159172: Update usage of jlink/jimage/jmod to show option patterns
Reviewed-by: mchung, alanb
This commit is contained in:
parent
d90e966a97
commit
2146bab54f
jdk/src/jdk.jlink/share/classes/jdk/tools
jimage
jlink
jmod
@ -54,8 +54,8 @@ class JImageTask {
|
||||
}, "--dir"),
|
||||
|
||||
new Option<JImageTask>(true, (task, option, arg) -> {
|
||||
task.options.filters = arg;
|
||||
}, "--filter"),
|
||||
task.options.include = arg;
|
||||
}, "--include"),
|
||||
|
||||
new Option<JImageTask>(false, (task, option, arg) -> {
|
||||
task.options.fullVersion = true;
|
||||
@ -81,12 +81,12 @@ class JImageTask {
|
||||
private static final FileSystem JRT_FILE_SYSTEM = Utils.jrtFileSystem();
|
||||
|
||||
private final OptionsValues options;
|
||||
private final List<Predicate<String>> filterPredicates;
|
||||
private final List<Predicate<String>> includePredicates;
|
||||
private PrintWriter log;
|
||||
|
||||
JImageTask() {
|
||||
this.options = new OptionsValues();
|
||||
this.filterPredicates = new ArrayList<>();
|
||||
this.includePredicates = new ArrayList<>();
|
||||
log = null;
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ class JImageTask {
|
||||
static class OptionsValues {
|
||||
Task task = Task.LIST;
|
||||
String directory = ".";
|
||||
String filters = "";
|
||||
String include = "";
|
||||
boolean fullVersion;
|
||||
boolean help;
|
||||
boolean verbose;
|
||||
@ -200,6 +200,8 @@ class JImageTask {
|
||||
|
||||
log.println(TASK_HELPER.getMessage("main.opt." + name));
|
||||
}
|
||||
|
||||
log.println(TASK_HELPER.getMessage("main.opt.footer"));
|
||||
} else {
|
||||
try {
|
||||
log.println(TASK_HELPER.getMessage("main.usage." +
|
||||
@ -219,7 +221,7 @@ class JImageTask {
|
||||
}
|
||||
}
|
||||
|
||||
processFilter(options.filters);
|
||||
processInclude(options.include);
|
||||
|
||||
return run() ? EXIT_OK : EXIT_ERROR;
|
||||
} catch (BadArgs e) {
|
||||
@ -239,15 +241,15 @@ class JImageTask {
|
||||
}
|
||||
}
|
||||
|
||||
private void processFilter(String filters) {
|
||||
if (filters.isEmpty()) {
|
||||
private void processInclude(String include) {
|
||||
if (include.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String filter : filters.split(",")) {
|
||||
for (String filter : include.split(",")) {
|
||||
final PathMatcher matcher = Utils.getPathMatcher(JRT_FILE_SYSTEM, filter);
|
||||
Predicate<String> predicate = (path) -> matcher.matches(JRT_FILE_SYSTEM.getPath(path));
|
||||
filterPredicates.add(predicate);
|
||||
includePredicates.add(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,9 +390,9 @@ class JImageTask {
|
||||
String oldModule = "";
|
||||
|
||||
for (String name : entryNames) {
|
||||
boolean match = filterPredicates.isEmpty();
|
||||
boolean match = includePredicates.isEmpty();
|
||||
|
||||
for (Predicate<String> predicate : filterPredicates) {
|
||||
for (Predicate<String> predicate : includePredicates) {
|
||||
if (predicate.test(name)) {
|
||||
match = true;
|
||||
break;
|
||||
|
@ -62,9 +62,19 @@ warn.prefix=Warning:
|
||||
main.opt.dir=\
|
||||
\ --dir Target directory for extract directive
|
||||
|
||||
main.opt.filter=\
|
||||
\ --filter Filter entries for list or extract\n\
|
||||
\ Ex. /java.base/*, */module-info.class
|
||||
main.opt.include=\
|
||||
\ --include <pattern-list> Pattern list for filtering list or extract entries.
|
||||
|
||||
main.opt.footer=\
|
||||
\n\
|
||||
\For options requiring a <pattern-list>, the value will be a comma\
|
||||
\ separated list of elements each using one the following forms:\n\
|
||||
\ <glob-pattern>\n\
|
||||
\ glob:<glob-pattern>\n\
|
||||
\ regex:<regex-pattern>\n\
|
||||
\ @<filename> where filename is the name of a file containing patterns to be\
|
||||
\ used, one pattern per line\n\
|
||||
|
||||
|
||||
main.opt.fullversion=\
|
||||
\ --fullversion Print full version information
|
||||
|
@ -584,6 +584,8 @@ public final class TaskHelper {
|
||||
showPlugin(plugin, log, showsImageBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
log.println("\n" + bundleHelper.getMessage("main.extended.help.footer"));
|
||||
}
|
||||
|
||||
private void showPlugin(Plugin plugin, PrintWriter log, boolean showsImageBuilder) {
|
||||
|
@ -29,7 +29,7 @@ use --help for a list of possible options
|
||||
|
||||
main.usage=\
|
||||
Usage: {0} <options> --modulepath <modulepath> --addmods <mods> --output <path>\n\
|
||||
Possible options include:
|
||||
\Possible options include:
|
||||
|
||||
error.prefix=Error:
|
||||
warn.prefix=Warning:
|
||||
@ -68,7 +68,18 @@ after checking the database for duplicates. \
|
||||
Include your program and the following diagnostic in your report. Thank you.
|
||||
|
||||
main.extended.help=\
|
||||
List of available plugins:
|
||||
\List of available plugins:
|
||||
|
||||
main.extended.help.footer=\
|
||||
\For options requiring a <pattern-list>, the value will be a comma\
|
||||
\ separated list of elements each using one the following forms:\n\
|
||||
\ <glob-pattern>\n\
|
||||
\ glob:<glob-pattern>\n\
|
||||
\ regex:<regex-pattern>\n\
|
||||
\ @<filename> where filename is the name of a file containing patterns to be\
|
||||
\ used, one pattern per line\n\
|
||||
\n\
|
||||
|
||||
|
||||
err.unknown.byte.order:unknown byte order {0}
|
||||
err.output.must.be.specified:--output must be specified
|
||||
|
@ -37,15 +37,16 @@ class-optim.description=\
|
||||
Class optimization. Warning: This plugin is experimental.\n\
|
||||
An optional <log file> can be specified to log applied optimizations.
|
||||
|
||||
compress.argument=<0|1|2>[:filter=<pattern>]
|
||||
compress.argument=<0|1|2>[:filter=<pattern-list>]
|
||||
|
||||
compress.description=\
|
||||
Compress all resources in the output image.\n\
|
||||
Level 0: constant string sharing\n\
|
||||
Level 1: ZIP\n\
|
||||
Level 2: both.\n\
|
||||
An optional filter can be specified to list the pattern of files to be filtered.\n\
|
||||
Use ^ for negation. e.g.: *Exception.class,*Error.class,^/java.base/java/lang/*
|
||||
An optional <pattern-list> filter can be specified to list the pattern of\n\
|
||||
files to be included.
|
||||
|
||||
|
||||
compact-cp.argument=<resource paths>
|
||||
|
||||
@ -59,15 +60,15 @@ copy-files.description=\
|
||||
If files to copy are not absolute path, JDK home dir is used.\n\
|
||||
e.g.: jrt-fs.jar,LICENSE,/home/me/myfile.txt=somewehere/conf.txt
|
||||
|
||||
exclude-files.argument=<files to exclude | files of excluded files>
|
||||
exclude-files.argument=<pattern-list> of files to exclude
|
||||
|
||||
exclude-files.description=\
|
||||
Specify files to exclude. e.g.: *.diz, /java.base/native/client/*
|
||||
Specify files to exclude. e.g.: **.java,glob:/java.base/native/client/**
|
||||
|
||||
exclude-resources.argument=<resources to exclude | file of excluded resources>
|
||||
exclude-resources.argument=<pattern-list> resources to exclude
|
||||
|
||||
exclude-resources.description=\
|
||||
Specify resources to exclude. e.g.: *.jcov, */META-INF/*
|
||||
Specify resources to exclude. e.g.: **.jcov,glob:**/META-INF/**
|
||||
|
||||
generate-jli-classes.argument=<bmh[:bmh-species=LL,L3,...]>
|
||||
|
||||
@ -78,10 +79,11 @@ installed-modules.description=Fast loading of module descriptors (always enabled
|
||||
|
||||
onoff.argument=<on|off>
|
||||
|
||||
order-resources.argument=<paths in priority order | file with resource paths>
|
||||
order-resources.argument=<pattern-list> of paths in priority order. If a @file\n\
|
||||
is specified, then each line should be an exact match for the path to be ordered
|
||||
|
||||
order-resources.description=\
|
||||
Order resources. e.g.: */module-info.class,/java.base/java/lang/*
|
||||
Order resources. e.g.: **/module-info.class,@classlist,/java.base/java/lang/**
|
||||
|
||||
strip-debug.description=\
|
||||
Strip debug information from the output image
|
||||
|
@ -1085,7 +1085,7 @@ public class JmodTask {
|
||||
|
||||
@Override public Class<Pattern> valueType() { return Pattern.class; }
|
||||
|
||||
@Override public String valuePattern() { return "pattern"; }
|
||||
@Override public String valuePattern() { return "regex-pattern"; }
|
||||
}
|
||||
|
||||
static class PathMatcherConverter implements ValueConverter<PathMatcher> {
|
||||
@ -1100,7 +1100,7 @@ public class JmodTask {
|
||||
|
||||
@Override public Class<PathMatcher> valueType() { return PathMatcher.class; }
|
||||
|
||||
@Override public String valuePattern() { return "pattern"; }
|
||||
@Override public String valuePattern() { return "pattern-list"; }
|
||||
}
|
||||
|
||||
/* Support for @<file> in jmod help */
|
||||
@ -1145,7 +1145,7 @@ public class JmodTask {
|
||||
String content = super.format(all);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("\n").append(" Main operation modes:\n ");
|
||||
builder.append(getMessage("main.opt.mode")).append("\n ");
|
||||
builder.append(getMessage("main.opt.mode.create")).append("\n ");
|
||||
builder.append(getMessage("main.opt.mode.list")).append("\n ");
|
||||
builder.append(getMessage("main.opt.mode.describe")).append("\n ");
|
||||
|
@ -28,11 +28,13 @@ Usage: {0} (create|list|describe|hash) <OPTIONS> <jmod-file>\n\
|
||||
use --help for a list of possible options
|
||||
|
||||
main.usage=\
|
||||
Usage: {0} (create|list|describe|hash) <OPTIONS> <jmod-file>
|
||||
Usage: {0} (create|list|describe|hash) <OPTIONS> <jmod-file>\n\
|
||||
|
||||
error.prefix=Error:
|
||||
warn.prefix=Warning:
|
||||
|
||||
main.opt.mode=\
|
||||
\Main operation modes:
|
||||
main.opt.mode.create=\
|
||||
\create - Creates a new jmod archive
|
||||
main.opt.mode.list=\
|
||||
@ -49,7 +51,9 @@ main.opt.libs=Location of native libraries
|
||||
main.opt.cmds=Location of native commands
|
||||
main.opt.config=Location of user-editable config files
|
||||
main.opt.dry-run=Dry run of hash mode
|
||||
main.opt.exclude=Exclude files, given as a PATTERN
|
||||
main.opt.exclude=Exclude files matching the supplied comma separated pattern\
|
||||
\ list, each element using one the following forms: <glob-pattern>,\
|
||||
\ glob:<glob-pattern> or regex:<regex-pattern>
|
||||
main.opt.module-version= Module version
|
||||
main.opt.main-class=Main class
|
||||
main.opt.main-class.arg=class-name
|
||||
@ -61,7 +65,7 @@ main.opt.os-version=Operating system version
|
||||
main.opt.os-version.arg=os-version
|
||||
main.opt.modulepath=Module path
|
||||
main.opt.hash-modules=Compute and record hashes to tie a packaged module\
|
||||
\ with modules matching the given pattern and depending upon it directly\
|
||||
\ with modules matching the given <regex-pattern> and depending upon it directly\
|
||||
\ or indirectly. The hashes are recorded in the JMOD file being created, or\
|
||||
\ a JMOD file or modular JAR on the module path specified the jmod hash command.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user