8172864: Remove custom plugin module path
authorsundar
Fri, 27 Jan 2017 19:07:45 +0530
changeset 43328 91f9c9170d97
parent 43327 889efa087768
child 43329 4b34ab4c7ba1
8172864: Remove custom plugin module path Reviewed-by: alanb, jlaskey
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties
jdk/test/ProblemList.txt
jdk/test/tools/jlink/CustomPluginTest.java
jdk/test/tools/jlink/JLink2Test.java
jdk/test/tools/jlink/customplugin/module-info.java
jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java
jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java
jdk/test/tools/jlink/customplugin/plugin/RogueAdderPlugin.java
jdk/test/tools/jlink/customplugin/plugin/RogueFilterPlugin.java
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu Jan 26 23:11:37 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Fri Jan 27 19:07:45 2017 +0530
@@ -194,8 +194,6 @@
 
     private final class PluginsHelper {
 
-        private static final String PLUGINS_PATH = "--plugin-module-path";
-
         private Layer pluginsLayer = Layer.boot();
         private final List<Plugin> plugins;
         private String lastSorter;
@@ -503,22 +501,7 @@
         }
 
         private String getPluginsPath(String[] args) throws BadArgs {
-            String pp = null;
-            for (int i = 0; i < args.length; i++) {
-                if (args[i].equals(PluginsHelper.PLUGINS_PATH)) {
-                    if (i == args.length - 1) {
-                        throw new BadArgs("err.no.plugins.path").showUsage(true);
-                    } else {
-                        i += 1;
-                        pp = args[i];
-                        if (!pp.isEmpty() && pp.charAt(0) == '-') {
-                            throw new BadArgs("err.no.plugins.path").showUsage(true);
-                        }
-                        break;
-                    }
-                }
-            }
-            return pp;
+            return null;
         }
 
         // used by jimage. Return unhandled arguments like "create", "describe".
@@ -542,31 +525,7 @@
             // Must extract it prior to do any option analysis.
             // Required to interpret custom plugin options.
             // Unit tests can call Task multiple time in same JVM.
-            pluginOptions = new PluginsHelper(getPluginsPath(args));
-
-            // First extract plugins path if any
-            String pp = null;
-            List<String> filteredArgs = new ArrayList<>();
-            for (int i = 0; i < args.length; i++) {
-                if (args[i].equals(PluginsHelper.PLUGINS_PATH)) {
-                    if (i == args.length - 1) {
-                        throw new BadArgs("err.no.plugins.path").showUsage(true);
-                    } else {
-                        warning("warn.thirdparty.plugins.enabled");
-                        log.println(bundleHelper.getMessage("warn.thirdparty.plugins"));
-                        i += 1;
-                        String arg = args[i];
-                        if (!arg.isEmpty() && arg.charAt(0) == '-') {
-                            throw new BadArgs("err.no.plugins.path").showUsage(true);
-                        }
-                        pp = args[i];
-                    }
-                } else {
-                    filteredArgs.add(args[i]);
-                }
-            }
-            String[] arr = new String[filteredArgs.size()];
-            args = filteredArgs.toArray(arr);
+            pluginOptions = new PluginsHelper(null);
 
             List<String> rest = collectUnhandled? new ArrayList<>() : null;
             // process options
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Thu Jan 26 23:11:37 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Fri Jan 27 19:07:45 2017 +0530
@@ -142,9 +142,6 @@
 \      --resources-last-sorter <name>    The last plugin allowed to sort\n\
 \                                        resources
 
-plugin.opt.plugin-module-path=\
-\      --plugin-module-path <modulepath> Custom plugin module path
-
 plugin.opt.disable-plugin=\
 \      --disable-plugin <pluginname>     Disable the plugin mentioned
 
--- a/jdk/test/ProblemList.txt	Thu Jan 26 23:11:37 2017 +0000
+++ b/jdk/test/ProblemList.txt	Fri Jan 27 19:07:45 2017 +0530
@@ -262,8 +262,6 @@
 
 tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java       8169971 windows-x64
 
-tools/jlink/CustomPluginTest.java                               8172864 generic-all
-
 tools/jar/multiRelease/ApiValidatorTest.java                    8173396 generic-all
 
 ############################################################################
