< prev index next >

jdk/test/tools/jlink/CustomPluginTest.java

Print this page




  76                 .output(helper.createNewImageDir("customplugin"))
  77                 .call();
  78         if (result.getExitCode() != 0) {
  79             System.err.println(result.getMessage());
  80             throw new AssertionError("jlink crashed: " + result.getExitCode());
  81         }
  82         List<String> customPlugins = Stream.of(result.getMessage().split("\n"))
  83                 .filter(s -> s.startsWith("Plugin Name:"))
  84                 .filter(s -> s.contains("custom"))
  85                 .collect(Collectors.toList());
  86         if (customPlugins.size() != 1) {
  87             System.err.println(result.getMessage());
  88             throw new AssertionError("Found plugins: " + customPlugins);
  89         }
  90     }
  91 
  92     private Path registerServices(Helper helper) throws IOException {
  93         String name = "customplugin";
  94         Path src = Paths.get(System.getProperty("test.src")).resolve(name);
  95         Path classes = helper.getJmodClassesDir().resolve(name);
  96         JImageGenerator.compile(src, classes, "-XaddExports:jdk.jlink/jdk.tools.jlink.internal=customplugin");

  97         return JImageGenerator.getJModTask()
  98                 .addClassPath(classes)
  99                 .jmod(helper.getJmodDir().resolve(name + ".jmod"))
 100                 .create().assertSuccess();
 101     }
 102 
 103     private void testHelloProvider(Helper helper, Path pluginModulePath) throws IOException {
 104         Path pluginFile = Paths.get("customplugin.txt");
 105         if (Files.exists(pluginFile)) {
 106             throw new AssertionError("Custom plugin output file already exists");
 107         }
 108         String customplugin = "customplugin";
 109         {
 110             // Add the path but not the option, plugin musn't be called
 111             JImageGenerator.getJLinkTask()
 112                     .modulePath(helper.defaultModulePath())
 113                     .pluginModulePath(pluginModulePath)
 114                     .output(helper.createNewImageDir(customplugin))
 115                     .addMods(customplugin)
 116                     .call().assertSuccess();




  76                 .output(helper.createNewImageDir("customplugin"))
  77                 .call();
  78         if (result.getExitCode() != 0) {
  79             System.err.println(result.getMessage());
  80             throw new AssertionError("jlink crashed: " + result.getExitCode());
  81         }
  82         List<String> customPlugins = Stream.of(result.getMessage().split("\n"))
  83                 .filter(s -> s.startsWith("Plugin Name:"))
  84                 .filter(s -> s.contains("custom"))
  85                 .collect(Collectors.toList());
  86         if (customPlugins.size() != 1) {
  87             System.err.println(result.getMessage());
  88             throw new AssertionError("Found plugins: " + customPlugins);
  89         }
  90     }
  91 
  92     private Path registerServices(Helper helper) throws IOException {
  93         String name = "customplugin";
  94         Path src = Paths.get(System.getProperty("test.src")).resolve(name);
  95         Path classes = helper.getJmodClassesDir().resolve(name);
  96         JImageGenerator.compile(src, classes,
  97                                 "--add-exports", "jdk.jlink/jdk.tools.jlink.internal=customplugin");
  98         return JImageGenerator.getJModTask()
  99                 .addClassPath(classes)
 100                 .jmod(helper.getJmodDir().resolve(name + ".jmod"))
 101                 .create().assertSuccess();
 102     }
 103 
 104     private void testHelloProvider(Helper helper, Path pluginModulePath) throws IOException {
 105         Path pluginFile = Paths.get("customplugin.txt");
 106         if (Files.exists(pluginFile)) {
 107             throw new AssertionError("Custom plugin output file already exists");
 108         }
 109         String customplugin = "customplugin";
 110         {
 111             // Add the path but not the option, plugin musn't be called
 112             JImageGenerator.getJLinkTask()
 113                     .modulePath(helper.defaultModulePath())
 114                     .pluginModulePath(pluginModulePath)
 115                     .output(helper.createNewImageDir(customplugin))
 116                     .addMods(customplugin)
 117                     .call().assertSuccess();


< prev index next >