Split kotlin modules (#316)
This commit is contained in:
parent
762de3dfba
commit
d2a47ad941
17 changed files with 127 additions and 78 deletions
|
|
@ -1,5 +1,6 @@
|
|||
plugins {
|
||||
`kotlin-dsl`
|
||||
id("org.jlleitschuh.gradle.ktlint")
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
|
@ -12,4 +13,7 @@ dependencies {
|
|||
implementation(libs.gradleTestLogger)
|
||||
implementation(libs.gradleErrorprone)
|
||||
implementation(libs.licenser)
|
||||
implementation(libs.gradleKotlinJvm)
|
||||
implementation(libs.gradleDokka)
|
||||
implementation(libs.gradleKtlint)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ tasks {
|
|||
options.errorprone {
|
||||
/* These are just annoying */
|
||||
disable(
|
||||
"JdkObsolete",
|
||||
"FutureReturnValueIgnored",
|
||||
"ImmutableEnumChecker",
|
||||
"StringSplitter",
|
||||
"EqualsGetClass",
|
||||
"CatchAndPrintStackTrace",
|
||||
"InlineMeSuggester",
|
||||
"JdkObsolete",
|
||||
"FutureReturnValueIgnored",
|
||||
"ImmutableEnumChecker",
|
||||
"StringSplitter",
|
||||
"EqualsGetClass",
|
||||
"CatchAndPrintStackTrace",
|
||||
"InlineMeSuggester",
|
||||
)
|
||||
}
|
||||
options.compilerArgs.addAll(listOf("-Xlint:-processing", "-Werror"))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id("cloud.base-conventions")
|
||||
kotlin("jvm")
|
||||
id("org.jetbrains.dokka")
|
||||
id("org.jlleitschuh.gradle.ktlint")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain {
|
||||
(this as JavaToolchainSpec).apply {
|
||||
languageVersion.set(JavaLanguageVersion.of(8))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val compileAndTest: Configuration by configurations.creating
|
||||
listOf(configurations.compileOnly, configurations.testImplementation).forEach { config ->
|
||||
config {
|
||||
extendsFrom(compileAndTest)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileAndTest(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<DokkaTask> {
|
||||
dokkaSourceSets.named("main") {
|
||||
includes.from(layout.projectDirectory.file("src/main/descriptions.md"))
|
||||
/*externalDocumentationLink { // todo: fix KDoc linking to JavaDoc
|
||||
url.set(URL("https://javadoc.commandframework.cloud/"))
|
||||
packageListUrl.set(URL("https://javadoc.commandframework.cloud/allpackages-index.html"))
|
||||
}*/
|
||||
}
|
||||
}
|
||||
javadocJar {
|
||||
from(dokkaHtml)
|
||||
}
|
||||
withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
explicitApi()
|
||||
}
|
||||
|
|
@ -4,11 +4,11 @@ import org.gradle.api.provider.Provider
|
|||
// set by GitHub Actions
|
||||
val Project.ci: Provider<Boolean>
|
||||
get() = providers.environmentVariable("CI")
|
||||
.forUseAtConfigurationTime()
|
||||
.map { it.toBoolean() }
|
||||
.orElse(false)
|
||||
.forUseAtConfigurationTime()
|
||||
.map { it.toBoolean() }
|
||||
.orElse(false)
|
||||
|
||||
val Project.compileExamples: Boolean
|
||||
get() = providers.gradleProperty("compile-examples")
|
||||
.forUseAtConfigurationTime()
|
||||
.isPresent
|
||||
.forUseAtConfigurationTime()
|
||||
.isPresent
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.5.30"
|
||||
id("org.jetbrains.dokka") version "1.5.30"
|
||||
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
|
||||
}
|
||||
|
||||
val compileAndTest: Configuration by configurations.creating
|
||||
|
||||
configurations {
|
||||
all {
|
||||
dependencies.removeIf { it.group == "org.jetbrains.kotlin" }
|
||||
}
|
||||
|
||||
compileOnly {
|
||||
extendsFrom(compileAndTest)
|
||||
}
|
||||
testImplementation {
|
||||
extendsFrom(compileAndTest)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":cloud-core"))
|
||||
|
||||
compileAndTest(project(":cloud-annotations"))
|
||||
compileAndTest(kotlin("stdlib-jdk8"))
|
||||
compileAndTest(kotlin("reflect"))
|
||||
compileAndTest("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
|
||||
compileAndTest("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.5.2")
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<DokkaTask>().configureEach {
|
||||
dokkaSourceSets.getByName("main") {
|
||||
includes.from(layout.projectDirectory.file("src/main/descriptions.md").toString())
|
||||
/*
|
||||
externalDocumentationLink {
|
||||
url.set(URL("https://javadoc.commandframework.cloud/")) //todo fix KDoc linking to JavaDoc
|
||||
packageListUrl.set(URL("https://javadoc.commandframework.cloud/allpackages-index.html"))
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
javadocJar {
|
||||
from(dokkaHtml)
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
explicitApi()
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
plugins {
|
||||
id("cloud.kotlin-conventions")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":cloud-core"))
|
||||
api(project(":cloud-annotations"))
|
||||
api(kotlin("reflect"))
|
||||
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
|
||||
api("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.5.2")
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Module cloud-kotlin-coroutines-annotations
|
||||
|
||||
cloud-annotations extensions for Kotlin coroutine integration.
|
||||
|
||||
# Package cloud.commandframework.kotlin.coroutines.annotations
|
||||
|
||||
cloud-kotlin-coroutines-annotations classes and functions.
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
package cloud.commandframework.kotlin.coroutines
|
||||
package cloud.commandframework.kotlin.coroutines.annotations
|
||||
|
||||
import cloud.commandframework.annotations.AnnotationParser
|
||||
import cloud.commandframework.annotations.MethodCommandExecutionHandler
|
||||
|
|
@ -43,12 +43,15 @@ import kotlin.reflect.jvm.kotlinFunction
|
|||
/**
|
||||
* Adds coroutine support to the [AnnotationParser].
|
||||
*
|
||||
* @param scope coroutine scope
|
||||
* @param context coroutine context
|
||||
* @return annotation parser
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public fun <C> AnnotationParser<C>.installCoroutineSupport(
|
||||
scope: CoroutineScope = GlobalScope,
|
||||
context: CoroutineContext = EmptyCoroutineContext
|
||||
) {
|
||||
): AnnotationParser<C> {
|
||||
if (manager().commandExecutionCoordinator() is CommandExecutionCoordinator.SimpleCoordinator) {
|
||||
RuntimeException(
|
||||
"""You are highly advised to not use the simple command execution coordinator together
|
||||
|
|
@ -61,6 +64,8 @@ public fun <C> AnnotationParser<C>.installCoroutineSupport(
|
|||
registerCommandExecutionMethodFactory(predicate) {
|
||||
KotlinMethodCommandExecutionHandler(scope, context, it)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
private class KotlinMethodCommandExecutionHandler<C>(
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
package cloud.commandframework.kotlin.coroutines
|
||||
package cloud.commandframework.kotlin.coroutines.annotations
|
||||
|
||||
import cloud.commandframework.CommandManager
|
||||
import cloud.commandframework.annotations.AnnotationParser
|
||||
|
|
@ -65,7 +65,7 @@ class KotlinAnnotatedMethodsTest {
|
|||
AnnotationParser(commandManager, TestCommandSender::class.java) {
|
||||
SimpleCommandMeta.empty()
|
||||
}
|
||||
.also { it.installCoroutineSupport() }
|
||||
.installCoroutineSupport()
|
||||
.parse(CommandMethods())
|
||||
|
||||
commandManager.executeCommand(TestCommandSender(), "test").await()
|
||||
|
|
@ -76,7 +76,7 @@ class KotlinAnnotatedMethodsTest {
|
|||
AnnotationParser(commandManager, TestCommandSender::class.java) {
|
||||
SimpleCommandMeta.empty()
|
||||
}
|
||||
.also { it.installCoroutineSupport() }
|
||||
.installCoroutineSupport()
|
||||
.parse(CommandMethods())
|
||||
|
||||
assertThrows<CommandExecutionException> {
|
||||
7
cloud-kotlin/cloud-kotlin-extensions/build.gradle.kts
Normal file
7
cloud-kotlin/cloud-kotlin-extensions/build.gradle.kts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
plugins {
|
||||
id("cloud.kotlin-conventions")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":cloud-core"))
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
kotlin.stdlib.default.dependency=false
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ metadata:
|
|||
plugins:
|
||||
com.github.johnrengelman.shadow: 7.1.0
|
||||
com.github.ben-manes.versions: 0.36.0
|
||||
org.jlleitschuh.gradle.ktlint: &ktlint 10.2.0
|
||||
|
||||
versions:
|
||||
kotlin: &kotlin 1.5.31
|
||||
dokka: *kotlin
|
||||
checkerQual: 3.14.0
|
||||
|
||||
# build-logic
|
||||
|
|
@ -15,6 +18,7 @@ versions:
|
|||
gradleTestLogger: 3.0.0
|
||||
gradleErrorprone: 2.0.2
|
||||
licenser: 0.6.1
|
||||
ktlint: *ktlint
|
||||
|
||||
dependencies:
|
||||
checkerQual:
|
||||
|
|
@ -43,5 +47,17 @@ dependencies:
|
|||
group: net.ltgt.gradle
|
||||
name: gradle-errorprone-plugin
|
||||
version: { ref: gradleErrorprone }
|
||||
gradleKotlinJvm:
|
||||
group: org.jetbrains.kotlin.jvm
|
||||
name: org.jetbrains.kotlin.jvm.gradle.plugin
|
||||
version: { ref: kotlin }
|
||||
gradleDokka:
|
||||
group: org.jetbrains.dokka
|
||||
name: dokka-gradle-plugin
|
||||
version: { ref: dokka }
|
||||
gradleKtlint:
|
||||
group: org.jlleitschuh.gradle
|
||||
name: ktlint-gradle
|
||||
version: { ref: ktlint }
|
||||
|
||||
bundles:
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ include(":cloud-services")
|
|||
include(":cloud-tasks")
|
||||
include(":cloud-annotations")
|
||||
|
||||
// Extension Modules
|
||||
include(":cloud-kotlin-extensions")
|
||||
// Kotlin Extensions
|
||||
setupKotlinModule("cloud-kotlin-extensions")
|
||||
setupKotlinModule("cloud-kotlin-coroutines-annotations")
|
||||
|
||||
// Discord Modules
|
||||
setupDiscordModule("cloud-javacord")
|
||||
|
|
@ -59,6 +60,9 @@ fun setupDiscordModule(name: String) =
|
|||
fun setupMinecraftModule(name: String) =
|
||||
setupSubproject(name, file("cloud-minecraft/$name"))
|
||||
|
||||
fun setupKotlinModule(name: String) =
|
||||
setupSubproject(name, file("cloud-kotlin/$name"))
|
||||
|
||||
fun setupExampleModule(name: String) =
|
||||
setupSubproject(name, file("examples/$name"))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue