aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-17 14:30:10 +0200
committerRobert Jaros <rjaros@finn.pl>2019-10-17 14:31:12 +0200
commitcb01930ae5174070aad9d1d7297e91b897340230 (patch)
tree320e6f7dece8161eab6a983199d2e88857f60d20 /kvision-modules
parent1830797fbe4a7fda6958b4a13d46acf121a5288d (diff)
downloadkvision-cb01930ae5174070aad9d1d7297e91b897340230.tar.gz
kvision-cb01930ae5174070aad9d1d7297e91b897340230.tar.bz2
kvision-cb01930ae5174070aad9d1d7297e91b897340230.zip
Kotlin compiler plugin and gradle plugin
Diffstat (limited to 'kvision-modules')
-rw-r--r--kvision-modules/kvision-common-annotations/build.gradle7
-rw-r--r--kvision-modules/kvision-common-annotations/src/main/kotlin/pl/treksoft/kvision/annotations/Annotations.kt26
-rw-r--r--kvision-modules/kvision-common-types/build.gradle3
-rw-r--r--kvision-modules/kvision-compiler-plugin/build.gradle16
-rw-r--r--kvision-modules/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/CommonComponentRegistrar.kt47
-rw-r--r--kvision-modules/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt209
-rw-r--r--kvision-modules/kvision-gradle-plugin/build.gradle20
-rw-r--r--kvision-modules/kvision-gradle-plugin/src/main/kotlin/pl/treksoft/kvision/gradle/KVisionGradlePlugin.kt30
-rw-r--r--kvision-modules/kvision-gradle-plugin/src/main/kotlin/pl/treksoft/kvision/gradle/KVisionGradleSubplugin.kt57
-rw-r--r--kvision-modules/kvision-remote/build.gradle1
-rw-r--r--kvision-modules/kvision-server-jooby/build.gradle2
-rw-r--r--kvision-modules/kvision-server-ktor/build.gradle2
-rw-r--r--kvision-modules/kvision-server-spring-boot/build.gradle2
13 files changed, 419 insertions, 3 deletions
diff --git a/kvision-modules/kvision-common-annotations/build.gradle b/kvision-modules/kvision-common-annotations/build.gradle
new file mode 100644
index 00000000..f62cd411
--- /dev/null
+++ b/kvision-modules/kvision-common-annotations/build.gradle
@@ -0,0 +1,7 @@
+apply plugin: 'kotlin-platform-common'
+apply plugin: 'kotlinx-serialization'
+
+dependencies {
+ compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion"
+ compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion"
+}
diff --git a/kvision-modules/kvision-common-annotations/src/main/kotlin/pl/treksoft/kvision/annotations/Annotations.kt b/kvision-modules/kvision-common-annotations/src/main/kotlin/pl/treksoft/kvision/annotations/Annotations.kt
new file mode 100644
index 00000000..02026f56
--- /dev/null
+++ b/kvision-modules/kvision-common-annotations/src/main/kotlin/pl/treksoft/kvision/annotations/Annotations.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision.annotations
+
+@Target(AnnotationTarget.CLASS)
+annotation class KVService()
+
diff --git a/kvision-modules/kvision-common-types/build.gradle b/kvision-modules/kvision-common-types/build.gradle
index af3703e6..f62cd411 100644
--- a/kvision-modules/kvision-common-types/build.gradle
+++ b/kvision-modules/kvision-common-types/build.gradle
@@ -4,7 +4,4 @@ apply plugin: 'kotlinx-serialization'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion"
- compile "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutinesVersion"
- testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion"
- testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion"
}
diff --git a/kvision-modules/kvision-compiler-plugin/build.gradle b/kvision-modules/kvision-compiler-plugin/build.gradle
new file mode 100644
index 00000000..3b00300c
--- /dev/null
+++ b/kvision-modules/kvision-compiler-plugin/build.gradle
@@ -0,0 +1,16 @@
+apply plugin: 'kotlin-platform-jvm'
+apply plugin: "kotlin-kapt"
+apply plugin: "maven"
+
+dependencies {
+ compile "de.jensklingenberg:mpapt-runtime:$mpaptRuntimeVersion"
+ expectedBy project(":kvision-modules:kvision-common-annotations")
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
+ compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable"
+ compileOnly "com.google.auto.service:auto-service:$autoServiceVersion"
+ kapt "com.google.auto.service:auto-service:$autoServiceVersion"
+}
+
+kapt {
+ includeCompileClasspath = false
+}
diff --git a/kvision-modules/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/CommonComponentRegistrar.kt b/kvision-modules/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/CommonComponentRegistrar.kt
new file mode 100644
index 00000000..c71dbce8
--- /dev/null
+++ b/kvision-modules/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/CommonComponentRegistrar.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision.plugin
+
+import com.google.auto.service.AutoService
+import de.jensklingenberg.mpapt.common.MpAptProject
+import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
+import org.jetbrains.kotlin.com.intellij.mock.MockProject
+import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
+import org.jetbrains.kotlin.config.CompilerConfiguration
+import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
+import org.jetbrains.kotlin.js.translate.extensions.JsSyntheticTranslateExtension
+
+@AutoService(ComponentRegistrar::class)
+open class CommonComponentRegistrar : ComponentRegistrar {
+
+ override fun registerProjectComponents(
+ project: MockProject,
+ configuration: CompilerConfiguration
+ ) {
+ val processor = KVProcessor()
+ val mpapt = MpAptProject(processor, configuration)
+ StorageComponentContainerContributor.registerExtension(project, mpapt)
+ ClassBuilderInterceptorExtension.registerExtension(project, mpapt)
+ JsSyntheticTranslateExtension.registerExtension(project, mpapt)
+
+ }
+}
diff --git a/kvision-modules/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt b/kvision-modules/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt
new file mode 100644
index 00000000..1b49a373
--- /dev/null
+++ b/kvision-modules/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision.plugin
+
+import de.jensklingenberg.mpapt.common.guessingBuildFolder
+import de.jensklingenberg.mpapt.common.methods
+import de.jensklingenberg.mpapt.model.AbstractProcessor
+import de.jensklingenberg.mpapt.model.Element
+import de.jensklingenberg.mpapt.model.RoundEnvironment
+import de.jensklingenberg.mpapt.utils.KotlinPlatformValues
+import org.jetbrains.kotlin.backend.common.descriptors.allParameters
+import org.jetbrains.kotlin.backend.common.descriptors.isSuspend
+import org.jetbrains.kotlin.cli.common.config.kotlinSourceRoots
+import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
+import org.jetbrains.kotlin.descriptors.ParameterDescriptor
+import org.jetbrains.kotlin.js.descriptorUtils.getJetTypeFqName
+import org.jetbrains.kotlin.platform.TargetPlatform
+import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
+import org.jetbrains.kotlin.types.KotlinType
+import pl.treksoft.kvision.annotations.KVService
+import java.io.File
+
+class KVProcessor : AbstractProcessor() {
+
+ override fun isTargetPlatformSupported(platform: TargetPlatform): Boolean {
+ val targetName = platform.first().platformName
+ return when (targetName) {
+ KotlinPlatformValues.JS -> false
+ KotlinPlatformValues.JVM -> true
+ KotlinPlatformValues.NATIVE -> false
+ else -> {
+ log(targetName)
+ false
+ }
+ }
+ }
+
+ override fun process(roundEnvironment: RoundEnvironment) {
+ val isCommon = this.configuration.kotlinSourceRoots.find { it.isCommon } != null
+ if (isCommon) {
+ roundEnvironment.getElementsAnnotatedWith(KVService::class.java.name).forEach {
+ if (it is Element.ClassElement && it.classDescriptor.name.asString().startsWith("I")
+ && it.classDescriptor.name.asString().endsWith("Service")
+ ) {
+ val cl = it.classDescriptor
+ val genRootDir = File(cl.guessingBuildFolder(), "generated-src").apply {
+ mkdirs()
+ }
+ val packageName = cl.containingDeclaration.fqNameSafe.asString()
+ val iName = cl.name.asString()
+ val baseName = iName.drop(1)
+ val commonCode = StringBuilder().apply {
+ appendln("//")
+ appendln("// GENERATED by KVision")
+ appendln("//")
+ appendln("package $packageName")
+ appendln()
+ appendln("import kotlinx.coroutines.CoroutineStart")
+ appendln("import kotlinx.coroutines.GlobalScope")
+ appendln("import kotlinx.coroutines.launch")
+ appendln("import pl.treksoft.kvision.remote.KVServiceManager")
+ appendln()
+ appendln("expect class $baseName : $iName")
+ appendln()
+ appendln("object ${baseName}Manager : KVServiceManager<$baseName>($baseName::class) {")
+ appendln(" init {")
+ appendln(" GlobalScope.launch(start = CoroutineStart.UNDISPATCHED) {")
+ cl.methods().forEach {
+ appendln(" bind($iName::${it.name})")
+ }
+ appendln(" }")
+ appendln(" }")
+ appendln("}")
+ }.toString()
+ val commonDestinationDir = File(
+ genRootDir,
+ "common" + File.separator + packageName.replace('.', File.separatorChar)
+ ).apply {
+ mkdirs()
+ }
+ val commonFile = File(commonDestinationDir, "${baseName}Manager.kt")
+ if (commonFile.exists()) {
+ val content = commonFile.readText()
+ if (content != commonCode) {
+ commonFile.writeText(commonCode)
+ }
+ } else {
+ commonFile.writeText(commonCode)
+ }
+ val frontendCode = StringBuilder().apply {
+ appendln("//")
+ appendln("// GENERATED by KVision")
+ appendln("//")
+ appendln("package $packageName")
+ appendln()
+ appendln("import pl.treksoft.kvision.remote.KVRemoteAgent")
+ getTypes(cl.methods()).sorted().forEach {
+ appendln("import $it")
+ }
+ appendln()
+ appendln("actual class $baseName : $iName, KVRemoteAgent<$baseName>(${baseName}Manager) {")
+ cl.methods().forEach {
+ val name = it.name
+ val params = it.allParameters.drop(1)
+ val wsMethod =
+ if (params.size == 2)
+ params.first().type.toString().startsWith("ReceiveChannel")
+ else false
+ if (it.isSuspend) {
+ if (!wsMethod) {
+ if (params.isNotEmpty()) {
+ appendln(
+ " override suspend fun $name(${getParameterList(params)}) = call($iName::$name, ${getParameterNames(
+ params
+ )})"
+ )
+ } else {
+ appendln(" override suspend fun $name() = call($iName::$name)")
+ }
+ } else {
+ appendln(" override suspend fun $name(${getParameterList(params)}) {}")
+ val type1 = params[0].type.toString().replace("ReceiveChannel", "SendChannel")
+ val type2 = params[1].type.toString().replace("SendChannel", "ReceiveChannel")
+ appendln(" suspend fun $name(handler: suspend ($type1, $type2) -> Unit) = webSocket($iName::$name, handler)")
+ }
+ } else {
+ if (it.returnType.toString().startsWith("RemoteData")) {
+ appendln(" override fun $name(${getParameterList(params)}) = ${it.returnType.toString()}()")
+ } else {
+ appendln(" override fun $name(${getParameterList(params)}) = emptyList<RemoteOption>()")
+ }
+ }
+ }
+ appendln("}")
+ }.toString()
+ val frontendDestinationDir = File(
+ genRootDir,
+ "frontend" + File.separator + packageName.replace('.', File.separatorChar)
+ ).apply {
+ mkdirs()
+ }
+ val frontendFile = File(frontendDestinationDir, "${baseName}.kt")
+ if (frontendFile.exists()) {
+ val content = frontendFile.readText()
+ if (content != frontendCode) {
+ frontendFile.writeText(frontendCode)
+ }
+ } else {
+ frontendFile.writeText(frontendCode)
+ }
+ }
+ }
+ }
+ }
+
+ private fun getParameterList(params: List<ParameterDescriptor>): String {
+ return params.map {
+ "${it.name.asString()}: ${it.type}"
+ }.joinToString(", ")
+ }
+
+ private fun getParameterNames(params: List<ParameterDescriptor>): String {
+ return params.map {
+ it.name.asString()
+ }.joinToString(", ")
+ }
+
+ private fun getTypes(type: KotlinType): Set<String> {
+ return if (type.arguments.isNotEmpty()) {
+ (type.arguments.flatMap { getTypes(it.type) } + type.getJetTypeFqName(false)).toSet()
+ } else {
+ setOf(type.getJetTypeFqName(false))
+ }
+ }
+
+ private fun getTypes(methods: Collection<CallableMemberDescriptor>): Set<String> {
+ return methods.flatMap { m ->
+ m.allParameters.drop(1).flatMap { p ->
+ getTypes(p.type)
+ }.toSet() + (m.returnType?.let { getTypes(it) } ?: setOf())
+ }.filterNot {
+ it.startsWith("kotlin.collections.") || it.startsWith("kotlin.")
+ }.toSet()
+ }
+
+ override fun getSupportedAnnotationTypes(): Set<String> = setOf(
+ KVService::class.java.name
+ )
+
+}
diff --git a/kvision-modules/kvision-gradle-plugin/build.gradle b/kvision-modules/kvision-gradle-plugin/build.gradle
new file mode 100644
index 00000000..7b2d0f33
--- /dev/null
+++ b/kvision-modules/kvision-gradle-plugin/build.gradle
@@ -0,0 +1,20 @@
+apply plugin: 'kotlin-platform-jvm'
+apply plugin: "java-gradle-plugin"
+apply plugin: "kotlin-kapt"
+apply plugin: "maven"
+
+gradlePlugin {
+ plugins {
+ simplePlugin {
+ id = "pl.treksoft.kvision"
+ implementationClass = "pl.treksoft.kvision.gradle.KVisionGradlePlugin"
+ }
+ }
+}
+
+dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
+ compile "org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kotlinVersion"
+ compileOnly "com.google.auto.service:auto-service:$autoServiceVersion"
+ kapt "com.google.auto.service:auto-service:$autoServiceVersion"
+}
diff --git a/kvision-modules/kvision-gradle-plugin/src/main/kotlin/pl/treksoft/kvision/gradle/KVisionGradlePlugin.kt b/kvision-modules/kvision-gradle-plugin/src/main/kotlin/pl/treksoft/kvision/gradle/KVisionGradlePlugin.kt
new file mode 100644
index 00000000..ec2dd7f4
--- /dev/null
+++ b/kvision-modules/kvision-gradle-plugin/src/main/kotlin/pl/treksoft/kvision/gradle/KVisionGradlePlugin.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision.gradle
+
+import org.gradle.api.Project
+
+open class KVisionGradlePlugin : org.gradle.api.Plugin<Project> {
+ override fun apply(project: Project) {
+
+ }
+}
diff --git a/kvision-modules/kvision-gradle-plugin/src/main/kotlin/pl/treksoft/kvision/gradle/KVisionGradleSubplugin.kt b/kvision-modules/kvision-gradle-plugin/src/main/kotlin/pl/treksoft/kvision/gradle/KVisionGradleSubplugin.kt
new file mode 100644
index 00000000..5ecfc3e9
--- /dev/null
+++ b/kvision-modules/kvision-gradle-plugin/src/main/kotlin/pl/treksoft/kvision/gradle/KVisionGradleSubplugin.kt
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision.gradle
+
+import com.google.auto.service.AutoService
+import org.gradle.api.Project
+import org.gradle.api.tasks.compile.AbstractCompile
+import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
+import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
+import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin
+import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact
+import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
+
+@AutoService(KotlinGradleSubplugin::class)
+class KVisionGradleSubplugin : KotlinGradleSubplugin<AbstractCompile> {
+ override fun apply(
+ project: Project,
+ kotlinCompile: AbstractCompile,
+ javaCompile: AbstractCompile?,
+ variantData: Any?,
+ androidProjectHandler: Any?,
+ kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
+ ): List<SubpluginOption> {
+ return emptyList()
+ }
+
+ override fun isApplicable(project: Project, task: AbstractCompile) =
+ project.plugins.hasPlugin(KVisionGradlePlugin::class.java)
+
+ override fun getCompilerPluginId(): String = "KVisionPlugin"
+
+ override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact(
+ groupId = "pl.treksoft",
+ artifactId = "kvision-compiler-plugin",
+ version = "2.0.0-SNAPSHOT"
+ )
+
+}
diff --git a/kvision-modules/kvision-remote/build.gradle b/kvision-modules/kvision-remote/build.gradle
index 277cce18..e5cac713 100644
--- a/kvision-modules/kvision-remote/build.gradle
+++ b/kvision-modules/kvision-remote/build.gradle
@@ -30,6 +30,7 @@ compileTestKotlin2Js {
dependencies {
expectedBy project(":kvision-modules:kvision-common-remote")
expectedBy project(":kvision-modules:kvision-common-types")
+ expectedBy project(":kvision-modules:kvision-common-annotations")
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutinesVersion"
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serializationVersion"
diff --git a/kvision-modules/kvision-server-jooby/build.gradle b/kvision-modules/kvision-server-jooby/build.gradle
index deafd40a..e1b2e9f4 100644
--- a/kvision-modules/kvision-server-jooby/build.gradle
+++ b/kvision-modules/kvision-server-jooby/build.gradle
@@ -11,6 +11,7 @@ dependencyManagement {
dependencies {
expectedBy project(":kvision-modules:kvision-common-types")
expectedBy project(":kvision-modules:kvision-common-remote")
+ expectedBy project(":kvision-modules:kvision-common-annotations")
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
@@ -24,6 +25,7 @@ dependencies {
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
testCompile project(":kvision-modules:kvision-common-types")
testCompile project(":kvision-modules:kvision-common-remote")
+ testCompile project(":kvision-modules:kvision-common-annotations")
}
compileKotlin {
diff --git a/kvision-modules/kvision-server-ktor/build.gradle b/kvision-modules/kvision-server-ktor/build.gradle
index 44be9171..20e21f6d 100644
--- a/kvision-modules/kvision-server-ktor/build.gradle
+++ b/kvision-modules/kvision-server-ktor/build.gradle
@@ -4,6 +4,7 @@ apply plugin: 'kotlinx-serialization'
dependencies {
expectedBy project(":kvision-modules:kvision-common-types")
expectedBy project(":kvision-modules:kvision-common-remote")
+ expectedBy project(":kvision-modules:kvision-common-annotations")
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion"
@@ -16,6 +17,7 @@ dependencies {
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
testCompile project(":kvision-modules:kvision-common-types")
testCompile project(":kvision-modules:kvision-common-remote")
+ testCompile project(":kvision-modules:kvision-common-annotations")
}
compileKotlin {
diff --git a/kvision-modules/kvision-server-spring-boot/build.gradle b/kvision-modules/kvision-server-spring-boot/build.gradle
index e277547b..c46a38b1 100644
--- a/kvision-modules/kvision-server-spring-boot/build.gradle
+++ b/kvision-modules/kvision-server-spring-boot/build.gradle
@@ -13,6 +13,7 @@ repositories {
dependencies {
expectedBy project(":kvision-modules:kvision-common-types")
expectedBy project(":kvision-modules:kvision-common-remote")
+ expectedBy project(":kvision-modules:kvision-common-annotations")
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
@@ -28,6 +29,7 @@ dependencies {
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
testCompile project(":kvision-modules:kvision-common-types")
testCompile project(":kvision-modules:kvision-common-remote")
+ testCompile project(":kvision-modules:kvision-common-annotations")
}
compileKotlin {