changeset 39150:cb99396625b4

8159172: Update usage of jlink/jimage/jmod to show option patterns Reviewed-by: mchung, alanb
author jlaskey
date Fri, 24 Jun 2016 11:20:24 -0300
parents 745d93b1bdb3
children 34455cc82f5e
files jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties
diffstat 7 files changed, 63 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Fri Jun 24 06:52:29 2016 +0100
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Fri Jun 24 11:20:24 2016 -0300
@@ -54,8 +54,8 @@
         }, "--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 @@
     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 @@
     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<String> 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<String> predicate : filterPredicates) {
+                        for (Predicate<String> predicate : includePredicates) {
                             if (predicate.test(name)) {
                                 match = true;
                                 break;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Fri Jun 24 06:52:29 2016 +0100
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Fri Jun 24 11:20:24 2016 -0300
@@ -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>          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
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Fri Jun 24 06:52:29 2016 +0100
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Fri Jun 24 11:20:24 2016 -0300
@@ -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) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Fri Jun 24 06:52:29 2016 +0100
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Fri Jun 24 11:20:24 2016 -0300
@@ -29,7 +29,7 @@
 
 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 @@
 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
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Fri Jun 24 06:52:29 2016 +0100
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Fri Jun 24 11:20:24 2016 -0300
@@ -37,15 +37,16 @@
 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 @@
 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 @@
 
 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
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Fri Jun 24 06:52:29 2016 +0100
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Fri Jun 24 11:20:24 2016 -0300
@@ -1085,7 +1085,7 @@
 
         @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 @@
 
         @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 @@
             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  ");
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Fri Jun 24 06:52:29 2016 +0100
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Fri Jun 24 11:20:24 2016 -0300
@@ -28,11 +28,13 @@
 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.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.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.