< prev index next >

test/tools/lib/tests/JImageGenerator.java

Print this page




 547             System.err.println("jimage options: " + optionsPrettyPrint(args));
 548             StringWriter writer = new StringWriter();
 549             int exitCode = jdk.tools.jimage.Main.run(args, new PrintWriter(writer));
 550             return new Result(exitCode, writer.toString(), returnPath);
 551         }
 552 
 553         public Result extract() {
 554             return cmd("extract", dir);
 555         }
 556     }
 557 
 558     public static class JLinkTask {
 559 
 560         private final List<Path> jars = new ArrayList<>();
 561         private final List<Path> jmods = new ArrayList<>();
 562         private final List<Path> pluginModulePath = new ArrayList<>();
 563         private final List<String> addMods = new ArrayList<>();
 564         private final List<String> limitMods = new ArrayList<>();
 565         private final List<String> options = new ArrayList<>();
 566         private String modulePath;




 567         private Path output;
 568         private Path existing;
 569 
 570         public JLinkTask modulePath(String modulePath) {
 571             this.modulePath = modulePath;
 572             return this;
 573         }
 574 





 575         public JLinkTask addJars(Path jars) {
 576             this.jars.add(jars);
 577             return this;
 578         }
 579 
 580         public JLinkTask addJmods(Path jmods) {
 581             this.jmods.add(jmods);
 582             return this;
 583         }
 584 
 585         public JLinkTask pluginModulePath(Path p) {
 586             this.pluginModulePath.add(p);
 587             return this;
 588         }
 589 
 590         public JLinkTask addMods(String moduleName) {
 591             this.addMods.add(moduleName);
 592             return this;
 593         }
 594 
 595         public JLinkTask limitMods(String moduleName) {
 596             this.limitMods.add(moduleName);
 597             return this;
 598         }
 599 





 600         public JLinkTask output(Path output) {
 601             this.output = output;
 602             return this;
 603         }
 604 
 605         public JLinkTask existing(Path existing) {
 606             this.existing = existing;
 607             return this;
 608         }
 609 
 610         public JLinkTask option(String o) {
 611             this.options.add(o);
 612             return this;
 613         }
 614 
 615         private String modulePath() {
 616             // This is expect FIRST jmods THEN jars, if you change this, some tests could fail
 617             String jmods = toPath(this.jmods);
 618             String jars = toPath(this.jars);
 619             return jmods + File.pathSeparator + jars;


 622         private String toPath(List<Path> paths) {
 623             return paths.stream()
 624                     .map(Path::toString)
 625                     .collect(Collectors.joining(File.pathSeparator));
 626         }
 627 
 628         private String[] optionsJLink() {
 629             List<String> options = new ArrayList<>();
 630             if (output != null) {
 631                 options.add(OUTPUT_OPTION);
 632                 options.add(output.toString());
 633             }
 634             if (!addMods.isEmpty()) {
 635                 options.add(ADD_MODULES_OPTION);
 636                 options.add(addMods.stream().collect(Collectors.joining(",")));
 637             }
 638             if (!limitMods.isEmpty()) {
 639                 options.add(LIMIT_MODULES_OPTION);
 640                 options.add(limitMods.stream().collect(Collectors.joining(",")));
 641             }




 642             if (!jars.isEmpty() || !jmods.isEmpty()) {
 643                 options.add(MODULE_PATH_OPTION);
 644                 options.add(modulePath());
 645             }
 646             if (modulePath != null) {
 647                 options.add(MODULE_PATH_OPTION);
 648                 options.add(modulePath);
 649             }




 650             if (!pluginModulePath.isEmpty()) {
 651                 options.add(PLUGIN_MODULE_PATH);
 652                 options.add(toPath(pluginModulePath));
 653             }
 654             options.addAll(this.options);
 655             return options.toArray(new String[options.size()]);
 656         }
 657 
 658         private String[] optionsPostProcessJLink() {
 659             List<String> options = new ArrayList<>();
 660             if (existing != null) {
 661                 options.add(POST_PROCESS_OPTION);
 662                 options.add(existing.toString());
 663             }
 664             options.addAll(this.options);
 665             return options.toArray(new String[options.size()]);
 666         }
 667 
 668         public Result call() {
 669             String[] args = optionsJLink();




 547             System.err.println("jimage options: " + optionsPrettyPrint(args));
 548             StringWriter writer = new StringWriter();
 549             int exitCode = jdk.tools.jimage.Main.run(args, new PrintWriter(writer));
 550             return new Result(exitCode, writer.toString(), returnPath);
 551         }
 552 
 553         public Result extract() {
 554             return cmd("extract", dir);
 555         }
 556     }
 557 
 558     public static class JLinkTask {
 559 
 560         private final List<Path> jars = new ArrayList<>();
 561         private final List<Path> jmods = new ArrayList<>();
 562         private final List<Path> pluginModulePath = new ArrayList<>();
 563         private final List<String> addMods = new ArrayList<>();
 564         private final List<String> limitMods = new ArrayList<>();
 565         private final List<String> options = new ArrayList<>();
 566         private String modulePath;
 567         // if you want to specifiy repeated --module-path option
 568         private String repeatedModulePath;
 569         // if you want to specifiy repeated --limit-modules option
 570         private String repeatedLimitMods;
 571         private Path output;
 572         private Path existing;
 573 
 574         public JLinkTask modulePath(String modulePath) {
 575             this.modulePath = modulePath;
 576             return this;
 577         }
 578 
 579         public JLinkTask repeatedModulePath(String modulePath) {
 580             this.repeatedModulePath = modulePath;
 581             return this;
 582         }
 583 
 584         public JLinkTask addJars(Path jars) {
 585             this.jars.add(jars);
 586             return this;
 587         }
 588 
 589         public JLinkTask addJmods(Path jmods) {
 590             this.jmods.add(jmods);
 591             return this;
 592         }
 593 
 594         public JLinkTask pluginModulePath(Path p) {
 595             this.pluginModulePath.add(p);
 596             return this;
 597         }
 598 
 599         public JLinkTask addMods(String moduleName) {
 600             this.addMods.add(moduleName);
 601             return this;
 602         }
 603 
 604         public JLinkTask limitMods(String moduleName) {
 605             this.limitMods.add(moduleName);
 606             return this;
 607         }
 608 
 609         public JLinkTask repeatedLimitMods(String modules) {
 610             this.repeatedLimitMods = modules;
 611             return this;
 612         }
 613 
 614         public JLinkTask output(Path output) {
 615             this.output = output;
 616             return this;
 617         }
 618 
 619         public JLinkTask existing(Path existing) {
 620             this.existing = existing;
 621             return this;
 622         }
 623 
 624         public JLinkTask option(String o) {
 625             this.options.add(o);
 626             return this;
 627         }
 628 
 629         private String modulePath() {
 630             // This is expect FIRST jmods THEN jars, if you change this, some tests could fail
 631             String jmods = toPath(this.jmods);
 632             String jars = toPath(this.jars);
 633             return jmods + File.pathSeparator + jars;


 636         private String toPath(List<Path> paths) {
 637             return paths.stream()
 638                     .map(Path::toString)
 639                     .collect(Collectors.joining(File.pathSeparator));
 640         }
 641 
 642         private String[] optionsJLink() {
 643             List<String> options = new ArrayList<>();
 644             if (output != null) {
 645                 options.add(OUTPUT_OPTION);
 646                 options.add(output.toString());
 647             }
 648             if (!addMods.isEmpty()) {
 649                 options.add(ADD_MODULES_OPTION);
 650                 options.add(addMods.stream().collect(Collectors.joining(",")));
 651             }
 652             if (!limitMods.isEmpty()) {
 653                 options.add(LIMIT_MODULES_OPTION);
 654                 options.add(limitMods.stream().collect(Collectors.joining(",")));
 655             }
 656             if (repeatedLimitMods != null) {
 657                 options.add(LIMIT_MODULES_OPTION);
 658                 options.add(repeatedLimitMods);
 659             }
 660             if (!jars.isEmpty() || !jmods.isEmpty()) {
 661                 options.add(MODULE_PATH_OPTION);
 662                 options.add(modulePath());
 663             }
 664             if (modulePath != null) {
 665                 options.add(MODULE_PATH_OPTION);
 666                 options.add(modulePath);
 667             }
 668             if (repeatedModulePath != null) {
 669                 options.add(MODULE_PATH_OPTION);
 670                 options.add(repeatedModulePath);
 671             }
 672             if (!pluginModulePath.isEmpty()) {
 673                 options.add(PLUGIN_MODULE_PATH);
 674                 options.add(toPath(pluginModulePath));
 675             }
 676             options.addAll(this.options);
 677             return options.toArray(new String[options.size()]);
 678         }
 679 
 680         private String[] optionsPostProcessJLink() {
 681             List<String> options = new ArrayList<>();
 682             if (existing != null) {
 683                 options.add(POST_PROCESS_OPTION);
 684                 options.add(existing.toString());
 685             }
 686             options.addAll(this.options);
 687             return options.toArray(new String[options.size()]);
 688         }
 689 
 690         public Result call() {
 691             String[] args = optionsJLink();


< prev index next >