[IC] Handle custom source set located outside project directory

To support build cache relocatability, we need to convert absolute paths
into relative paths before storing them in IC caches.

Before this commit, we computed relative paths based on the (root)
project directory and FAIL if some source files are located outside the
project directory.

With this commit, we will NOT FAIL in that case. This means relative
paths may start with "../". It's not "clean", but it can work.

Test: New test in BuildCacheRelocationIT
^KT-61852 Fixed
This commit is contained in:
Hung Nguyen
2023-09-19 18:08:02 +01:00
committed by Space Team
parent ff812197a8
commit 0d04b8783c
5 changed files with 85 additions and 96 deletions
@@ -84,7 +84,7 @@ class SourceToOutputFilesMapTest {
@Test
fun testSetRelativeFails() {
assertFailsWith<IllegalStateException> {
assertFailsWith<IllegalArgumentException> {
stofMap[fooDotKt] = listOf(File("relativePath"))
}
}
@@ -93,7 +93,7 @@ class SourceToOutputFilesMapTest {
fun testGetRelativeFails() {
stofMap[fooDotKt] = listOf(fooDotClass)
assertFailsWith<IllegalStateException> {
assertFailsWith<IllegalArgumentException> {
stofMap[fooDotKt.relativeTo(srcDir)]
}
}