# HG changeset patch # User jlaskey # Date 1466706577 10800 # Thu Jun 23 15:29:37 2016 -0300 # Node ID a8eb0eb043360c0cabef9c22d4290c1cebe49735 # Parent 504c0fc6f4bf346d61d1bc88dfe00d3bd3363fdb 8159172: Update usage of jlink/jimage/jmod to show option patterns Reviewed-by: mchung diff --git a/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java b/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java --- a/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java @@ -54,8 +54,8 @@ }, "--dir"), new Option(true, (task, option, arg) -> { - task.options.filters = arg; - }, "--filter"), + task.options.include = arg; + }, "--include"), new Option(false, (task, option, arg) -> { task.options.fullVersion = true; @@ -81,12 +81,12 @@ private static final FileSystem JRT_FILE_SYSTEM = Utils.jrtFileSystem(); private final OptionsValues options; - private final List> filterPredicates; + private final List> includePredicates; private PrintWriter log; JImageTask() { this.options = new OptionsValues(); - this.filterPredicates = new ArrayList<>(); + this.includePredicates = new ArrayList<>(); log = null; } @@ -98,7 +98,7 @@ static class OptionsValues { Task task = Task.LIST; String directory = "."; - String filters = ""; + String include = ""; boolean fullVersion; boolean help; boolean verbose; @@ -200,6 +200,8 @@ 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 @@ } } - processFilter(options.filters); + processInclude(options.include); return run() ? EXIT_OK : EXIT_ERROR; } catch (BadArgs e) { @@ -239,15 +241,15 @@ } } - 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 predicate = (path) -> matcher.matches(JRT_FILE_SYSTEM.getPath(path)); - filterPredicates.add(predicate); + includePredicates.add(predicate); } } @@ -388,9 +390,9 @@ String oldModule = ""; for (String name : entryNames) { - boolean match = filterPredicates.isEmpty(); + boolean match = includePredicates.isEmpty(); - for (Predicate predicate : filterPredicates) { + for (Predicate predicate : includePredicates) { if (predicate.test(name)) { match = true; break; diff --git a/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties b/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties --- a/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties @@ -62,9 +62,19 @@ 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 for filtering list or extract entries.w + +main.opt.footer=\ +\n\ +\For options requiring a , the value will be a comma\ +\ separated list of elements each using one the following forms:\n\ +\ \n\ +\ glob:\n\ +\ regex:\n\ +\ @ 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 diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java @@ -584,6 +584,8 @@ showPlugin(plugin, log, showsImageBuilder); } } + + log.println("\n" + bundleHelper.getMessage("main.extended.help.footer")); } private void showPlugin(Plugin plugin, PrintWriter log, boolean showsImageBuilder) { diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties @@ -29,7 +29,7 @@ main.usage=\ Usage: {0} --modulepath --addmods --output \n\ -Possible options include: +\Possible options include: error.prefix=Error: warn.prefix=Warning: @@ -68,7 +68,18 @@ 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 , the value will be a comma\ +\ separated list of elements each using one the following forms:\n\ +\ \n\ +\ glob:\n\ +\ regex:\n\ +\ @ 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 diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -37,15 +37,16 @@ Class optimization. Warning: This plugin is experimental.\n\ An optional can be specified to log applied optimizations. -compress.argument=<0|1|2>[:filter=] +compress.argument=<0|1|2>[:filter=] 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 filter can be specified to list the pattern of\n\ +files to be included. + compact-cp.argument= @@ -59,15 +60,15 @@ 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= +exclude-files.argument= 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= +exclude-resources.argument= 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= @@ -78,10 +79,11 @@ onoff.argument= -order-resources.argument= +order-resources.argument= 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 diff --git a/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java b/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java --- a/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java @@ -1085,7 +1085,7 @@ @Override public Class valueType() { return Pattern.class; } - @Override public String valuePattern() { return "pattern"; } + @Override public String valuePattern() { return "regex-pattern"; } } static class PathMatcherConverter implements ValueConverter { @@ -1100,7 +1100,7 @@ @Override public Class valueType() { return PathMatcher.class; } - @Override public String valuePattern() { return "pattern"; } + @Override public String valuePattern() { return "pattern-list"; } } /* Support for @ in jmod help */ @@ -1145,7 +1145,7 @@ String content = super.format(all); StringBuilder builder = new StringBuilder(); - builder.append("\n").append(" Main operation modes:\n "); + builder.append(" Main operation modes:\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 "); diff --git a/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties b/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties --- a/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties @@ -28,7 +28,7 @@ use --help for a list of possible options main.usage=\ -Usage: {0} (create|list|describe|hash) +Usage: {0} (create|list|describe|hash) \n\ error.prefix=Error: warn.prefix=Warning: @@ -49,7 +49,9 @@ 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: or regex: main.opt.module-version= Module version main.opt.main-class=Main class main.opt.main-class.arg=class-name @@ -61,7 +63,7 @@ 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 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.