@@ -11,13 +11,13 @@ import java.io.File;
11
11
* Defines a trait which handles deerialization of paths, in a way that can be used by both path refs and paths
12
12
*/
13
13
trait PathUtils {
14
- // TEMPORARY! A better solution needs to be found.
14
+ // TEMPORARY! A better solution needs to be found.
15
15
def findOutRoot (): os.Path = {
16
16
val outFolderName = OutFiles .out
17
17
val root = os.Path (new File (" " ).getCanonicalPath().toString)
18
18
var currentPath = root
19
19
20
- for (i <- 1 to 100 ){
20
+ for (i <- 1 to 100 ) {
21
21
if (os.exists(currentPath / " mill-java-home" )) {
22
22
return currentPath
23
23
} else {
@@ -29,13 +29,15 @@ trait PathUtils {
29
29
}
30
30
}
31
31
root
32
- }
32
+ }
33
+
34
+ lazy val outFolderRoot : os.Path = findOutRoot()
35
+
33
36
/*
34
37
* Returns a list of paths and their variables to be substituted with.
35
38
*/
36
39
implicit def substitutions (): List [(os.Path , String )] = {
37
- val out = findOutRoot()
38
- var result = List ((out, " *$WorkplaceRoot*" ))
40
+ var result = List ((outFolderRoot, " *$WorkplaceRoot*" ))
39
41
val javaHome = os.Path (System .getProperty(" java.home" ))
40
42
result = result :+ (javaHome, " *$JavaHome*" )
41
43
@@ -79,7 +81,7 @@ trait PathUtils {
79
81
var result = a
80
82
var depth = 0
81
83
subs.foreach { case (path, sub) =>
82
- val pathDepth = path.segments.length
84
+ val pathDepth = path.segments.length
83
85
val pathString = path.toString
84
86
// In the case that a path is in the folder of another path, it picks the path with the most depth
85
87
if (result.startsWith(sub) && pathDepth >= depth) {
@@ -90,5 +92,5 @@ trait PathUtils {
90
92
91
93
// println(s"2!! $a -> $result")
92
94
os.Path (result)
93
- }
95
+ }
94
96
}
0 commit comments