equal
deleted
inserted
replaced
25 package jdk.jpackage.test; |
25 package jdk.jpackage.test; |
26 |
26 |
27 |
27 |
28 import java.io.File; |
28 import java.io.File; |
29 import java.nio.file.Path; |
29 import java.nio.file.Path; |
|
30 import java.util.spi.ToolProvider; |
30 |
31 |
31 public enum JavaTool { |
32 public enum JavaTool { |
32 JAVAC("javac"), JPACKAGE("jpackage"), JAR("jar"); |
33 JAVAC("javac"), JPACKAGE("jpackage"), JAR("jar"); |
33 private File path; |
|
34 |
34 |
35 JavaTool(String name) { |
35 JavaTool(String name) { |
|
36 this.name = name; |
36 path = Path.of(System.getProperty("java.home"), "bin", name).toFile(); |
37 path = Path.of(System.getProperty("java.home"), "bin", name).toFile(); |
37 if (!path.exists()) { |
38 if (Test.isWindows()) { |
38 path = new File(path.toString() + ".exe"); |
39 path = new File(path.toString() + ".exe"); |
39 } |
40 } |
40 if (!path.exists()) { |
41 if (!path.exists()) { |
41 throw new RuntimeException("Unable to find tool [" |
42 throw new RuntimeException("Unable to find tool [" |
42 + name + "] at path=[" + path.getAbsolutePath() + "]"); |
43 + name + "] at path=[" + path.getAbsolutePath() + "]"); |
44 } |
45 } |
45 |
46 |
46 File getPath() { |
47 File getPath() { |
47 return path; |
48 return path; |
48 } |
49 } |
|
50 |
|
51 ToolProvider asToolProvider() { |
|
52 return ToolProvider.findFirst(name).orElse(null); |
|
53 } |
|
54 |
|
55 private File path; |
|
56 private String name; |
49 } |
57 } |