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 package com.oracle.appbundlers.tests.functionality.jdk9test;
   6 
   7 import static java.util.stream.Collectors.toSet;
   8 
   9 import java.io.IOException;
  10 import java.nio.file.Path;
  11 import java.util.HashMap;
  12 import java.util.Map;
  13 
  14 import com.oracle.appbundlers.tests.functionality.functionalinterface.BasicParams;
  15 import com.oracle.appbundlers.tests.functionality.parameters.GenericModuleParameters;
  16 import com.oracle.appbundlers.utils.AppWrapper;
  17 import com.oracle.appbundlers.utils.ExtensionType;
  18 import com.oracle.tools.packager.RelativeFileSet;
  19 import com.sun.javafx.tools.packager.bundlers.BundleParams;
  20 
  21 /**
  22  * @author Ramesh BG
  23  *
  24  */
  25 public class MainModuleTest extends ModuleTestBase {
  26 
  27     protected BasicParams getBasicParams() {
  28         return (AppWrapper app) -> {
  29             Map<String, Object> params = new HashMap<>();
  30             params.put(BundleParams.PARAM_APP_RESOURCES,
  31                     new RelativeFileSet(app.getJarDir().toFile(),
  32                             app.getJarFilesList().stream().map(Path::toFile)
  33                                     .collect(toSet())));
  34             params.put(MODULEPATH, ((GenericModuleParameters) this.currentParameter).getModulePath());
  35             params.put(APP_NAME, getResultingAppName());
  36             params.put(MAIN_MODULE,
  37                     app.getMainModuleName() + "/" + app.getMainClass());
  38             return params;
  39         };
  40     }
  41 
  42     @Override
  43     public void overrideParameters(ExtensionType intermediate)
  44             throws IOException {
  45         this.currentParameter.setBasicParams(getBasicParams());
  46     }
  47 }