Skip to content

Commit ae4b8eb

Browse files
authored
Fix relativlization bug (#792)
If the temporary directory and the working directory are not on the same drive, relativization will fail. This commit uses an absolute path in case relativization is not possible. Fixes #777
1 parent 54db68c commit ae4b8eb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

common/utils/src/main/java/org/graalvm/buildtools/utils/NativeImageUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ public static List<String> convertToArgsFile(List<String> cliArgs, Path outputDi
101101

102102
Path resultingPath = tmpFile.toPath().toAbsolutePath();
103103
if (projectDir != null) { // We know where the project dir is, so want to use relative paths
104-
resultingPath = projectDir.toAbsolutePath().relativize(resultingPath);
104+
Path absProjectDir = projectDir.toAbsolutePath();
105+
// Only relativize if both paths are on the same file system (same drive on Windows)
106+
if (resultingPath.getRoot() != null && resultingPath.getRoot().equals(absProjectDir.getRoot())) {
107+
resultingPath = absProjectDir.relativize(resultingPath);
108+
}
105109
}
106110
return Collections.singletonList("@" + resultingPath);
107111
} catch (IOException e) {

docs/src/docs/asciidoc/changelog.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
[[changelog]]
22
== Changelog
33

4+
== Release 0.11.3
5+
6+
- Fixed use of argument file when the temporary directory is not on the same drive as the project
7+
8+
== Release 0.11.2
9+
10+
- Fixed missing JUnit types in build time initialization
11+
412
== Release 0.11.1
513

614
- Fix `NoClassDefFoundError` when JUnit feature is missing some dependency

0 commit comments

Comments
 (0)