aboutsummaryrefslogtreecommitdiffstats
path: root/demo/gradle/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'demo/gradle/plugins')
-rw-r--r--demo/gradle/plugins/build.gradle33
-rw-r--r--demo/gradle/plugins/disabled.txt6
-rw-r--r--demo/gradle/plugins/enabled.txt6
-rw-r--r--demo/gradle/plugins/plugin1/.gitignore1
-rw-r--r--demo/gradle/plugins/plugin1/build.gradle11
-rw-r--r--demo/gradle/plugins/plugin1/gradle.properties6
-rw-r--r--demo/gradle/plugins/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java59
-rw-r--r--demo/gradle/plugins/plugin2/.gitignore1
-rw-r--r--demo/gradle/plugins/plugin2/build.gradle11
-rw-r--r--demo/gradle/plugins/plugin2/gradle.properties6
-rw-r--r--demo/gradle/plugins/plugin2/src/main/java/org/pf4j/demo/hello/HelloPlugin.java57
-rw-r--r--demo/gradle/plugins/plugin3/build.gradle30
-rw-r--r--demo/gradle/plugins/plugin3/gradle.properties6
-rw-r--r--demo/gradle/plugins/plugin3/src/main/kotlin/org/pf4j/demo/kotlin/KotlinPlugin.kt48
14 files changed, 281 insertions, 0 deletions
diff --git a/demo/gradle/plugins/build.gradle b/demo/gradle/plugins/build.gradle
new file mode 100644
index 0000000..4b03210
--- /dev/null
+++ b/demo/gradle/plugins/build.gradle
@@ -0,0 +1,33 @@
+subprojects {
+ jar {
+ manifest {
+ attributes 'Plugin-Class': "${pluginClass}",
+ 'Plugin-Id': "${pluginId}",
+ 'Plugin-Version': "${archiveVersion}",
+ 'Plugin-Provider': "${pluginProvider}",
+ 'Plugin-Dependencies': "${pluginDependencies}"
+ }
+ }
+
+ task plugin(type: Jar) {
+ archiveBaseName = "plugin-${pluginId}"
+ into('classes') {
+ with jar
+ }
+ into('lib') {
+ from configurations.runtimeClasspath
+ }
+ archiveExtension ='zip'
+ }
+
+ task assemblePlugin(type: Copy) {
+ from plugin
+ into pluginsDir
+ }
+}
+
+task assemblePlugins(type: Copy) {
+ dependsOn subprojects.assemblePlugin
+}
+
+build.dependsOn project.tasks.assemblePlugins
diff --git a/demo/gradle/plugins/disabled.txt b/demo/gradle/plugins/disabled.txt
new file mode 100644
index 0000000..45f1801
--- /dev/null
+++ b/demo/gradle/plugins/disabled.txt
@@ -0,0 +1,6 @@
+########################################
+# - load all plugins except these
+# - add one plugin id on each line
+# - put this file in plugins folder
+########################################
+#welcome-plugin
diff --git a/demo/gradle/plugins/enabled.txt b/demo/gradle/plugins/enabled.txt
new file mode 100644
index 0000000..3d76b2f
--- /dev/null
+++ b/demo/gradle/plugins/enabled.txt
@@ -0,0 +1,6 @@
+########################################
+# - load only these plugins
+# - add one plugin id on each line
+# - put this file in plugins folder
+########################################
+#welcome-plugin
diff --git a/demo/gradle/plugins/plugin1/.gitignore b/demo/gradle/plugins/plugin1/.gitignore
new file mode 100644
index 0000000..378eac2
--- /dev/null
+++ b/demo/gradle/plugins/plugin1/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/demo/gradle/plugins/plugin1/build.gradle b/demo/gradle/plugins/plugin1/build.gradle
new file mode 100644
index 0000000..78eef47
--- /dev/null
+++ b/demo/gradle/plugins/plugin1/build.gradle
@@ -0,0 +1,11 @@
+dependencies {
+ // compileOnly important!!! We do not want to put the api into the zip file since the main program has it already!
+ compileOnly project(':api')
+ compileOnly(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}") {
+ exclude group: "org.slf4j"
+ }
+ annotationProcessor(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}")
+ implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
+ implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
+ testImplementation group: 'junit', name: 'junit', version: '4.+'
+}
diff --git a/demo/gradle/plugins/plugin1/gradle.properties b/demo/gradle/plugins/plugin1/gradle.properties
new file mode 100644
index 0000000..2edd800
--- /dev/null
+++ b/demo/gradle/plugins/plugin1/gradle.properties
@@ -0,0 +1,6 @@
+version=0.0.1
+
+pluginId=welcome-plugin
+pluginClass=org.pf4j.demo.welcome.WelcomePlugin
+pluginProvider=Decebal Suiu
+pluginDependencies=
diff --git a/demo/gradle/plugins/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java b/demo/gradle/plugins/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java
new file mode 100644
index 0000000..aaf1804
--- /dev/null
+++ b/demo/gradle/plugins/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012-present 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 org.pf4j.demo.welcome;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.pf4j.Extension;
+import org.pf4j.Plugin;
+import org.pf4j.PluginWrapper;
+import org.pf4j.demo.api.Greeting;
+
+/**
+ * @author Decebal Suiu
+ */
+public class WelcomePlugin extends Plugin {
+
+ private static final Logger logger = LoggerFactory.getLogger(WelcomePlugin.class);
+
+ public WelcomePlugin(PluginWrapper wrapper) {
+ super(wrapper);
+ }
+
+ @Override
+ public void start() {
+ logger.info("WelcomePlugin.start()");
+ logger.info(StringUtils.upperCase("WelcomePlugin"));
+ }
+
+ @Override
+ public void stop() {
+ logger.info("WelcomePlugin.stop()");
+ }
+
+ @Extension
+ public static class WelcomeGreeting implements Greeting {
+
+ @Override
+ public String getGreeting() {
+ return "Welcome";
+ }
+
+ }
+
+}
diff --git a/demo/gradle/plugins/plugin2/.gitignore b/demo/gradle/plugins/plugin2/.gitignore
new file mode 100644
index 0000000..378eac2
--- /dev/null
+++ b/demo/gradle/plugins/plugin2/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/demo/gradle/plugins/plugin2/build.gradle b/demo/gradle/plugins/plugin2/build.gradle
new file mode 100644
index 0000000..78eef47
--- /dev/null
+++ b/demo/gradle/plugins/plugin2/build.gradle
@@ -0,0 +1,11 @@
+dependencies {
+ // compileOnly important!!! We do not want to put the api into the zip file since the main program has it already!
+ compileOnly project(':api')
+ compileOnly(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}") {
+ exclude group: "org.slf4j"
+ }
+ annotationProcessor(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}")
+ implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
+ implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
+ testImplementation group: 'junit', name: 'junit', version: '4.+'
+}
diff --git a/demo/gradle/plugins/plugin2/gradle.properties b/demo/gradle/plugins/plugin2/gradle.properties
new file mode 100644
index 0000000..ef70127
--- /dev/null
+++ b/demo/gradle/plugins/plugin2/gradle.properties
@@ -0,0 +1,6 @@
+version=0.0.1
+
+pluginId=hello-plugin
+pluginClass=org.pf4j.demo.hello.HelloPlugin
+pluginProvider=Decebal Suiu
+pluginDependencies=
diff --git a/demo/gradle/plugins/plugin2/src/main/java/org/pf4j/demo/hello/HelloPlugin.java b/demo/gradle/plugins/plugin2/src/main/java/org/pf4j/demo/hello/HelloPlugin.java
new file mode 100644
index 0000000..f9c7797
--- /dev/null
+++ b/demo/gradle/plugins/plugin2/src/main/java/org/pf4j/demo/hello/HelloPlugin.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012-present 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 org.pf4j.demo.hello;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.pf4j.Extension;
+import org.pf4j.Plugin;
+import org.pf4j.PluginWrapper;
+import org.pf4j.demo.api.Greeting;
+
+/**
+ * A very simple plugin.
+ *
+ * @author Decebal Suiu
+ */
+public class HelloPlugin extends Plugin {
+ private static final Logger logger = LoggerFactory.getLogger(HelloPlugin.class);
+
+ public HelloPlugin(PluginWrapper wrapper) {
+ super(wrapper);
+ }
+
+ @Override
+ public void start() {
+ logger.info("HelloPlugin.start()");
+ }
+
+ @Override
+ public void stop() {
+ logger.info("HelloPlugin.stop()");
+ }
+
+ @Extension(ordinal=1)
+ public static class HelloGreeting implements Greeting {
+
+ @Override
+ public String getGreeting() {
+ return "Hello";
+ }
+
+ }
+
+}
diff --git a/demo/gradle/plugins/plugin3/build.gradle b/demo/gradle/plugins/plugin3/build.gradle
new file mode 100644
index 0000000..4371251
--- /dev/null
+++ b/demo/gradle/plugins/plugin3/build.gradle
@@ -0,0 +1,30 @@
+buildscript {
+ ext.kotlin_version = '1.9.24'
+
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+
+apply plugin: 'kotlin'
+apply plugin: 'kotlin-kapt'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ compileOnly project(':api')
+ compileOnly(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}") {
+ exclude group: "org.slf4j"
+ }
+ kapt(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}")
+ implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
+ implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
+
+ testImplementation group: 'junit', name: 'junit', version: '4.+'
+}
diff --git a/demo/gradle/plugins/plugin3/gradle.properties b/demo/gradle/plugins/plugin3/gradle.properties
new file mode 100644
index 0000000..a04b609
--- /dev/null
+++ b/demo/gradle/plugins/plugin3/gradle.properties
@@ -0,0 +1,6 @@
+version=1.0.0
+
+pluginId=KotlinPlugin
+pluginClass=org.pf4j.demo.kotlin.KotlinPlugin
+pluginProvider=Anindya Chatterjee
+pluginDependencies=
diff --git a/demo/gradle/plugins/plugin3/src/main/kotlin/org/pf4j/demo/kotlin/KotlinPlugin.kt b/demo/gradle/plugins/plugin3/src/main/kotlin/org/pf4j/demo/kotlin/KotlinPlugin.kt
new file mode 100644
index 0000000..2b2bc17
--- /dev/null
+++ b/demo/gradle/plugins/plugin3/src/main/kotlin/org/pf4j/demo/kotlin/KotlinPlugin.kt
@@ -0,0 +1,48 @@
+/*
+ * 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 org.pf4j.demo.kotlin
+
+import org.apache.commons.lang3.StringUtils
+import org.slf4j.LoggerFactory
+import org.pf4j.Extension
+import org.pf4j.Plugin
+import org.pf4j.PluginWrapper
+import org.pf4j.demo.api.Greeting
+
+/**
+ * A sample plugin written in Kotlin
+ *
+ * @author Anindya Chatterjee
+ */
+class KotlinPlugin(wrapper: PluginWrapper) : Plugin(wrapper) {
+ private val logger = LoggerFactory.getLogger(KotlinPlugin::class.java)
+
+ override fun start() {
+ logger.info("KotlinPlugin.start()")
+ logger.info(StringUtils.upperCase("KotlinPlugin"))
+ }
+
+ override fun stop() {
+ logger.info("KotlinPlugin.stop()")
+ }
+}
+
+@Extension
+class KotlinGreeting : Greeting {
+ override fun getGreeting(): String {
+ return "KotlinGreetings"
+ }
+}