11package org.javacs.kt.classpath
22
3+ import org.javacs.kt.LOG
34import org.jetbrains.exposed.dao.IntEntity
45import org.jetbrains.exposed.dao.IntEntityClass
56import org.jetbrains.exposed.dao.id.EntityID
@@ -50,12 +51,14 @@ internal class CachedClassPathResolver(private val wrapped: ClassPathResolver, p
5051 override val resolverType: String get() = " Cached + ${wrapped.resolverType} "
5152
5253 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+ }
5962 set(newEntries) = transaction(db) {
6063 ClassPathCacheEntry .deleteAll()
6164 newEntries.map {
@@ -67,19 +70,21 @@ internal class CachedClassPathResolver(private val wrapped: ClassPathResolver, p
6770 }
6871
6972 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() }
7174 set(newEntries) = transaction(db) {
7275 BuildScriptClassPathCacheEntry .deleteAll()
7376 newEntries.map { BuildScriptClassPathCacheEntryEntity .new { jar = it.toString() } }
7477 }
7578
7679 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+ }
8388 set(newClassPathMetadata) = transaction(db) {
8489 ClassPathMetadataCache .deleteAll()
8590 val newClassPathMetadataRow = newClassPathMetadata ? : ClasspathMetadata ()
@@ -96,7 +101,12 @@ internal class CachedClassPathResolver(private val wrapped: ClassPathResolver, p
96101 }
97102
98103 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" )
100110
101111 val newClasspath = wrapped.classpath
102112 updateClasspathCache(newClasspath, false )
@@ -105,7 +115,12 @@ internal class CachedClassPathResolver(private val wrapped: ClassPathResolver, p
105115 }
106116
107117 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" )
109124
110125 val newBuildScriptClasspath = wrapped.buildScriptClasspath
111126
0 commit comments