@@ -6,6 +6,7 @@ import java.nio.file.Path
6
6
/* * A source for creating class paths */
7
7
interface ClassPathResolver {
8
8
val resolverType: String
9
+
9
10
val classpath: Set <Path > // may throw exceptions
10
11
val classpathOrEmpty: Set <Path > // does not throw exceptions
11
12
get() = try {
@@ -15,6 +16,16 @@ interface ClassPathResolver {
15
16
emptySet<Path >()
16
17
}
17
18
19
+ val buildScriptClasspath: Set <Path >
20
+ get() = emptySet<Path >()
21
+ val buildScriptClasspathOrEmpty: Set <Path >
22
+ get() = try {
23
+ buildScriptClasspath
24
+ } catch (e: Exception ) {
25
+ LOG .warn(" Could not resolve buildscript classpath using {}: {}" , resolverType, e.message)
26
+ emptySet<Path >()
27
+ }
28
+
18
29
companion object {
19
30
/* * A default empty classpath implementation */
20
31
val empty = object : ClassPathResolver {
@@ -39,10 +50,14 @@ internal class UnionClassPathResolver(val lhs: ClassPathResolver, val rhs: Class
39
50
override val resolverType: String get() = " (${lhs.resolverType} + ${rhs.resolverType} )"
40
51
override val classpath get() = lhs.classpath + rhs.classpath
41
52
override val classpathOrEmpty get() = lhs.classpathOrEmpty + rhs.classpathOrEmpty
53
+ override val buildScriptClasspath get() = lhs.buildScriptClasspath + rhs.buildScriptClasspath
54
+ override val buildScriptClasspathOrEmpty get() = lhs.buildScriptClasspathOrEmpty + rhs.buildScriptClasspathOrEmpty
42
55
}
43
56
44
57
internal class FirstNonEmptyClassPathResolver (val lhs : ClassPathResolver , val rhs : ClassPathResolver ) : ClassPathResolver {
45
58
override val resolverType: String get() = " (${lhs.resolverType} or ${rhs.resolverType} )"
46
59
override val classpath get() = lhs.classpath.takeIf { it.isNotEmpty() } ? : rhs.classpath
47
60
override val classpathOrEmpty get() = lhs.classpathOrEmpty.takeIf { it.isNotEmpty() } ? : rhs.classpathOrEmpty
61
+ override val buildScriptClasspath get() = lhs.buildScriptClasspath.takeIf { it.isNotEmpty() } ? : rhs.buildScriptClasspath
62
+ override val buildScriptClasspathOrEmpty get() = lhs.buildScriptClasspathOrEmpty.takeIf { it.isNotEmpty() } ? : rhs.buildScriptClasspathOrEmpty
48
63
}
0 commit comments