aboutsummaryrefslogtreecommitdiffstats
path: root/demo_gradle
diff options
context:
space:
mode:
authorAnindya Chatterjee <anidotnet@gmail.com>2017-06-09 16:14:27 +0530
committerDecebal Suiu <decebal.suiu@gmail.com>2017-06-09 13:44:27 +0300
commit443191d0cc75079099278596c686c29d18cf9a01 (patch)
treeacf6f84d5ed23ebeecf100cf825652c7710103ae /demo_gradle
parent7f4c67ae6f847ee8a5594413b0ece899e3956300 (diff)
downloadpf4j-443191d0cc75079099278596c686c29d18cf9a01.tar.gz
pf4j-443191d0cc75079099278596c686c29d18cf9a01.zip
Kotlin plugin example added and README updated for Kotlin. (#146)
Diffstat (limited to 'demo_gradle')
-rw-r--r--demo_gradle/plugins/plugin3/build.gradle49
-rw-r--r--demo_gradle/plugins/plugin3/src/main/kotlin/ro/fortsoft/pf4j/demo/kotlin/KotlinPlugin.kt46
-rw-r--r--demo_gradle/settings.gradle4
3 files changed, 98 insertions, 1 deletions
diff --git a/demo_gradle/plugins/plugin3/build.gradle b/demo_gradle/plugins/plugin3/build.gradle
new file mode 100644
index 0000000..8596512
--- /dev/null
+++ b/demo_gradle/plugins/plugin3/build.gradle
@@ -0,0 +1,49 @@
+buildscript {
+ ext.kotlin_version = '1.1.2-2'
+
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+
+jar {
+ baseName = 'KotlinPlugin'
+ version = '0.1.0'
+ manifest {
+ attributes 'Plugin-Class' : 'ro.fortsoft.pf4j.demo.kotlin.KotlinPlugin',
+ 'Plugin-Id' : 'KotlinPlugin',
+ 'Plugin-Version' : '1.0.0',
+ 'Plugin-Provider' : 'Anindya Chatterjee'
+ }
+}
+
+task plugin(type: Jar) {
+ baseName = 'KotlinPlugin'
+ version = '0.1.0'
+ into('classes'){
+ with jar
+ }
+ into('lib'){
+ from configurations.compile
+ }
+ extension('zip')
+}
+assemble.dependsOn plugin
+
+apply plugin: 'kotlin'
+apply plugin: 'kotlin-kapt'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ compileOnly project(':api')
+ kapt 'ro.fortsoft.pf4j:pf4j:1.+'
+ compile 'org.apache.commons:commons-lang3:3.0'
+ testCompile group: 'junit', name: 'junit', version: '4.+'
+ compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
+}
diff --git a/demo_gradle/plugins/plugin3/src/main/kotlin/ro/fortsoft/pf4j/demo/kotlin/KotlinPlugin.kt b/demo_gradle/plugins/plugin3/src/main/kotlin/ro/fortsoft/pf4j/demo/kotlin/KotlinPlugin.kt
new file mode 100644
index 0000000..c6a317e
--- /dev/null
+++ b/demo_gradle/plugins/plugin3/src/main/kotlin/ro/fortsoft/pf4j/demo/kotlin/KotlinPlugin.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ro.fortsoft.pf4j.demo.kotlin
+
+import org.apache.commons.lang3.StringUtils
+import ro.fortsoft.pf4j.Extension
+import ro.fortsoft.pf4j.Plugin
+import ro.fortsoft.pf4j.PluginWrapper
+import ro.fortsoft.pf4j.demo.api.Greeting
+
+/**
+ * A sample plugin written in Kotlin
+ *
+ * @author Anindya Chatterjee
+ */
+class KotlinPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
+
+ override fun start() {
+ println("KotlinPlugin.start()")
+ println(StringUtils.upperCase("KotlinPlugin"))
+ }
+
+ override fun stop() {
+ println("KotlinPlugin.stop()")
+ }
+}
+
+@Extension
+class KotlinGreeting : Greeting {
+ override fun getGreeting(): String {
+ return "KotlinGreetings"
+ }
+}
diff --git a/demo_gradle/settings.gradle b/demo_gradle/settings.gradle
index e76ea04..8bbcb21 100644
--- a/demo_gradle/settings.gradle
+++ b/demo_gradle/settings.gradle
@@ -1,4 +1,6 @@
include 'api'
include 'app'
include 'plugins/plugin1'
-include 'plugins/plugin2' \ No newline at end of file
+include 'plugins/plugin2'
+include 'plugins/plugin3'
+