Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/root' into root
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Oct 5, 2023
2 parents cc70462 + ab1840c commit cb27d3e
Show file tree
Hide file tree
Showing 38 changed files with 2,287 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules/plugins/kord-extensions.plugins.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules/plugins/kord-extensions.plugins.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions annotation-processor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ dokkaModule {
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of("11"))
}
sourceCompatibility = JavaVersion.VERSION_13
targetCompatibility = JavaVersion.VERSION_13
}
10 changes: 3 additions & 7 deletions buildSrc/src/main/kotlin/kordex-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ tasks {

kotlin {
explicitApi()

jvmToolchain {
languageVersion.set(JavaLanguageVersion.of("11"))
}
}

jar {
Expand All @@ -43,8 +39,8 @@ tasks {
rootProject.file("LICENSE").copyTo(rootProject.file("build/LICENSE-kordex"), true)

tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "11"
targetCompatibility = "11"
sourceCompatibility = "13"
targetCompatibility = "13"
}

withType<KotlinCompile>().configureEach {
Expand All @@ -53,7 +49,7 @@ tasks {
}

kotlinOptions {
jvmTarget = "11"
jvmTarget = "13"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kotlin.incremental = true

ksp.incremental = false

projectVersion = 1.5.9-SNAPSHOT
projectVersion = 1.5.10-SNAPSHOT

#dokka will run out of memory with the default meta space
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1024m
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ logback-groovy = "1.14.5"
logging = "5.1.0"
mongodb = "4.10.2"
pf4j = "3.10.0"
semver = "1.4.2"
sentry = "6.29.0"
slf4j = "2.0.9"
time4j-base = "5.9.3"
Expand Down Expand Up @@ -53,12 +54,14 @@ ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref =
ktor-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
kx-coro = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kx-coro"}
kx-ser = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kx-ser" }
kx-ser-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kx-ser" }
linkie = { module = "me.shedaniel:linkie-core", version.ref = "linkie" }
logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
logback-groovy = { module = "io.github.virtualdogbert:logback-groovy-config", version.ref = "logback-groovy" }
kotlin-logging = { module = "io.github.oshai:kotlin-logging", version.ref = "logging" }
mongodb = { module = "org.mongodb:mongodb-driver-kotlin-coroutine", version.ref = "mongodb" }
pf4j = { module = "org.pf4j:pf4j", version.ref = "pf4j" }
semver = { module = "io.github.z4kn4fein:semver", version.ref = "semver" }
sentry = { module = "io.sentry:sentry", version.ref = "sentry" }
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
time4j-base = { module = "net.time4j:time4j-base", version.ref = "time4j-base" }
Expand Down
39 changes: 39 additions & 0 deletions plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
buildscript {
repositories {
maven {
name = "Sonatype Snapshots"
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
}
}

plugins {
`kordex-module`
`published-module`
`dokka-module`
`tested-module`
}

metadata {
name = "KordEx: Plugins"
description = "Self-contained API implementing a simple plugin system"
}

group = "com.kotlindiscord.kord.extensions"

dependencies {
detektPlugins(libs.detekt)
detektPlugins(libs.detekt.libraries)

implementation(libs.bundles.logging)
implementation(libs.kotlin.stdlib)
implementation(libs.kx.ser)
implementation(libs.kx.ser.json) // No ktor dep
implementation(libs.semver)

testImplementation(libs.groovy) // For logback config
testImplementation(libs.jansi)
testImplementation(libs.junit)
testImplementation(libs.logback)
testImplementation(libs.logback.groovy)
}
66 changes: 66 additions & 0 deletions plugins/plugin-load-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
buildscript {
repositories {
maven {
name = "Sonatype Snapshots"
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
}
}

plugins {
`kordex-module`
`dokka-module`
`tested-module`
}

group = "com.kotlindiscord.kord.extensions"

dependencies {
detektPlugins(libs.detekt)
detektPlugins(libs.detekt.libraries)

testImplementation(libs.bundles.logging)
testImplementation(libs.kotlin.stdlib)
testImplementation(libs.kx.ser)
testImplementation(libs.kx.ser.json) // No ktor dep
testImplementation(libs.semver)

testImplementation(libs.groovy) // For logback config
testImplementation(libs.jansi)
testImplementation(libs.junit)
testImplementation(libs.logback)
testImplementation(libs.logback.groovy)

// Make sure these get built before the test module
testImplementation(project(":plugins:test-plugin-core"))
testImplementation(project(":plugins:test-plugin-1"))
testImplementation(project(":plugins:test-plugin-2"))
}

val copyTestJars = tasks.register<Copy>("copyTestJars") {
val matchRegex = Regex("^.*(\\d|-SNAPSHOT)\\.jar\$")

val root = rootProject.rootDir
val pluginDir = root.resolve("plugins/plugin-load-test/tmp/plugins")

val testOneJar = root.resolve("plugins/test-plugin-1/build/libs")
.listFiles()
?.first {
it.name.matches(matchRegex)
}

val testTwoJar = root.resolve("plugins/test-plugin-2/build/libs")
.listFiles()
?.first {
it.name.matches(matchRegex)
}

pluginDir.mkdirs()

from(testOneJar, testTwoJar)
into(pluginDir)
}

tasks.test {
dependsOn(copyTestJars)
}
28 changes: 28 additions & 0 deletions plugins/plugin-load-test/src/test/kotlin/PluginJarTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import com.kotlindiscord.kord.extensions.plugins.PluginManager
import com.kotlindiscord.kord.extensions.plugins.test.core.TestPlugin
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PluginJarTests {
private val pluginManager = PluginManager<TestPlugin>(
baseTypeReference = "TestPlugin",
pluginDirectory = "tmp/plugins"
)

@Test
fun `Standard plugin load`() {
pluginManager.loadAllPlugins()

Assertions.assertEquals(
"test-one",
pluginManager.loadPlugin("test-one")?.get()?.manifest?.id
)

Assertions.assertEquals(
"test-two",
pluginManager.loadPlugin("test-two")?.get()?.manifest?.id
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#

junit.jupiter.execution.parallel.enabled=true
40 changes: 40 additions & 0 deletions plugins/plugin-load-test/src/test/resources/logback.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import ch.qos.logback.classic.encoder.PatternLayoutEncoder
import ch.qos.logback.core.joran.spi.ConsoleTarget
import ch.qos.logback.core.ConsoleAppender
import ch.qos.logback.core.FileAppender

def environment = System.getenv("ENVIRONMENT") ?: "dev"
def defaultLevel = TRACE

if (environment == "spam") {
logger("dev.kord.rest.DefaultGateway", TRACE)
} else {
// Silence warning about missing native PRNG
logger("io.ktor.util.random", ERROR)
}

appender("CONSOLE", ConsoleAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%boldGreen(%d{yyyy-MM-dd}) %boldYellow(%d{HH:mm:ss}) %gray(|) %highlight(%5level) %gray(|) %boldMagenta(%40.40logger{40}) %gray(|) %msg%n"

withJansi = true
}

target = ConsoleTarget.SystemOut
}

appender("FILE", FileAppender) {
file = "output.log"

encoder(PatternLayoutEncoder) {
pattern = "%d{yyyy-MM-dd HH:mm:ss:SSS Z} | %5level | %40.40logger{40} | %msg%n"
}
}

root(defaultLevel, ["CONSOLE", "FILE"])
Loading

0 comments on commit cb27d3e

Please sign in to comment.