Skip to content

Commit dcd5e2c

Browse files
heliocastrosschuberth
authored andcommitted
feat(ort-utils): Handle macOS in singleContainedDirectoryOrThis()
Native macOS installations follow system placement, requiring path adjustments not necessary on other platforms. Signed-off-by: Helio Chissini de Castro <[email protected]> Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 8710b76 commit dcd5e2c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

utils/ort/src/main/kotlin/JavaBootstrapper.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ object JavaBootstrapper {
5050
/**
5151
* Return the single top-level directory contained in this directory, if any, or return this directory otherwise.
5252
*/
53-
private fun File.singleContainedDirectoryOrThis() =
54-
walk().maxDepth(1).filter { it != this && it.isDirectory }.singleOrNull() ?: this
53+
private fun File.singleContainedDirectoryOrThis(): File {
54+
val dir = walk().maxDepth(1).filter { it != this && it.isDirectory }.singleOrNull() ?: this
55+
return if (Os.isMac) dir / "Contents" / "Home" else dir
56+
}
5557

5658
/**
5759
* Return whether ORT is running on a JDK (not JRE) of the specified [version].

0 commit comments

Comments
 (0)