Switch from koin to micronaut-inject
This commit is contained in:
@@ -2,6 +2,7 @@ import be.simplenotes.Libs
|
||||
|
||||
plugins {
|
||||
id("be.simplenotes.base")
|
||||
kotlin("kapt")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -11,7 +12,9 @@ dependencies {
|
||||
implementation(Libs.luceneQueryParser)
|
||||
implementation(Libs.luceneAnalyzersCommon)
|
||||
implementation(Libs.slf4jApi)
|
||||
implementation(Libs.koinCore)
|
||||
|
||||
implementation(Libs.micronaut)
|
||||
kapt(Libs.micronautProcessor)
|
||||
|
||||
testImplementation(Libs.junit)
|
||||
testImplementation(Libs.assertJ)
|
||||
|
||||
@@ -12,8 +12,17 @@ import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
import javax.inject.Named
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
internal class NoteSearcherImpl(
|
||||
@Named("search-index")
|
||||
basePath: Path,
|
||||
) : NoteSearcher {
|
||||
|
||||
constructor() : this(Path.of("/tmp", "lucene"))
|
||||
|
||||
internal class NoteSearcherImpl(basePath: Path = Path.of("/tmp", "lucene")) : NoteSearcher {
|
||||
private val baseFile = basePath.toFile()
|
||||
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package be.simplenotes.search
|
||||
|
||||
import org.koin.dsl.module
|
||||
import java.nio.file.Path
|
||||
|
||||
val searchModule = module {
|
||||
single<NoteSearcher> { NoteSearcherImpl(Path.of(".lucene")) }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package be.simplenotes.search
|
||||
|
||||
import io.micronaut.context.annotation.Factory
|
||||
import io.micronaut.context.annotation.Prototype
|
||||
import java.nio.file.Path
|
||||
import javax.inject.Named
|
||||
|
||||
@Factory
|
||||
class SearchModule {
|
||||
|
||||
@Named("search-index")
|
||||
@Prototype
|
||||
internal fun luceneIndex() = Path.of(".lucene")
|
||||
}
|
||||
Reference in New Issue
Block a user