-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.5.10-SNAPSHOT: Java 13, plugin system
- Loading branch information
Showing
38 changed files
with
2,287 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
28
plugins/plugin-load-test/src/test/kotlin/PluginJarTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
plugins/plugin-load-test/src/test/resources/junit-platform.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
40
plugins/plugin-load-test/src/test/resources/logback.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]) |
Oops, something went wrong.