-
-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from stiXits/master
Demo build configuration with gradle
- Loading branch information
Showing
21 changed files
with
383 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dependencies { | ||
compile 'ro.fortsoft.pf4j:pf4j:0.4' | ||
compile 'org.apache.commons:commons-lang3:3.0' | ||
testCompile group: 'junit', name: 'junit', version: '4.+' | ||
} |
24 changes: 24 additions & 0 deletions
24
demo_gradle/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2012 Decebal Suiu | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with | ||
* the License. You may obtain a copy of the License in the LICENSE file, or 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.api; | ||
|
||
import ro.fortsoft.pf4j.ExtensionPoint; | ||
|
||
/** | ||
* @author Decebal Suiu | ||
*/ | ||
public interface Greeting extends ExtensionPoint { | ||
|
||
public String getGreeting(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apply plugin:'application' | ||
|
||
mainClassName = 'ro.fortsoft.pf4j.demo.Boot' | ||
|
||
dependencies { | ||
compile project(':api') | ||
compile 'ro.fortsoft.pf4j:pf4j:0.4' | ||
compile 'org.apache.commons:commons-lang3:3.0' | ||
testCompile group: 'junit', name: 'junit', version: '4.+' | ||
} | ||
|
||
jar { | ||
baseName = 'Plugin Demo' | ||
version = '0.1.0' | ||
} |
96 changes: 96 additions & 0 deletions
96
demo_gradle/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright 2012 Decebal Suiu | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with | ||
* the License. You may obtain a copy of the License in the LICENSE file, or 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; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import ro.fortsoft.pf4j.DefaultPluginManager; | ||
import ro.fortsoft.pf4j.PluginManager; | ||
import ro.fortsoft.pf4j.PluginWrapper; | ||
import ro.fortsoft.pf4j.demo.api.Greeting; | ||
|
||
/** | ||
* A boot class that start the demo. | ||
* | ||
* @author Decebal Suiu | ||
*/ | ||
public class Boot { | ||
|
||
public static void main(String[] args) { | ||
// print logo | ||
printLogo(); | ||
|
||
// create the plugin manager | ||
final PluginManager pluginManager = new DefaultPluginManager(); | ||
|
||
// load the plugins | ||
pluginManager.loadPlugins(); | ||
|
||
// enable a disabled plugin | ||
// pluginManager.enablePlugin("welcome-plugin"); | ||
|
||
// start (active/resolved) the plugins | ||
pluginManager.startPlugins(); | ||
|
||
System.out.println("Plugindirectory: "); | ||
System.out.println("\t" + System.getProperty("pf4j.pluginsDir", "plugins") + "\n"); | ||
|
||
// retrieves the extensions for Greeting extension point | ||
List<Greeting> greetings = pluginManager.getExtensions(Greeting.class); | ||
System.out.println(String.format("Found %d extensions for extension point '%s'", greetings.size(), Greeting.class.getName())); | ||
for (Greeting greeting : greetings) { | ||
System.out.println(">>> " + greeting.getGreeting()); | ||
} | ||
|
||
// // print extensions from classpath (non plugin) | ||
// System.out.println(String.format("Extensions added by classpath:")); | ||
// Set<String> extensionClassNames = pluginManager.getExtensionClassNames(null); | ||
// for (String extension : extensionClassNames) { | ||
// System.out.println(" " + extension); | ||
// } | ||
|
||
// print extensions for each started plugin | ||
List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins(); | ||
for (PluginWrapper plugin : startedPlugins) { | ||
String pluginId = plugin.getDescriptor().getPluginId(); | ||
System.out.println(String.format("Extensions added by plugin '%s':", pluginId)); | ||
// extensionClassNames = pluginManager.getExtensionClassNames(pluginId); | ||
// for (String extension : extensionClassNames) { | ||
// System.out.println(" " + extension); | ||
// } | ||
} | ||
|
||
// stop the plugins | ||
pluginManager.stopPlugins(); | ||
/* | ||
Runtime.getRuntime().addShutdownHook(new Thread() { | ||
@Override | ||
public void run() { | ||
pluginManager.stopPlugins(); | ||
} | ||
}); | ||
*/ | ||
} | ||
|
||
private static void printLogo() { | ||
System.out.println(StringUtils.repeat("#", 40)); | ||
System.out.println(StringUtils.center("PF4J-DEMO", 40)); | ||
System.out.println(StringUtils.repeat("#", 40)); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
demo_gradle/app/src/main/java/ro/fortsoft/pf4j/demo/WhazzupGreeting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2014 Decebal Suiu | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with | ||
* the License. You may obtain a copy of the License in the LICENSE file, or 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; | ||
|
||
import ro.fortsoft.pf4j.Extension; | ||
import ro.fortsoft.pf4j.demo.api.Greeting; | ||
|
||
/** | ||
* @author Decebal Suiu | ||
*/ | ||
@Extension | ||
public class WhazzupGreeting implements Greeting { | ||
|
||
@Override | ||
public String getGreeting() { | ||
return "Whazzup"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
log4j.rootLogger=DEBUG, Console | ||
|
||
# | ||
# PF4J log | ||
# | ||
log4j.logger.ro.fortsoft.pf4j=DEBUG, Console | ||
log4j.logger.ro.fortsoft.pf4j.PluginClassLoader=WARN, Console | ||
log4j.additivity.ro.fortsoft.pf4j=false | ||
|
||
# | ||
# Appenders | ||
# | ||
log4j.appender.Console=org.apache.log4j.ConsoleAppender | ||
log4j.appender.Console.layout=org.apache.log4j.PatternLayout | ||
#log4j.appender.Console.layout.conversionPattern=%-5p - %-32.32c{1} - %m\n | ||
log4j.appender.Console.layout.ConversionPattern=%d %p %c - %m%n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
subprojects { | ||
apply plugin: 'java' | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
|
||
task wrapper(type: Wrapper) { | ||
gradleVersion = '1.11' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
######################################## | ||
# - load all plugins except these | ||
# - add one plugin id on each line | ||
# - put this file in plugins folder | ||
######################################## | ||
#welcome-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
######################################## | ||
# - load only these plugins | ||
# - add one plugin id on each line | ||
# - put this file in plugins folder | ||
######################################## | ||
#welcome-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
jar { | ||
baseName = 'WelcomePlugin' | ||
version = '0.1.0' | ||
manifest { | ||
attributes 'Plugin-Class' : 'ro.fortsoft.pf4j.demo.welcome.WelcomePlugin', | ||
'Plugin-Id' : 'WelcomePlugin', | ||
'Plugin-Version' : '1.0', | ||
'Plugin-Provider' : 'Decebal Suiu' | ||
} | ||
} | ||
|
||
task plugin(type: Jar) { | ||
baseName = 'WelcomePlugin' | ||
version = '0.1.0' | ||
into('classes') | ||
extension('zip') | ||
with jar | ||
} | ||
|
||
dependencies { | ||
compile project(':api') | ||
compile 'ro.fortsoft.pf4j:pf4j:0.4' | ||
compile 'org.apache.commons:commons-lang3:3.0' | ||
testCompile group: 'junit', name: 'junit', version: '4.+' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
plugin.id=welcome-plugin | ||
plugin.class=ro.fortsoft.pf4j.demo.welcome.WelcomePlugin | ||
plugin.version=0.0.1 | ||
plugin.provider=Decebal Suiu | ||
plugin.dependencies= |
52 changes: 52 additions & 0 deletions
52
demo_gradle/plugins/plugin1/src/main/java/ro/fortsoft/pf4j/demo/welcome/WelcomePlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2012 Decebal Suiu | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with | ||
* the License. You may obtain a copy of the License in the LICENSE file, or 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.welcome; | ||
|
||
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; | ||
|
||
/** | ||
* @author Decebal Suiu | ||
*/ | ||
public class WelcomePlugin extends Plugin { | ||
|
||
public WelcomePlugin(PluginWrapper wrapper) { | ||
super(wrapper); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
System.out.println("WelcomePlugin.start()"); | ||
System.out.println(StringUtils.upperCase("WelcomePlugin")); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
System.out.println("WelcomePlugin.stop()"); | ||
} | ||
|
||
@Extension | ||
public static class WelcomeGreeting implements Greeting { | ||
|
||
@Override | ||
public String getGreeting() { | ||
return "Welcome"; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
jar { | ||
baseName = 'HelloPlugin' | ||
version = '0.1.0' | ||
manifest { | ||
attributes 'Plugin-Class' : 'ro.fortsoft.pf4j.demo.welcome.HelloPlugin', | ||
'Plugin-Id' : 'HelloPlugin', | ||
'Plugin-Version' : '1.0', | ||
'Plugin-Provider' : 'Decebal Suiu' | ||
} | ||
} | ||
|
||
task plugin(type: Jar) { | ||
baseName = 'HelloPlugin' | ||
version = '0.1.0' | ||
into('classes') | ||
extension('zip') | ||
with jar | ||
} | ||
|
||
dependencies { | ||
compile project(':api') | ||
compile 'ro.fortsoft.pf4j:pf4j:0.4' | ||
compile 'org.apache.commons:commons-lang3:3.0' | ||
testCompile group: 'junit', name: 'junit', version: '4.+' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
plugin.id=hello-plugin | ||
plugin.class=ro.fortsoft.pf4j.demo.hello.HelloPlugin | ||
plugin.version=0.0.1 | ||
plugin.provider=Decebal Suiu | ||
plugin.dependencies= |
Oops, something went wrong.