1
1
package org.javacs.kt.classpath
2
2
3
+ import org.javacs.kt.LOG
3
4
import org.jetbrains.exposed.dao.IntEntity
4
5
import org.jetbrains.exposed.dao.IntEntityClass
5
6
import org.jetbrains.exposed.dao.id.EntityID
@@ -50,12 +51,14 @@ internal class CachedClassPathResolver(private val wrapped: ClassPathResolver, p
50
51
override val resolverType: String get() = " Cached + ${wrapped.resolverType} "
51
52
52
53
private var cachedClassPathEntries: Set <ClassPathEntry >
53
- get() = transaction(db) { ClassPathCacheEntryEntity .all() }.map {
54
- ClassPathEntry (
55
- compiledJar = Paths .get(it.compiledJar),
56
- sourceJar = if (it.sourceJar != null ) Paths .get(it.sourceJar) else null
57
- )
58
- }.toSet()
54
+ get() = transaction(db) {
55
+ ClassPathCacheEntryEntity .all().map {
56
+ ClassPathEntry (
57
+ compiledJar = Paths .get(it.compiledJar),
58
+ sourceJar = if (it.sourceJar != null ) Paths .get(it.sourceJar) else null
59
+ )
60
+ }.toSet()
61
+ }
59
62
set(newEntries) = transaction(db) {
60
63
ClassPathCacheEntry .deleteAll()
61
64
newEntries.map {
@@ -67,19 +70,21 @@ internal class CachedClassPathResolver(private val wrapped: ClassPathResolver, p
67
70
}
68
71
69
72
private var cachedBuildScriptClassPathEntries: Set <Path >
70
- get() = transaction(db) { BuildScriptClassPathCacheEntryEntity .all() } .map { Paths .get(it.jar) }.toSet()
73
+ get() = transaction(db) { BuildScriptClassPathCacheEntryEntity .all().map { Paths .get(it.jar) }.toSet() }
71
74
set(newEntries) = transaction(db) {
72
75
BuildScriptClassPathCacheEntry .deleteAll()
73
76
newEntries.map { BuildScriptClassPathCacheEntryEntity .new { jar = it.toString() } }
74
77
}
75
78
76
79
private var cachedClassPathMetadata
77
- get() = transaction(db) { ClassPathMetadataCacheEntity .all().map {
78
- ClasspathMetadata (
79
- includesSources = it.includesSources,
80
- buildFileVersion = it.buildFileVersion
81
- )
82
- }.firstOrNull() }
80
+ get() = transaction(db) {
81
+ ClassPathMetadataCacheEntity .all().map {
82
+ ClasspathMetadata (
83
+ includesSources = it.includesSources,
84
+ buildFileVersion = it.buildFileVersion
85
+ )
86
+ }.firstOrNull()
87
+ }
83
88
set(newClassPathMetadata) = transaction(db) {
84
89
ClassPathMetadataCache .deleteAll()
85
90
val newClassPathMetadataRow = newClassPathMetadata ? : ClasspathMetadata ()
@@ -96,7 +101,12 @@ internal class CachedClassPathResolver(private val wrapped: ClassPathResolver, p
96
101
}
97
102
98
103
override val classpath: Set <ClassPathEntry > get() {
99
- cachedClassPathEntries.let { if (! dependenciesChanged()) return it }
104
+ cachedClassPathEntries.let { if (! dependenciesChanged()) {
105
+ LOG .info(" Classpath has not changed. Fetching from cache" )
106
+ return it
107
+ } }
108
+
109
+ LOG .info(" Cached classpath is outdated or not found. Resolving again" )
100
110
101
111
val newClasspath = wrapped.classpath
102
112
updateClasspathCache(newClasspath, false )
@@ -105,7 +115,12 @@ internal class CachedClassPathResolver(private val wrapped: ClassPathResolver, p
105
115
}
106
116
107
117
override val buildScriptClasspath: Set <Path > get() {
108
- if (! dependenciesChanged()) return cachedBuildScriptClassPathEntries
118
+ if (! dependenciesChanged()) {
119
+ LOG .info(" Build script classpath has not changed. Fetching from cache" )
120
+ return cachedBuildScriptClassPathEntries
121
+ }
122
+
123
+ LOG .info(" Cached build script classpath is outdated or not found. Resolving again" )
109
124
110
125
val newBuildScriptClasspath = wrapped.buildScriptClasspath
111
126
0 commit comments