From 2bf27537af743552ce262da929e3e51522222c92 Mon Sep 17 00:00:00 2001 From: dzikoysk Date: Fri, 22 Nov 2024 18:29:50 +0100 Subject: [PATCH] GH-2275 Fix plugin loader after recent changes in file api (Fix #2275) --- reposilite-backend/build.gradle.kts | 11 +++++++---- .../main/kotlin/com/reposilite/plugin/Extensions.kt | 4 +++- .../main/kotlin/com/reposilite/plugin/PluginLoader.kt | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/reposilite-backend/build.gradle.kts b/reposilite-backend/build.gradle.kts index 81df72923..8fc680a90 100644 --- a/reposilite-backend/build.gradle.kts +++ b/reposilite-backend/build.gradle.kts @@ -115,12 +115,12 @@ dependencies { val httpClient = "1.45.1" implementation("com.google.http-client:google-http-client:$httpClient") { exclude(group = "commons-codec", module = "commons-codec") + exclude(group = "com.google.guava", module = "guava") } + api("commons-codec:commons-codec:1.17.1") + api("com.google.guava:guava:33.3.1-android") testImplementation("com.google.http-client:google-http-client-jackson2:$httpClient") - val commonsCoded = "1.17.1" - api("commons-codec:commons-codec:$commonsCoded") - val jansi = "2.4.1" implementation("org.fusesource.jansi:jansi:$jansi") @@ -135,12 +135,15 @@ dependencies { implementation("org.tinylog:tinylog-impl:$tinylog") val testcontainers = "1.20.4" - testImplementation("org.testcontainers:postgresql:$testcontainers") testImplementation("org.testcontainers:mariadb:$testcontainers") testImplementation("org.testcontainers:testcontainers:$testcontainers") testImplementation("org.testcontainers:junit-jupiter:$testcontainers") testImplementation("org.testcontainers:localstack:$testcontainers") testImplementation("org.testcontainers:mysql:$testcontainers") + testImplementation("org.testcontainers:postgresql:$testcontainers") { + exclude(group = "org.apache.commons", module = "commons-compress") + } + testImplementation("org.apache.commons:commons-compress:1.27.1") val ldap = "7.0.1" testImplementation("com.unboundid:unboundid-ldapsdk:$ldap") diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/plugin/Extensions.kt b/reposilite-backend/src/main/kotlin/com/reposilite/plugin/Extensions.kt index e556040ce..4f785713c 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/plugin/Extensions.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/plugin/Extensions.kt @@ -72,7 +72,9 @@ class Extensions(private val journalist: Journalist) : Journalist { @Suppress("UNCHECKED_CAST") fun facade(type: Class): F = - getFacades().find { type.isInstance(it) }!! as F + getFacades() + .find { type.isInstance(it) } as? F + ?: throw IllegalStateException("Facade ${type.name} not found") fun getFacades(): Collection = facades.toList() diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/plugin/PluginLoader.kt b/reposilite-backend/src/main/kotlin/com/reposilite/plugin/PluginLoader.kt index c049f9755..11fbc4b06 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/plugin/PluginLoader.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/plugin/PluginLoader.kt @@ -71,7 +71,8 @@ class PluginLoader( extensions.logger.debug("Plugins directory: ${pluginsDirectory.absolute()}") pluginsDirectory.useDirectoryEntries { pluginDirectoryStream -> - pluginDirectoryStream.filter { it.extension == ".jar" } + pluginDirectoryStream + .filter { it.extension == "jar" } .filter { isValidJarFile(it.toFile()) } .map { it.toUri().toURL() } .toList()