settings.gradle.kts failed to parse rootProject variable on windows
markfergy opened this issue · comments
Hi,
I have been using quarkus to build a java project using gradle where the rootProject variable has been set in the gradle settings file.
settings.gradle.kts
rootProject.name = "code-with-quarkus-windows"
Command to reproduced the error:
gradlew --no-daemon build -Dquarkus.kubernetes.deploy=true -Dquarkus.kubernetes-client.trust-certs=true
This caused an exception to be thrown:
Build step io.quarkus.kubernetes.deployment.KubernetesDeployer#deploy threw an exception: java.lang.NullPointerException: Cannot invoke "io.quarkus.kubernetes.spi.KubernetesOutputDirectoryBuildItem.getOutputDirectory()" because "outputDirectoryBuildItem" is null
I debugged the quarkus gradle plugin and found a windows path error invalid character quote <">
Further debugging identified the issue to be coming from the GradleInfoReader.java class and method readSettingsGradle
protected static Map<String, String> readSettingsGradle(Path path) {
Map<String, String> properties = new HashMap<>();
if (path.toFile().exists()) {
try {
Files.lines(path)
.map(l -> l.replaceAll("[ ]*", ""))
.filter(l -> l.contains(EQUALS))
.forEach(l -> {
String key = l.substring(0, l.lastIndexOf(EQUALS));
if (key.startsWith(ROOT_PROJECT_PREFIX)) {
key = key.substring(ROOT_PROJECT_PREFIX.length());
String value = l.substring(l.lastIndexOf(EQUALS) + 1).replaceAll(QUOTE, "");
properties.put(key, value);
}
});
} catch (IOException e) {
throw DekorateException.launderThrowable(e);
}
}
return properties;
}
I could see the value being added into the properties map was double quoted for example:
""code-with-quarkus-windows""
This would then cause an issue when a filename was being generated from the root project name.
Note the problem is only reproduceable on Windows as on Linux quotes in a file name are ignored.