modules/jdk.packager/src/main/java/com/oracle/tools/packager/StandardBundlerParam.java

Print this page


   1 /*
   2  * Copyright (c) 2014, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 705             new StandardBundlerParam<>(
 706                     I18N.getString("param.limit-modules.name"),
 707                     I18N.getString("param.limit-modules.description"),
 708                     "limit-modules",
 709                     (Class<Set<String>>) (Object) Set.class,
 710                     p -> new LinkedHashSet(),
 711                     (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
 712             );
 713 
 714     @SuppressWarnings("unchecked")
 715     public static final BundlerParamInfo<Boolean> STRIP_NATIVE_COMMANDS =
 716             new StandardBundlerParam<>(
 717                     I18N.getString("param.strip-executables.name"),
 718                     I18N.getString("param.strip-executables.description"),
 719                     "strip-native-commands",
 720                     Boolean.class,
 721                     p -> Boolean.TRUE,
 722                     (s, p) -> Boolean.valueOf(s)
 723             );
 724 









 725     public static void extractMainClassInfoFromAppResources(Map<String, ? super Object> params) {
 726         boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
 727         boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
 728         boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
 729         boolean hasPreloader = params.containsKey(PRELOADER_CLASS.getID());
 730         boolean hasModule = params.containsKey(MODULE.getID());
 731 
 732         if (hasMainClass && hasMainJar && hasMainJarClassPath || hasModule) {
 733             return;
 734         }
 735 
 736         // it's a pair.  The [0] is the srcdir [1] is the file relative to sourcedir
 737         List<String[]> filesToCheck = new ArrayList<>();
 738 
 739         if (hasMainJar) {
 740             RelativeFileSet rfs = MAIN_JAR.fetchFrom(params);
 741             for (String s : rfs.getIncludedFiles()) {
 742                 filesToCheck.add(new String[]{rfs.getBaseDirectory().toString(), s});
 743             }
 744         } else if (hasMainJarClassPath) {


   1 /*
   2  * Copyright (c) 2014, 2017, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 705             new StandardBundlerParam<>(
 706                     I18N.getString("param.limit-modules.name"),
 707                     I18N.getString("param.limit-modules.description"),
 708                     "limit-modules",
 709                     (Class<Set<String>>) (Object) Set.class,
 710                     p -> new LinkedHashSet(),
 711                     (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
 712             );
 713 
 714     @SuppressWarnings("unchecked")
 715     public static final BundlerParamInfo<Boolean> STRIP_NATIVE_COMMANDS =
 716             new StandardBundlerParam<>(
 717                     I18N.getString("param.strip-executables.name"),
 718                     I18N.getString("param.strip-executables.description"),
 719                     "strip-native-commands",
 720                     Boolean.class,
 721                     p -> Boolean.TRUE,
 722                     (s, p) -> Boolean.valueOf(s)
 723             );
 724 
 725     public static final BundlerParamInfo<Boolean> SINGLETON = new StandardBundlerParam<> (
 726         I18N.getString("param.singleton.name"),
 727         I18N.getString("param.singleton.description"),
 728         BundleParams.PARAM_SINGLETON,
 729         Boolean.class,
 730         params -> Boolean.FALSE,
 731         (s, p) -> Boolean.valueOf(s)
 732     );
 733 
 734     public static void extractMainClassInfoFromAppResources(Map<String, ? super Object> params) {
 735         boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
 736         boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
 737         boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
 738         boolean hasPreloader = params.containsKey(PRELOADER_CLASS.getID());
 739         boolean hasModule = params.containsKey(MODULE.getID());
 740 
 741         if (hasMainClass && hasMainJar && hasMainJarClassPath || hasModule) {
 742             return;
 743         }
 744 
 745         // it's a pair.  The [0] is the srcdir [1] is the file relative to sourcedir
 746         List<String[]> filesToCheck = new ArrayList<>();
 747 
 748         if (hasMainJar) {
 749             RelativeFileSet rfs = MAIN_JAR.fetchFrom(params);
 750             for (String s : rfs.getIncludedFiles()) {
 751                 filesToCheck.add(new String[]{rfs.getBaseDirectory().toString(), s});
 752             }
 753         } else if (hasMainJarClassPath) {