--- a/jdk/test/tools/jlink/CustomPluginTest.java	Thu Jan 26 23:11:37 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import tests.Helper;
-import tests.JImageGenerator;
-import tests.Result;
-
-/*
- * @test
- * @summary Test custom plugin
- * @author Jean-Francois Denise
- * @library ../lib
- * @modules java.base/jdk.internal.jimage
- *          jdk.jdeps/com.sun.tools.classfile
- *          jdk.jlink/jdk.tools.jlink.internal
- *          jdk.jlink/jdk.tools.jmod
- *          jdk.jlink/jdk.tools.jimage
- *          jdk.compiler
- * @build tests.*
- * @run main/othervm CustomPluginTest
- */
-
-public class CustomPluginTest {
-
-    public static void main(String[] args) throws Exception {
-        new CustomPluginTest().test();
-    }
-
-    private void test() throws Exception {
-        Helper helper = Helper.newHelper();
-        if (helper == null) {
-            System.err.println("Test not run");
-            return;
-        }
-        helper.generateDefaultModules();
-        Path jmod = registerServices(helper);
-        Path pluginModulePath = jmod.getParent();
-
-        testHelloProvider(helper, pluginModulePath);
-        testCustomPlugins(helper, pluginModulePath);
-        testModuleVerification(helper, pluginModulePath);
-    }
-
-    private void testCustomPlugins(Helper helper, Path pluginModulePath) {
-        Result result = JImageGenerator.getJLinkTask()
-                .option("--list-plugins")
-                .pluginModulePath(pluginModulePath)
-                .output(helper.createNewImageDir("customplugin"))
-                .call();
-        if (result.getExitCode() != 0) {
-            System.err.println(result.getMessage());
-            throw new AssertionError("jlink crashed: " + result.getExitCode());
-        }
-        List<String> customPlugins = Stream.of(result.getMessage().split("\n"))
-                .filter(s -> s.startsWith("Plugin Name:"))
-                .filter(s -> s.contains("custom"))
-                .collect(Collectors.toList());
-        if (customPlugins.size() != 1) {
-            System.err.println(result.getMessage());
-            throw new AssertionError("Found plugins: " + customPlugins);
-        }
-    }
-
-    private Path registerServices(Helper helper) throws IOException {
-        String name = "customplugin";
-        Path src = Paths.get(System.getProperty("test.src")).resolve(name);
-        Path classes = helper.getJmodClassesDir().resolve(name);
-        JImageGenerator.compile(src, classes);
-        return JImageGenerator.getJModTask()
-                .addClassPath(classes)
-                .jmod(helper.getJmodDir().resolve(name + ".jmod"))
-                .create().assertSuccess();
-    }
-
-    private void testHelloProvider(Helper helper, Path pluginModulePath) throws IOException {
-        Path pluginFile = Paths.get("customplugin.txt");
-        if (Files.exists(pluginFile)) {
-            throw new AssertionError("Custom plugin output file already exists");
-        }
-        String customplugin = "customplugin";
-        {
-            // Add the path but not the option, plugin musn't be called
-            JImageGenerator.getJLinkTask()
-                    .modulePath(helper.defaultModulePath())
-                    .pluginModulePath(pluginModulePath)
-                    .output(helper.createNewImageDir(customplugin))
-                    .addMods(customplugin)
-                    .call().assertSuccess();
-        }
-
-        if (Files.exists(pluginFile)) {
-            throw new AssertionError("Custom plugin output file exists, plugin "
-                    + " called although shouldn't have been");
-        }
-
-        { // Add the path and the option, plugin should be called.
-            JImageGenerator.getJLinkTask()
-                    .modulePath(helper.defaultModulePath())
-                    .addMods(customplugin)
-                    .pluginModulePath(pluginModulePath)
-                    .output(helper.createNewImageDir(customplugin))
-                    .option("--hello")
-                    .call().assertSuccess();
-        }
-
-        if (!Files.exists(pluginFile)) {
-            throw new AssertionError("Custom plugin not called");
-        }
-    }
-
-    private void testModuleVerification(Helper helper, Path pluginModulePath) throws IOException {
-        {
-            // dependent module missing check
-            String moduleName = "bar"; // 8147491
-            Path jmodFoo = helper.generateDefaultJModule("foo").assertSuccess();
-            Path jmodBar = helper.generateDefaultJModule(moduleName, "foo").assertSuccess();
-            // rogue filter removes "foo" module resources which are
-            // required by "bar" module. Module checks after plugin
-            // application should detect and report error.
-            JImageGenerator.getJLinkTask()
-                .modulePath(helper.defaultModulePath())
-                .pluginModulePath(pluginModulePath)
-                .output(helper.createNewImageDir(moduleName))
-                .addMods(moduleName)
-                .option("--disable-plugin")
-                .option("release-info")
-                .option("--rogue-filter")
-                .option("/foo/")
-                .call()
-                .assertFailure("foo not found");
-        }
-
-        {
-            // package exported by one module used as concealed package
-            // in another module. But, module-info.class is not updated!
-            String moduleName = "jdk.scripting.nashorn";
-            JImageGenerator.getJLinkTask()
-                .modulePath(helper.defaultModulePath())
-                .pluginModulePath(pluginModulePath)
-                .output(helper.createNewImageDir(moduleName))
-                .addMods(moduleName)
-                // "java.logging" includes a package 'javax.script'
-                // which is an exported package from "java.scripting" module!
-                // module-info.class of java.logging left "as is".
-                .option("--rogue-adder")
-                .option("/java.logging/javax/script/Foo.class")
-                .call()
-                .assertFailure(
-                    "Module java.logging's descriptor returns inconsistent package set");
-        }
-    }
-}
--- a/jdk/test/tools/jlink/JLink2Test.java	Thu Jan 26 23:11:37 2017 +0000
+++ b/jdk/test/tools/jlink/JLink2Test.java	Fri Jan 27 19:07:45 2017 +0530
@@ -68,58 +68,9 @@
         // This test case must be first one, the JlinkTask is clean
         // and reveals possible bug related to plugin options in defaults
         testSameNames(helper);
