mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-15 08:15:37 +00:00
Added support for 3rd party dependencies in plugins (#434)
This commit is contained in:
@@ -10,7 +10,9 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
// PF4J (shared)
|
||||
api("org.pf4j:pf4j:${rootProject.extra["pf4jVersion"]}")
|
||||
api("org.pf4j:pf4j:${rootProject.extra["pf4jVersion"]}") {
|
||||
exclude(group = "org.slf4j")
|
||||
}
|
||||
|
||||
implementation(kotlin("stdlib"))
|
||||
|
||||
|
||||
+12
-38
@@ -1,5 +1,3 @@
|
||||
val pluginDir: File by rootProject.extra
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
@@ -8,48 +6,24 @@ subprojects {
|
||||
apply(plugin = "org.jetbrains.kotlin.jvm")
|
||||
|
||||
dependencies {
|
||||
implementation(project(":plugin-api"))
|
||||
}
|
||||
|
||||
tasks.register<Jar>("plugin") {
|
||||
archiveBaseName.set("plugin-${project.name}")
|
||||
|
||||
// first taking the classes generated by the jar task
|
||||
into("classes") {
|
||||
with(tasks.named<Jar>("jar").get())
|
||||
}
|
||||
// and then we also need to include any libraries that are needed by the plugin
|
||||
dependsOn(configurations.runtimeClasspath)
|
||||
into("lib") {
|
||||
from({
|
||||
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }
|
||||
})
|
||||
}
|
||||
archiveExtension.set("jar")
|
||||
}
|
||||
|
||||
tasks.register<Copy>("assemblePlugin") {
|
||||
from(project.tasks.named("plugin"))
|
||||
into(pluginDir)
|
||||
compileOnly(project(":plugin-api"))
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
isZip64 = true
|
||||
archiveBaseName.set("plugin-${project.name}")
|
||||
|
||||
manifest {
|
||||
from("./src/main/resources/MANIFEST.MF")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("build") {
|
||||
dependsOn(tasks.named("plugin"))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register<Copy>("assemblePlugins") {
|
||||
dependsOn(subprojects.map { it.tasks.named("assemblePlugin") })
|
||||
}
|
||||
|
||||
tasks {
|
||||
"build" {
|
||||
dependsOn(named("assemblePlugins"))
|
||||
from(configurations.runtimeClasspath.get().map { project.zipTree(it) }) {
|
||||
exclude("META-INF/*.SF")
|
||||
exclude("META-INF/*.DSA")
|
||||
exclude("META-INF/*.RSA")
|
||||
}
|
||||
from(sourceSets["main"].output.classesDirs)
|
||||
from(sourceSets["main"].resources)
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,22 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
ksp("care.better.pf4j:pf4j-kotlin-symbol-processing:2.0.20-1.0.1")
|
||||
|
||||
// IGDB API client
|
||||
implementation("io.github.husnjak:igdb-api-jvm:1.2.0")
|
||||
}
|
||||
|
||||
tasks.register<Copy>("copyDependencyClasses") {
|
||||
dependsOn(tasks.jar)
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
|
||||
from(configurations.runtimeClasspath.get().map { project.zipTree(it) }) {
|
||||
include("**/*.class")
|
||||
}
|
||||
into(layout.buildDirectory.get().asFile.resolve("classes/kotlin/main"))
|
||||
}
|
||||
|
||||
tasks.build {
|
||||
dependsOn("copyDependencyClasses")
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.grimsi.gameyfin.plugins.igdb
|
||||
|
||||
import com.api.igdb.request.IGDBWrapper
|
||||
import com.api.igdb.request.TwitchAuthenticator
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadata
|
||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataFetcher
|
||||
import org.pf4j.Extension
|
||||
@@ -10,13 +12,23 @@ import java.time.Instant
|
||||
class IgdbPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
||||
|
||||
override fun start() {
|
||||
println("IgdbPlugin.start()")
|
||||
authenticate()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
println("IgdbPlugin.stop()")
|
||||
}
|
||||
|
||||
private fun authenticate() {
|
||||
// Kotlin example
|
||||
val token = TwitchAuthenticator.requestTwitchToken("CLIENT_ID", "CLIENT_SECRET")
|
||||
if (token == null) {
|
||||
println("Failed to authenticate with Twitch")
|
||||
return
|
||||
}
|
||||
IGDBWrapper.setCredentials("client_id", token.access_token)
|
||||
}
|
||||
|
||||
@Extension
|
||||
class IgdbMetadataFetcher : GameMetadataFetcher {
|
||||
override fun getConfig(): Map<String, String> {
|
||||
|
||||
Reference in New Issue
Block a user