1 /* 2 * Copyright (c) 2019, 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 24 package jdk.jpackage.tests; 25 26 import java.io.IOException; 27 import java.nio.file.Path; 28 import java.util.stream.Stream; 29 import jdk.jpackage.test.Functional.ThrowingSupplier; 30 import jdk.jpackage.test.HelloApp; 31 import jdk.jpackage.test.JavaAppDesc; 32 import jdk.jpackage.test.Annotations.Test; 33 import jdk.jpackage.test.Annotations.Parameter; 34 import jdk.jpackage.test.JPackageCommand; 35 import jdk.jpackage.test.TKit; 36 37 38 /* 39 * @test 40 * @summary jpackage with --module-path testing 41 * @library ../../../../helpers 42 * @build jdk.jpackage.test.* 43 * @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal 44 * @compile ModulePathTest2.java 45 * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main 46 * --jpt-run=jdk.jpackage.tests.ModulePathTest2 47 */ 48 49 public final class ModulePathTest2 { 50 51 /** 52 * Test case for JDK-8233265. 53 * Adding modules in .jmod files for non-modular app results in unexpected 54 * jpackage failure. 55 * @param mainAppDesc 56 */ 57 @Test 58 @Parameter("Hello!") 59 @Parameter("com.foo/com.foo.ModuleApp") 60 public void test8233265(String mainAppDesc) throws IOException { 61 JPackageCommand cmd = JPackageCommand.helloAppImage(mainAppDesc); 62 63 // The test should make jpackage invoke jlink. 64 cmd.ignoreDefaultRuntime(true); 65 66 Path modulePath = cmd.getArgumentValue("--module-path", () -> null, Path::of); 67 if (modulePath == null) { 68 modulePath = TKit.createTempDirectory("input-modules"); 69 cmd.addArguments("--module-path", modulePath); 70 } 71 72 JavaAppDesc extraModule = JavaAppDesc.parse("x.jmod:com.x/com.x.Y"); 73 HelloApp.createBundle(extraModule, modulePath); 74 cmd.addArguments("--add-modules", extraModule.moduleName()); 75 76 cmd.executeAndAssertHelloAppImageCreated(); 77 } 78 }