jdk/test/tools/jlink/customplugin/plugin/RogueFilterPlugin.java
changeset 43359 269efd520e13
parent 43358 9e2d943b5b66
parent 43353 2498f60f2ef1
child 43361 b580f96a38b4
equal deleted inserted replaced
43358:9e2d943b5b66 43359:269efd520e13
     1 /*
       
     2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 package plugin;
       
    24 
       
    25 import java.io.File;
       
    26 import java.io.IOException;
       
    27 import java.io.UncheckedIOException;
       
    28 import java.util.Collections;
       
    29 import java.util.Map;
       
    30 import jdk.tools.jlink.plugin.ResourcePoolEntry;
       
    31 import jdk.tools.jlink.plugin.ResourcePool;
       
    32 import jdk.tools.jlink.plugin.ResourcePoolBuilder;
       
    33 import jdk.tools.jlink.plugin.Plugin;
       
    34 
       
    35 /**
       
    36  * Rogue filter plugin
       
    37  */
       
    38 public final class RogueFilterPlugin implements Plugin {
       
    39     public static final String NAME = "rogue-filter";
       
    40     private String prefix;
       
    41 
       
    42     @Override
       
    43     public String getName() {
       
    44         return NAME;
       
    45     }
       
    46 
       
    47     @Override
       
    48     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
       
    49         in.transformAndCopy((file) -> {
       
    50             return file.path().startsWith(prefix)? null : file;
       
    51         }, out);
       
    52         return out.build();
       
    53     }
       
    54 
       
    55     @Override
       
    56     public String getDescription() {
       
    57         return NAME + "-description";
       
    58     }
       
    59 
       
    60     @Override
       
    61     public Category getType() {
       
    62         return Category.FILTER;
       
    63     }
       
    64 
       
    65     @Override
       
    66     public boolean hasArguments() {
       
    67         return true;
       
    68     }
       
    69 
       
    70     @Override
       
    71     public void configure(Map<String, String> config) {
       
    72         prefix = config.get(NAME);
       
    73     }
       
    74 }