-        testModulePath(helper);
         testOptions();
     }
 
-    private static void testModulePath(Helper helper) throws IOException {
-        Path doesNotExist = helper.createNewImageDir("doesnotexist");
-        Path jar = helper.getJarDir().resolve("bad.jar");
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(doesNotExist)
-                .option("--help")
-                .call().assertSuccess();
-        Files.createFile(jar);
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(jar)
-                .option("--help")
-                .call().assertFailure("(\n|\r|.)*Error: Invalid modules in the plugins path: (\n|\r|.)*");
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(jar.getParent())
-                .option("--help")
-                .call().assertFailure("Error: Invalid modules in the plugins path: .*zip file is empty(\n|\r|.)*");
-        try (JarOutputStream out = new JarOutputStream(new FileOutputStream(jar.toFile()))) {
-            JarEntry entry = new JarEntry("class");
-            out.putNextEntry(entry);
-            out.write("AAAA".getBytes());
-            out.closeEntry();
-        }
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(jar.getParent())
-                .output(helper.createNewImageDir("crash"))
-                .addJmods(helper.getStdJmodsDir())
-                .addJmods(jar.getParent())
-                .addMods("bad")
-                .call().assertFailure("(\n|\r|.)*Error: module-info.class not found for bad module(\n|\r|.)*");
-        try (JarOutputStream out = new JarOutputStream(new FileOutputStream(jar.toFile()))) {
-            JarEntry entry = new JarEntry("classes");
-            out.putNextEntry(entry);
-            out.closeEntry();
-
-            entry = new JarEntry("classes/class");
-            out.putNextEntry(entry);
-            out.write("AAAA".getBytes());
-            out.closeEntry();
-        }
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(jar.getParent())
-                .output(helper.createNewImageDir("bad"))
-                .addJmods(jar.getParent())
-                .addJars(helper.getStdJmodsDir())
-                .addMods("bad")
-                .call().assertFailure("(\n|\r|.)*Error: module-info.class not found for bad module(\n|\r|.)*");
-    }
-
     private static void testSameNames(Helper helper) throws Exception {
         // Multiple modules with the same name in modulepath, take the first one in the path.
         // First jmods then jars. So jmods are found, jars are hidden.
--- a/jdk/test/tools/jlink/customplugin/module-info.java	Thu Jan 26 23:11:37 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module customplugin {
-    requires jdk.jlink;
-    provides jdk.tools.jlink.plugin.Plugin with plugin.HelloPlugin;
-    provides jdk.tools.jlink.plugin.Plugin with plugin.CustomPlugin;
-    provides jdk.tools.jlink.plugin.Plugin with plugin.RogueAdderPlugin;
-    provides jdk.tools.jlink.plugin.Plugin with plugin.RogueFilterPlugin;
-}
--- a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java	Thu Jan 26 23:11:37 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package plugin;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.function.Function;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.Plugin;
-
-public class CustomPlugin implements Plugin {
-
-    private final static String NAME = "custom-plugin";
-
-    public CustomPlugin() {
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
-        in.transformAndCopy(Function.identity(), out);
-        return out.build();
-    }
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public String getDescription() {
-        return NAME + "-description";
-    }
-
-    @Override
-    public void configure(Map<String, String> config) {
-    }
-
-    @Override
-    public Category getType() {
-        return Category.PROCESSOR;
-    }
-}
--- a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java	Thu Jan 26 23:11:37 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package plugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.util.Collections;
-import java.util.Map;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.Plugin;
-
-/**
- * Custom plugin
- */
-public final class HelloPlugin implements Plugin {
-
-    private static final String OUTPUT_FILE = "customplugin.txt";
-    public static final String NAME = "hello";
-
-    public static boolean called;
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool inResources, ResourcePoolBuilder outResources) {
-        try {
-            System.out.println("Hello!!!!!!!!!!");
-            File f = new File(OUTPUT_FILE);
-            f.createNewFile();
-            inResources.entries().forEach(res -> {
-                outResources.add(res);
-            });
-        } catch (IOException ex) {
-            throw new UncheckedIOException(ex);
-        }
-        return outResources.build();
-    }
-
-    @Override
-    public String getDescription() {
-        return NAME + "-description";
-    }
-}
--- a/jdk/test/tools/jlink/customplugin/plugin/RogueAdderPlugin.java	Thu Jan 26 23:11:37 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package plugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.lang.module.ModuleDescriptor;
-import java.util.Collections;
-import java.util.Map;
-import java.util.function.Function;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePoolModule;
-import jdk.tools.jlink.plugin.Plugin;
-
-/**
- * Rogue adder plugin
- */
-public final class RogueAdderPlugin implements Plugin {
-    public static final String NAME = "rogue-adder";
-    private String resName;
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
-        in.transformAndCopy(Function.identity(), out);
-        out.add(ResourcePoolEntry.create(resName, new byte[1]));
-        return out.build();
-    }
-
-    @Override
-    public String getDescription() {
-        return NAME + "-description";
-    }
-
-    @Override
-    public Category getType() {
-        return Category.FILTER;
-    }
-
-    @Override
-    public boolean hasArguments() {
-        return true;
-    }
-
-    @Override
-    public void configure(Map<String, String> config) {
-        resName = config.get(NAME);
-    }
-}
--- a/jdk/test/tools/jlink/customplugin/plugin/RogueFilterPlugin.java	Thu Jan 26 23:11:37 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package plugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.util.Collections;
-import java.util.Map;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.Plugin;
-
-/**
- * Rogue filter plugin
- */
-public final class RogueFilterPlugin implements Plugin {
-    public static final String NAME = "rogue-filter";
-    private String prefix;
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
-        in.transformAndCopy((file) -> {
-            return file.path().startsWith(prefix)? null : file;
-        }, out);
-        return out.build();
-    }
-
-    @Override
-    public String getDescription() {
-        return NAME + "-description";
-    }
-
-    @Override
-    public Category getType() {
-        return Category.FILTER;
-    }
-
-    @Override
-    public boolean hasArguments() {
-        return true;
-    }
-
-    @Override
-    public void configure(Map<String, String> config) {
-        prefix = config.get(NAME);
-    }
-}