test/jdk/tools/jpackage/helpers/JPackageHelper.java
branchJDK-8200758-branch
changeset 57324 c1d3935fbb79
parent 57314 23da9e6f446f
child 57395 521c02b9eed0
equal deleted inserted replaced
57323:66c1dbc008c5 57324:c1d3935fbb79
   345             throw new AssertionError("jar exited with error: " + retVal);
   345             throw new AssertionError("jar exited with error: " + retVal);
   346         }
   346         }
   347     }
   347     }
   348 
   348 
   349     public static void createHelloModule() throws Exception {
   349     public static void createHelloModule() throws Exception {
   350         createModule("Hello.java");
   350         createModule("Hello.java", "input", "hello");
   351     }
   351     }
   352 
   352 
   353     private static void createModule(String javaFile)
   353     public static void createOtherModule() throws Exception {
   354             throws Exception {
   354         createModule("Other.java", "input-other", "other");
       
   355     }
       
   356 
       
   357     private static void createModule(String javaFile, String inputDir,
       
   358             String aName) throws Exception {
   355         int retVal;
   359         int retVal;
   356 
   360 
   357         File input = new File("input");
   361         File input = new File(inputDir);
   358         if (!input.exists()) {
   362         if (!input.exists()) {
   359             input.mkdir();
   363             input.mkdir();
   360         }
   364         }
   361 
   365 
   362         File module = new File("module" + File.separator + "com.hello");
   366         File module = new File("module" + File.separator + "com." + aName);
   363         if (!module.exists()) {
   367         if (!module.exists()) {
   364             module.mkdirs();
   368             module.mkdirs();
   365         }
   369         }
   366 
   370 
   367         File javacLog = new File("javac.log");
   371         File javacLog = new File("javac.log");
   368         try {
   372         try {
   369             List<String> args = new ArrayList<>();
   373             List<String> args = new ArrayList<>();
   370             args.add(JAVAC.toString());
   374             args.add(JAVAC.toString());
   371             args.add("-d");
   375             args.add("-d");
   372             args.add("module" + File.separator + "com.hello");
   376             args.add("module" + File.separator + "com." + aName);
   373             args.add(TEST_SRC_ROOT + File.separator + "apps" + File.separator + "com.hello"
   377             args.add(TEST_SRC_ROOT + File.separator + "apps" + File.separator
   374                     + File.separator + "module-info.java");
   378                     + "com." + aName + File.separator + "module-info.java");
   375             args.add(TEST_SRC_ROOT + File.separator + "apps" + File.separator + "com.hello"
   379             args.add(TEST_SRC_ROOT + File.separator + "apps"
   376                     + File.separator + "com" + File.separator + "hello" + File.separator
   380                     + File.separator + "com." + aName + File.separator + "com"
   377                     + javaFile);
   381                     + File.separator + aName + File.separator + javaFile);
   378             retVal = execute(javacLog, args.stream().toArray(String[]::new));
   382             retVal = execute(javacLog, args.stream().toArray(String[]::new));
   379         } catch (Exception ex) {
   383         } catch (Exception ex) {
   380             if (javacLog.exists()) {
   384             if (javacLog.exists()) {
   381                 System.err.println(Files.readString(javacLog.toPath()));
   385                 System.err.println(Files.readString(javacLog.toPath()));
   382             }
   386             }
   394         try {
   398         try {
   395             List<String> args = new ArrayList<>();
   399             List<String> args = new ArrayList<>();
   396             args.add(JAR.toString());
   400             args.add(JAR.toString());
   397             args.add("--create");
   401             args.add("--create");
   398             args.add("--file");
   402             args.add("--file");
   399             args.add("input" + File.separator + "com.hello.jar");
   403             args.add(inputDir + File.separator + "com." + aName + ".jar");
   400             args.add("-C");
   404             args.add("-C");
   401             args.add("module" + File.separator + "com.hello");
   405             args.add("module" + File.separator + "com." + aName);
   402             args.add(".");
   406             args.add(".");
   403 
   407 
   404             retVal = execute(jarLog, args.stream().toArray(String[]::new));
   408             retVal = execute(jarLog, args.stream().toArray(String[]::new));
   405         } catch (Exception ex) {
   409         } catch (Exception ex) {
   406             if (jarLog.exists()) {
   410             if (jarLog.exists()) {