mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-17 00:30:04 +00:00
Added support for 3rd party dependencies in plugins (#434)
This commit is contained in:
@@ -10,7 +10,9 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// PF4J (shared)
|
// PF4J (shared)
|
||||||
api("org.pf4j:pf4j:${rootProject.extra["pf4jVersion"]}")
|
api("org.pf4j:pf4j:${rootProject.extra["pf4jVersion"]}") {
|
||||||
|
exclude(group = "org.slf4j")
|
||||||
|
}
|
||||||
|
|
||||||
implementation(kotlin("stdlib"))
|
implementation(kotlin("stdlib"))
|
||||||
|
|
||||||
|
|||||||
+12
-38
@@ -1,5 +1,3 @@
|
|||||||
val pluginDir: File by rootProject.extra
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
}
|
}
|
||||||
@@ -8,48 +6,24 @@ subprojects {
|
|||||||
apply(plugin = "org.jetbrains.kotlin.jvm")
|
apply(plugin = "org.jetbrains.kotlin.jvm")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":plugin-api"))
|
compileOnly(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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.jar {
|
tasks.jar {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
isZip64 = true
|
||||||
|
archiveBaseName.set("plugin-${project.name}")
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
from("./src/main/resources/MANIFEST.MF")
|
from("./src/main/resources/MANIFEST.MF")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named("build") {
|
from(configurations.runtimeClasspath.get().map { project.zipTree(it) }) {
|
||||||
dependsOn(tasks.named("plugin"))
|
exclude("META-INF/*.SF")
|
||||||
}
|
exclude("META-INF/*.DSA")
|
||||||
}
|
exclude("META-INF/*.RSA")
|
||||||
|
}
|
||||||
tasks.register<Copy>("assemblePlugins") {
|
from(sourceSets["main"].output.classesDirs)
|
||||||
dependsOn(subprojects.map { it.tasks.named("assemblePlugin") })
|
from(sourceSets["main"].resources)
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
"build" {
|
|
||||||
dependsOn(named("assemblePlugins"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,22 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
ksp("care.better.pf4j:pf4j-kotlin-symbol-processing:2.0.20-1.0.1")
|
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
|
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.GameMetadata
|
||||||
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataFetcher
|
import de.grimsi.gameyfin.pluginapi.gamemetadata.GameMetadataFetcher
|
||||||
import org.pf4j.Extension
|
import org.pf4j.Extension
|
||||||
@@ -10,13 +12,23 @@ import java.time.Instant
|
|||||||
class IgdbPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
class IgdbPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
|
||||||
|
|
||||||
override fun start() {
|
override fun start() {
|
||||||
println("IgdbPlugin.start()")
|
authenticate()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun stop() {
|
override fun stop() {
|
||||||
println("IgdbPlugin.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
|
@Extension
|
||||||
class IgdbMetadataFetcher : GameMetadataFetcher {
|
class IgdbMetadataFetcher : GameMetadataFetcher {
|
||||||
override fun getConfig(): Map<String, String> {
|
override fun getConfig(): Map<String, String> {
|
||||||
|
|||||||
Reference in New Issue
Block a user