RFR: 8279995: jpackage --add-launcher option should allow overriding description [v4]
Alexey Semenyuk
asemenyuk at openjdk.java.net
Wed Feb 23 20:33:54 UTC 2022
On Thu, 17 Feb 2022 06:54:33 GMT, Alexander Matveev <almatvee at openjdk.org> wrote:
>> Added ability to override description for additional launchers via "description" property.
>
> Alexander Matveev has updated the pull request incrementally with one additional commit since the last revision:
>
> 8279995: jpackage --add-launcher option should allow overriding description [v4]
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java line 165:
> 163:
> 164: return description;
> 165: }
How about this:
public static String getExecutableDesciption(Path pathToExeFile) {
Executor exec = Executor.of("powershell",
"-NoLogo",
"-NoProfile",
"-Command",
"(Get-Item \\""
+ pathToExeFile.toAbsolutePath()
+ "\\").VersionInfo | select FileDescription");
var lineIt = exec.dumpOutput().executeAndGetOutput().iterator();
while (lineIt.hasNext()) {
var line = lineIt.next();
if (line.trim().equals("FileDescription")) {
// Skip "---------------" and move to the description value
lineIt.next();
var description = lineIt.next().trim();
if (lineIt.hasNext()) {
throw new RuntimeException("Unexpected input");
}
return description;
}
}
throw new RuntimeException(String.format(
"Failed to get file description of [%s]", pathToExeFile));
}
Added `Executor.dumpOutput()` call to save the output of powershell command in the test log for easier debugging.
No null initialized `description` variable. No iteration over the list using the index. Check for the end of the output.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7399
More information about the core-libs-dev
mailing list