< prev index next >

modules/jdk.packager/src/main/java/jdk/packager/internal/JLinkBundlerHelper.java

Print this page




  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
  23  * questions.
  24  */
  25 
  26 package jdk.packager.internal;
  27 
  28 
  29 import com.oracle.tools.packager.StandardBundlerParam;
  30 import com.oracle.tools.packager.BundlerParamInfo;
  31 import com.oracle.tools.packager.RelativeFileSet;
  32 import com.oracle.tools.packager.Log;

  33 
  34 import java.io.ByteArrayOutputStream;
  35 import java.io.File;
  36 import java.io.FileInputStream;
  37 import java.io.FileNotFoundException;
  38 import java.io.IOException;
  39 import java.io.InputStream;
  40 import java.io.PrintWriter;
  41 import java.io.StringReader;
  42 import java.net.URI;
  43 import java.nio.file.Files;
  44 import java.nio.file.Path;
  45 import java.nio.file.Paths;
  46 import java.text.MessageFormat;
  47 import java.util.ArrayList;
  48 import java.util.Arrays;
  49 import java.util.Collection;
  50 import java.util.Collections;
  51 import java.util.EnumSet;
  52 import java.util.HashMap;


 223         String result = "";
 224         List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
 225         Path javaBasePath = findPathOfModule(modulePath, "java.base.jmod");
 226 
 227         if (javaBasePath != null && javaBasePath.toFile().exists()) {
 228             result = RedistributableModules.getModuleVersion(javaBasePath.toFile(),
 229                         modulePath, StandardBundlerParam.ADD_MODULES.fetchFrom(params),
 230                         StandardBundlerParam.LIMIT_MODULES.fetchFrom(params));
 231         }
 232 
 233         return result;
 234     }
 235 
 236     public static Path getJDKHome(Map<String, ? super Object> params) {
 237         Path result = null;
 238         List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
 239         Path javaBasePath = findPathOfModule(modulePath, "java.base.jmod");
 240 
 241         if (javaBasePath != null && javaBasePath.toFile().exists()) {
 242             result = javaBasePath.getParent();





















 243         }
 244 
 245         return result;
 246     }
 247 
 248     public static void execute(Map<String, ? super Object> params, AbstractAppImageBuilder imageBuilder) throws IOException, Exception {
 249         List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
 250         Set<String> addModules = StandardBundlerParam.ADD_MODULES.fetchFrom(params);
 251         Set<String> limitModules = StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
 252         boolean stripNativeCommands = StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params);
 253         Map<String, String> userArguments = JLINK_OPTIONS.fetchFrom(params);
 254         Path outputDir = imageBuilder.getRoot();
 255         String excludeFileList = imageBuilder.getExcludeFileList();
 256         Set<String> jars = getResourceFileJarList(params, Module.JarType.UnnamedJar);
 257         File mainJar = getMainJar(params);
 258         Module.ModuleType mainJarType = Module.ModuleType.Unknown;
 259 
 260         if (mainJar != null) {
 261             mainJarType = new Module(mainJar).getModuleType();
 262         }




  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
  23  * questions.
  24  */
  25 
  26 package jdk.packager.internal;
  27 
  28 
  29 import com.oracle.tools.packager.StandardBundlerParam;
  30 import com.oracle.tools.packager.BundlerParamInfo;
  31 import com.oracle.tools.packager.RelativeFileSet;
  32 import com.oracle.tools.packager.Log;
  33 import com.oracle.tools.packager.Platform;
  34 
  35 import java.io.ByteArrayOutputStream;
  36 import java.io.File;
  37 import java.io.FileInputStream;
  38 import java.io.FileNotFoundException;
  39 import java.io.IOException;
  40 import java.io.InputStream;
  41 import java.io.PrintWriter;
  42 import java.io.StringReader;
  43 import java.net.URI;
  44 import java.nio.file.Files;
  45 import java.nio.file.Path;
  46 import java.nio.file.Paths;
  47 import java.text.MessageFormat;
  48 import java.util.ArrayList;
  49 import java.util.Arrays;
  50 import java.util.Collection;
  51 import java.util.Collections;
  52 import java.util.EnumSet;
  53 import java.util.HashMap;


 224         String result = "";
 225         List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
 226         Path javaBasePath = findPathOfModule(modulePath, "java.base.jmod");
 227 
 228         if (javaBasePath != null && javaBasePath.toFile().exists()) {
 229             result = RedistributableModules.getModuleVersion(javaBasePath.toFile(),
 230                         modulePath, StandardBundlerParam.ADD_MODULES.fetchFrom(params),
 231                         StandardBundlerParam.LIMIT_MODULES.fetchFrom(params));
 232         }
 233 
 234         return result;
 235     }
 236 
 237     public static Path getJDKHome(Map<String, ? super Object> params) {
 238         Path result = null;
 239         List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
 240         Path javaBasePath = findPathOfModule(modulePath, "java.base.jmod");
 241 
 242         if (javaBasePath != null && javaBasePath.toFile().exists()) {
 243             result = javaBasePath.getParent();
 244 
 245             // On a developer build the JDK Home isn't where we expect it
 246             // relative to the jmods directory. Do some extra
 247             // processing to find it.
 248             if (result != null) {
 249                 boolean found = false;
 250                 Path bin = result.resolve("bin");
 251 
 252                 if (Files.exists(bin)) {
 253                     final String exe = (Platform.getPlatform() == Platform.WINDOWS) ? ".exe" : "";
 254                     Path javaExe = bin.resolve("java" + exe);
 255 
 256                     if (Files.exists(javaExe)) {
 257                         found = true;
 258                     }
 259                 }
 260 
 261                 if (!found) {
 262                     result = result.resolve("..\\jdk");
 263                 }
 264             }
 265         }
 266 
 267         return result;
 268     }
 269 
 270     public static void execute(Map<String, ? super Object> params, AbstractAppImageBuilder imageBuilder) throws IOException, Exception {
 271         List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
 272         Set<String> addModules = StandardBundlerParam.ADD_MODULES.fetchFrom(params);
 273         Set<String> limitModules = StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
 274         boolean stripNativeCommands = StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params);
 275         Map<String, String> userArguments = JLINK_OPTIONS.fetchFrom(params);
 276         Path outputDir = imageBuilder.getRoot();
 277         String excludeFileList = imageBuilder.getExcludeFileList();
 278         Set<String> jars = getResourceFileJarList(params, Module.JarType.UnnamedJar);
 279         File mainJar = getMainJar(params);
 280         Module.ModuleType mainJarType = Module.ModuleType.Unknown;
 281 
 282         if (mainJar != null) {
 283             mainJarType = new Module(mainJar).getModuleType();
 284         }


< prev index next >