jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.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) 2015, 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  * Custom plugin
       
    37  */
       
    38 public final class HelloPlugin implements Plugin {
       
    39 
       
    40     private static final String OUTPUT_FILE = "customplugin.txt";
       
    41     public static final String NAME = "hello";
       
    42 
       
    43     public static boolean called;
       
    44 
       
    45     @Override
       
    46     public String getName() {
       
    47         return NAME;
       
    48     }
       
    49 
       
    50     @Override
       
    51     public ResourcePool transform(ResourcePool inResources, ResourcePoolBuilder outResources) {
       
    52         try {
       
    53             System.out.println("Hello!!!!!!!!!!");
       
    54             File f = new File(OUTPUT_FILE);
       
    55             f.createNewFile();
       
    56             inResources.entries().forEach(res -> {
       
    57                 outResources.add(res);
       
    58             });
       
    59         } catch (IOException ex) {
       
    60             throw new UncheckedIOException(ex);
       
    61         }
       
    62         return outResources.build();
       
    63     }
       
    64 
       
    65     @Override
       
    66     public String getDescription() {
       
    67         return NAME + "-description";
       
    68     }
       
    69 }