mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
WIP: Plugin for IGDB
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
<module name="Gameyfin.gameyfin.main" />
|
||||
<option name="SHORTEN_COMMAND_LINE" value="ARGS_FILE" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="de.grimsi.gameyfin.GameyfinApplication" />
|
||||
<option name="VM_PARAMETERS" value="-Dpf4j.mode=development" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="de.grimsi.gameyfin.*" />
|
||||
|
||||
@@ -68,9 +68,6 @@ dependencies {
|
||||
|
||||
// Plugins
|
||||
implementation(project(":plugin-api"))
|
||||
implementation("org.pf4j:pf4j-spring:${rootProject.extra["pf4jSpringVersion"]}") {
|
||||
exclude("org.slf4j")
|
||||
}
|
||||
|
||||
// Development
|
||||
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
||||
@@ -88,6 +85,18 @@ dependencyManagement {
|
||||
}
|
||||
}
|
||||
|
||||
// Task to copy the bundled plugin JARs to the plugins directory
|
||||
val copyPlugins by tasks.registering(Copy::class) {
|
||||
// Directory where plugins will be copied
|
||||
val pluginsDir = layout.buildDirectory.dir("plugins")
|
||||
from(project(":plugins:igdb").tasks.named("jar"))
|
||||
into(pluginsDir)
|
||||
}
|
||||
|
||||
tasks.named("compileKotlin") {
|
||||
dependsOn(copyPlugins)
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
package de.grimsi.gameyfin.core
|
||||
|
||||
import org.pf4j.spring.SpringPluginManager
|
||||
import org.pf4j.DefaultPluginManager
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import java.nio.file.Path
|
||||
|
||||
@Configuration
|
||||
class PluginManagerConfig {
|
||||
private val pluginPath = Path.of("plugins")
|
||||
|
||||
@Bean
|
||||
fun pluginManager() = SpringPluginManager()
|
||||
fun pluginManager() = DefaultPluginManager(pluginPath)
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package de.grimsi.gameyfin.games
|
||||
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataPlugin
|
||||
import org.pf4j.spring.SpringPluginManager
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import org.pf4j.PluginManager
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent
|
||||
import org.springframework.context.event.EventListener
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
import org.springframework.stereotype.Service
|
||||
import java.nio.file.Path
|
||||
@@ -9,11 +12,20 @@ import java.nio.file.Path
|
||||
@Service
|
||||
class GameService(
|
||||
private val gameRepository: GameRepository,
|
||||
private val pluginManager: SpringPluginManager
|
||||
private val pluginManager: PluginManager
|
||||
) {
|
||||
val metadataPlugins: List<GameMetadataPlugin>
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
private val metadataPlugins: List<GameMetadataPlugin>
|
||||
get() = pluginManager.getExtensions(GameMetadataPlugin::class.java)
|
||||
|
||||
@EventListener(ApplicationReadyEvent::class)
|
||||
fun loadedPlugins() {
|
||||
pluginManager.loadPlugins()
|
||||
pluginManager.startPlugins()
|
||||
log.info { "Loaded metadata plugins: ${metadataPlugins.map { it::class.simpleName }}" }
|
||||
}
|
||||
|
||||
fun createOrUpdate(game: Game): Game {
|
||||
return gameRepository.save(game)
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
package de.grimsi.gameyfin.pluginapi.gamemetadata
|
||||
|
||||
interface GameMetadataPlugin {
|
||||
import org.pf4j.ExtensionPoint
|
||||
|
||||
interface GameMetadataPlugin : ExtensionPoint {
|
||||
fun getConfig(): Map<String, String>
|
||||
fun setConfig(config: Map<String, String>)
|
||||
fun fetchMetadata(gameId: String): GameMetadata
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("kotlin-kapt")
|
||||
}
|
||||
|
||||
group = "de.grimsi.gameyfin.plugins"
|
||||
@@ -12,6 +13,12 @@ dependencies {
|
||||
implementation(project(":plugin-api"))
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
manifest {
|
||||
from("./src/main/resources/MANIFEST.MF")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package de.grimsi.gameyfin.plugins.igdb
|
||||
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadata
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataPlugin
|
||||
import org.pf4j.Extension
|
||||
import java.time.Instant
|
||||
|
||||
@Extension
|
||||
class IgdbPlugin : GameMetadataPlugin {
|
||||
override fun getConfig(): Map<String, String> {
|
||||
TODO("Not yet implemented")
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Manifest-Version: 1.0
|
||||
Plugin-Id: igdb
|
||||
Plugin-Class: de.grimsi.gameyfin.plugins.igdb.IgdbPlugin
|
||||
Plugin-Version: 1.0.0
|
||||
Plugin-Provider: grimsi
|
||||
@@ -18,4 +18,3 @@ pluginManagement {
|
||||
include("gameyfin")
|
||||
include("plugin-api")
|
||||
include("plugins:igdb")
|
||||
findProject(":plugins:igdb")?.name = "igdb"
|
||||
|
||||
Reference in New Issue
Block a user