From 84f406bfd20ec2076cf7616e7f396ad480513bc4 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Mon, 10 Mar 2014 01:50:49 +0100 Subject: [PATCH] Add plugins/extension infrastructure Plugins are stored in `${baseFolder}/plugins` and are loaded during startup by the PluginManager. A plugin defines it's metadata in META-INF/MANIFEST.MF: Plugin-Class: com.gitblit.plugins.cookbook.CookbookPlugin Plugin-Dependencies: foo, bar Plugin-Id: gitblit-plugin Plugin-Provider: John Doe Plugin-Version: 1.0 Plugins can define extension points that can be implemented by other plugins and they can depend on other plugins: Plugin-Dependencies: foo, bar During the load phase, a directed acyclic graph is built and the loading order of the dependency chain is reversed using a topological sort; parent followed by children. The parent plugin classloader is the combined classloader of all parent plugins. Change-Id: I738821fa2bff02a5dbe339a944cc7e3c4dd8e299 --- .classpath | 1 + build.moxie | 1 + gitblit.iml | 11 ++++ src/main/distrib/data/gitblit.properties | 8 +++ src/main/java/WEB-INF/web.xml | 3 +- src/main/java/com/gitblit/DaggerModule.java | 13 ++++- .../java/com/gitblit/FederationClient.java | 2 +- src/main/java/com/gitblit/GitBlit.java | 7 ++- .../java/com/gitblit/dagger/DaggerFilter.java | 2 +- .../com/gitblit/manager/GitblitManager.java | 18 +++++- .../java/com/gitblit/manager/IGitblit.java | 3 +- .../com/gitblit/manager/IPluginManager.java | 39 +++++++++++++ .../com/gitblit/manager/PluginManager.java | 56 +++++++++++++++++++ .../com/gitblit/servlet/GitblitContext.java | 2 + .../gitblit/servlet/SyndicationFilter.java | 1 + 15 files changed, 157 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/gitblit/manager/IPluginManager.java create mode 100644 src/main/java/com/gitblit/manager/PluginManager.java diff --git a/.classpath b/.classpath index d3aec7e8..252a7c96 100644 --- a/.classpath +++ b/.classpath @@ -76,6 +76,7 @@ + diff --git a/build.moxie b/build.moxie index 6015becc..eb2878a8 100644 --- a/build.moxie +++ b/build.moxie @@ -174,6 +174,7 @@ dependencies: - compile 'args4j:args4j:2.0.26' :war :fedclient :authority - compile 'commons-codec:commons-codec:1.7' :war - compile 'redis.clients:jedis:2.3.1' :war +- compile 'ro.fortsoft.pf4j:pf4j:0.6' :war - test 'junit' # Dependencies for Selenium web page testing - test 'org.seleniumhq.selenium:selenium-java:${selenium.version}' @jar diff --git a/gitblit.iml b/gitblit.iml index a48f12ad..ed067f28 100644 --- a/gitblit.iml +++ b/gitblit.iml @@ -790,6 +790,17 @@ + + + + + + + + + + + diff --git a/src/main/distrib/data/gitblit.properties b/src/main/distrib/data/gitblit.properties index 64a52f5c..762344b4 100644 --- a/src/main/distrib/data/gitblit.properties +++ b/src/main/distrib/data/gitblit.properties @@ -1844,3 +1844,11 @@ server.requireClientCertificates = false # SINCE 0.5.0 # RESTART REQUIRED server.shutdownPort = 8081 + +# Base folder for plugins. +# This folder may contain Gitblit plugins +# +# SINCE 1.6.0 +# RESTART REQUIRED +# BASEFOLDER +plugins.folder = ${baseFolder}/plugins diff --git a/src/main/java/WEB-INF/web.xml b/src/main/java/WEB-INF/web.xml index 1451ec63..77456d47 100644 --- a/src/main/java/WEB-INF/web.xml +++ b/src/main/java/WEB-INF/web.xml @@ -199,7 +199,6 @@ /robots.txt -