Skip to content

Commit

Permalink
merge lucene spi
Browse files Browse the repository at this point in the history
  • Loading branch information
storytellerF committed Jan 7, 2025
1 parent 1bbb50a commit 851be67
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 25 deletions.
44 changes: 41 additions & 3 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
implementation(libs.lucene.analysis.common)
implementation(libs.simplemagic)

runtimeOnly(libs.lucene.backward.codecs)
implementation(libs.lucene.backward.codecs)
testImplementation(libs.elasticsearch)
}

Expand All @@ -49,15 +49,16 @@ sourceSets {
resources {
srcDirs(
layout.buildDirectory.dir("copied/resources"),
layout.buildDirectory.dir("copied-ca/resources")
layout.buildDirectory.dir("copied-ca/resources"),
layout.buildDirectory.dir("merged-services/resources")
)
}
}
}

val flavor = project.findProperty("buildkonfig.flavor")

val copyTask = tasks.register("CopyEnv", Copy::class) {
val copyTask = tasks.register("copyEnv", Copy::class) {
group = "copy"
from("../${flavor}.env")
enabled = File(rootDir, "${flavor}.env").exists()
Expand All @@ -67,5 +68,42 @@ val copyTask = tasks.register("CopyEnv", Copy::class) {
}
}

val mergeServiceFiles = tasks.register("mergeServiceFiles") {
group = "build"
description = "Merge SPI files from dependencies into a single output"

val outputDir = layout.buildDirectory.dir("merged-services")
doLast {

// Iterate through each jar/zip in runtimeClasspath
val output = outputDir.get().asFile
output.mkdirs()
configurations.runtimeClasspath.get().flatMap { file ->
if (file.isFile && file.name.endsWith(".jar")) {
zipTree(file).filter {
it.name.startsWith("org.apache.lucene.codecs")
}.map { serviceFile ->
val serviceName = serviceFile.name
val serviceContent =
serviceFile.readText().lines().filter { it.startsWith("org.apache.lucene") }
serviceName to serviceContent
}
} else {
emptyList()
}
}.groupBy {
it.first
}.forEach {
val outputFile = output.resolve("META-INF/services/${it.key}")
outputFile.parentFile.mkdirs()

outputFile.writeText(it.value.flatMap {
it.second
}.joinToString("\n"))
}
}
}

tasks.processResources.dependsOn(copyTask)
tasks.processResources.dependsOn(mergeServiceFiles)

This file was deleted.

4 changes: 2 additions & 2 deletions cli/src/main/kotlin/com/storyteller_f/cli/CleanCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class CleanCommand : Subcommand("clean", "clean all data") {
Napier.i {
"database tables removed."
}
backend.mediaService.clean("amedia")
backend.mediaService.clean("amedia").getOrThrow()
runBlocking {
backend.topicSearchService.clean()
backend.topicSearchService.clean().getOrThrow()
}
Napier.i {
"clean done."
Expand Down
3 changes: 0 additions & 3 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ android {
buildTypes {
getByName("debug") {
applicationIdSuffix = ".debug"
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
getByName("release") {
isMinifyEnabled = true
Expand Down

Large diffs are not rendered by default.

0 comments on commit 851be67

Please sign in to comment.