mirror of https://github.com/pf4j/pf4j.git
Cesar Andres
7 years ago
committed by
Decebal Suiu
16 changed files with 198 additions and 146 deletions
@ -0,0 +1,62 @@ |
|||||||
|
# PF4J Gradle Demo |
||||||
|
|
||||||
|
This demo assumes that you know the basics of Gradle (Please look at [gradle](https://gradle.org/) for more info) |
||||||
|
|
||||||
|
### Setup/Build |
||||||
|
|
||||||
|
1. Clone the repo |
||||||
|
2. Go to demo_gradle `cd demo_gradle` |
||||||
|
3. run `gradle build` |
||||||
|
|
||||||
|
* This will produce one jar, named app-plugin-demo-uberjar.jar, located in the `app/build/libs/` directory and three plugins zips located in `build/plugins` directory. |
||||||
|
* The plugins are `plugin-hello-plugin-0.0.1.zip`, `plugin-KotlinPlugin-1.0.0.zip` and `plugin-welcome-plugin-0.0.1.zip` |
||||||
|
|
||||||
|
### Run the demo |
||||||
|
|
||||||
|
1. Run |
||||||
|
|
||||||
|
``` |
||||||
|
java -jar -Dpf4j.pluginsDir=build/plugins app/build/libs/app-plugin-demo-uberjar.jar |
||||||
|
``` |
||||||
|
|
||||||
|
* pf4j.pluginsDir: is where the plugins are located |
||||||
|
|
||||||
|
2. The demo's output should look similar to: (Please see `Boot#main()` for more details) |
||||||
|
``` |
||||||
|
demo_gradle $ java -jar -Dpf4j.pluginsDir=build/plugins app/build/libs/app-plugin-demo-uberjar.jar |
||||||
|
[main] INFO org.pf4j.demo.Boot - ######################################## |
||||||
|
[main] INFO org.pf4j.demo.Boot - PF4J-DEMO |
||||||
|
[main] INFO org.pf4j.demo.Boot - ######################################## |
||||||
|
[main] INFO org.pf4j.DefaultPluginStatusProvider - Enabled plugins: [] |
||||||
|
[main] INFO org.pf4j.DefaultPluginStatusProvider - Disabled plugins: [] |
||||||
|
[main] INFO org.pf4j.DefaultPluginManager - PF4J version 0.0.0 in 'deployment' mode |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Plugin 'welcome-plugin@0.0.1' resolved |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Plugin 'KotlinPlugin@1.0.0' resolved |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Plugin 'hello-plugin@0.0.1' resolved |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Start plugin 'welcome-plugin@0.0.1' |
||||||
|
[main] INFO org.pf4j.demo.welcome.WelcomePlugin - WelcomePlugin.start() |
||||||
|
[main] INFO org.pf4j.demo.welcome.WelcomePlugin - WELCOMEPLUGIN |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Start plugin 'KotlinPlugin@1.0.0' |
||||||
|
[main] INFO org.pf4j.demo.kotlin.KotlinPlugin - KotlinPlugin.start() |
||||||
|
[main] INFO org.pf4j.demo.kotlin.KotlinPlugin - KOTLINPLUGIN |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Start plugin 'hello-plugin@0.0.1' |
||||||
|
[main] INFO org.pf4j.demo.hello.HelloPlugin - HelloPlugin.start() |
||||||
|
[main] INFO org.pf4j.demo.Boot - Plugindirectory: |
||||||
|
[main] INFO org.pf4j.demo.Boot - build/plugins |
||||||
|
|
||||||
|
[main] INFO org.pf4j.demo.Boot - Found 3 extensions for extension point 'org.pf4j.demo.api.Greeting' |
||||||
|
[main] INFO org.pf4j.demo.Boot - >>> Whazzup |
||||||
|
[main] INFO org.pf4j.demo.Boot - >>> Welcome |
||||||
|
[main] INFO org.pf4j.demo.Boot - >>> Hello |
||||||
|
[main] INFO org.pf4j.demo.Boot - Extensions added by plugin 'welcome-plugin': |
||||||
|
[main] INFO org.pf4j.demo.Boot - Extensions added by plugin 'KotlinPlugin': |
||||||
|
[main] INFO org.pf4j.demo.Boot - Extensions added by plugin 'hello-plugin': |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Stop plugin 'hello-plugin@0.0.1' |
||||||
|
[main] INFO org.pf4j.demo.hello.HelloPlugin - HelloPlugin.stop() |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Stop plugin 'KotlinPlugin@1.0.0' |
||||||
|
[main] INFO org.pf4j.demo.kotlin.KotlinPlugin - KotlinPlugin.stop() |
||||||
|
[main] INFO org.pf4j.AbstractPluginManager - Stop plugin 'welcome-plugin@0.0.1' |
||||||
|
[main] INFO org.pf4j.demo.welcome.WelcomePlugin - WelcomePlugin.stop() |
||||||
|
|
||||||
|
``` |
||||||
|
|
@ -1,5 +1,6 @@ |
|||||||
dependencies { |
dependencies { |
||||||
compile 'org.pf4j:pf4j:2.0.0-SNAPSHOT' |
compile group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}" |
||||||
compile 'org.apache.commons:commons-lang3:3.0' |
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5' |
||||||
|
|
||||||
testCompile group: 'junit', name: 'junit', version: '4.+' |
testCompile group: 'junit', name: 'junit', version: '4.+' |
||||||
} |
} |
||||||
|
@ -0,0 +1,32 @@ |
|||||||
|
subprojects { |
||||||
|
jar { |
||||||
|
manifest { |
||||||
|
attributes 'Plugin-Class': "${pluginClass}", |
||||||
|
'Plugin-Id': "${pluginId}", |
||||||
|
'Plugin-Version': "${version}", |
||||||
|
'Plugin-Provider': "${pluginProvider}" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
task plugin(type: Jar) { |
||||||
|
baseName = "plugin-${pluginId}" |
||||||
|
into('classes') { |
||||||
|
with jar |
||||||
|
} |
||||||
|
into('lib') { |
||||||
|
from configurations.compile |
||||||
|
} |
||||||
|
extension('zip') |
||||||
|
} |
||||||
|
|
||||||
|
task assemblePlugin(type: Copy) { |
||||||
|
from plugin |
||||||
|
into pluginsDir |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
task assemblePlugins(type: Copy) { |
||||||
|
dependsOn subprojects.assemblePlugin |
||||||
|
} |
||||||
|
|
||||||
|
build.dependsOn project.tasks.assemblePlugins |
@ -1,33 +1,9 @@ |
|||||||
jar { |
|
||||||
baseName = 'WelcomePlugin' |
|
||||||
version = '0.1.0' |
|
||||||
manifest { |
|
||||||
attributes 'Plugin-Class': 'org.pf4j.demo.welcome.WelcomePlugin', |
|
||||||
'Plugin-Id': 'WelcomePlugin', |
|
||||||
'Plugin-Version': '1.0.0', |
|
||||||
'Plugin-Provider': 'Decebal Suiu' |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
task plugin(type: Jar) { |
|
||||||
baseName = 'WelcomePlugin' |
|
||||||
version = '0.1.0' |
|
||||||
into('classes') { |
|
||||||
with jar |
|
||||||
} |
|
||||||
into('lib') { |
|
||||||
from configurations.compile |
|
||||||
} |
|
||||||
extension('zip') |
|
||||||
} |
|
||||||
assemble.dependsOn plugin |
|
||||||
|
|
||||||
dependencies { |
dependencies { |
||||||
compileOnly project(':api') |
|
||||||
// compileOnly important!!! We do not want to put the api into the zip file since the main program has it already! |
// compileOnly important!!! We do not want to put the api into the zip file since the main program has it already! |
||||||
compile('org.pf4j:pf4j:2.0.0-SNAPSHOT') { |
compileOnly project(':api') |
||||||
|
compileOnly(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}") { |
||||||
exclude group: "org.slf4j" |
exclude group: "org.slf4j" |
||||||
} |
} |
||||||
compile 'org.apache.commons:commons-lang3:3.5' |
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5' |
||||||
testCompile group: 'junit', name: 'junit', version: '4.+' |
testCompile group: 'junit', name: 'junit', version: '4.+' |
||||||
} |
} |
||||||
|
@ -0,0 +1,6 @@ |
|||||||
|
version=0.0.1 |
||||||
|
|
||||||
|
pluginId=welcome-plugin |
||||||
|
pluginClass=org.pf4j.demo.welcome.WelcomePlugin |
||||||
|
pluginProvider=Decebal Suiu |
||||||
|
pluginDependencies= |
@ -1,5 +0,0 @@ |
|||||||
plugin.id=welcome-plugin |
|
||||||
plugin.class=org.pf4j.demo.welcome.WelcomePlugin |
|
||||||
plugin.version=0.0.1 |
|
||||||
plugin.provider=Decebal Suiu |
|
||||||
plugin.dependencies= |
|
@ -1,33 +1,9 @@ |
|||||||
jar { |
|
||||||
baseName = 'HelloPlugin' |
|
||||||
version = '0.1.0' |
|
||||||
manifest { |
|
||||||
attributes 'Plugin-Class': 'org.pf4j.demo.hello.HelloPlugin', |
|
||||||
'Plugin-Id': 'HelloPlugin', |
|
||||||
'Plugin-Version': '1.0.0', |
|
||||||
'Plugin-Provider': 'Decebal Suiu' |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
task plugin(type: Jar) { |
|
||||||
baseName = 'HelloPlugin' |
|
||||||
version = '0.1.0' |
|
||||||
into('classes') { |
|
||||||
with jar |
|
||||||
} |
|
||||||
into('lib') { |
|
||||||
from configurations.compile |
|
||||||
} |
|
||||||
extension('zip') |
|
||||||
} |
|
||||||
assemble.dependsOn plugin |
|
||||||
|
|
||||||
dependencies { |
dependencies { |
||||||
compileOnly project(':api') |
|
||||||
// compileOnly important!!! We do not want to put the api into the zip file since the main program has it already! |
// compileOnly important!!! We do not want to put the api into the zip file since the main program has it already! |
||||||
compile('org.pf4j:pf4j:2.0.0-SNAPSHOT') { |
compileOnly project(':api') |
||||||
|
compileOnly(group: 'org.pf4j', name: 'pf4j', version: "${pf4jVersion}") { |
||||||
exclude group: "org.slf4j" |
exclude group: "org.slf4j" |
||||||
} |
} |
||||||
compile 'org.apache.commons:commons-lang3:3.5' |
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5' |
||||||
testCompile group: 'junit', name: 'junit', version: '4.+' |
testCompile group: 'junit', name: 'junit', version: '4.+' |
||||||
} |
} |
||||||
|
@ -0,0 +1,6 @@ |
|||||||
|
version=0.0.1 |
||||||
|
|
||||||
|
pluginId=hello-plugin |
||||||
|
pluginClass=org.pf4j.demo.hello.HelloPlugin |
||||||
|
pluginProvider=Decebal Suiu |
||||||
|
pluginDependencies= |
@ -1,5 +0,0 @@ |
|||||||
plugin.id=hello-plugin |
|
||||||
plugin.class=org.pf4j.demo.hello.HelloPlugin |
|
||||||
plugin.version=0.0.1 |
|
||||||
plugin.provider=Decebal Suiu |
|
||||||
plugin.dependencies= |
|
@ -0,0 +1,6 @@ |
|||||||
|
version=1.0.0 |
||||||
|
|
||||||
|
pluginId=KotlinPlugin |
||||||
|
pluginClass=org.pf4j.demo.kotlin.KotlinPlugin |
||||||
|
pluginProvider=Anindya Chatterjee |
||||||
|
pluginDependencies= |
Loading…
Reference in new issue