docs/development/create-openproject-plugin/README.md
OpenProject plugins are special ruby gems. You may include them in your Gemfile.plugins file like you would do for any other gem. Fortunately, this gives us plugin version management and dependency resolution for free.
You can generate a new plugin directly from OpenProject. Think of a good name and a place (in your filesystem) where the plugin should go. In this example, we have a plugins directory right next to the openproject directory. Then do
bundle exec rails generate open_project:plugin my_plugin ../plugins/
This generates the plugins openproject-my_plugin into the directory ../plugins/openproject-my_plugin. The new plugin is a rails engine, which can be published as a gem.
You may want to update the generated plugin's gemspec (openproject-my_plugin.gemspec).
Example Plugin
There is an example plugin which does some of the basic things (adding menu items, hooking into views, defining a project menu, etc.) and provides further info in its README.
Instead of generating a new plugin you can also just clone the example plugin and adapt it.
To include the new plugin into OpenProject, we have to add it into Gemfile.plugins like any other OpenProject plugin. Add the following lines to Gemfile.plugins:
group :opf_plugins do
gem "openproject-my_plugin", :path => '../plugins/openproject-my_plugin'
end
If there already is an opf_plugins group, just add the gem line to it.
Once you've done that install it via
bundle install
To use your plugin in production you have to add it to your docker container or install it in the packaged installation.
You may have a look at some existing OpenProject plugins to get inspiration. It is possible to add new routes, views, models, … and/or overwrite existing ones.
Feel free to ask for help in our Development Forum.
The following steps are necessary to release a new plugin:
A code review should check the whole code and remove glitches like:
Usually, this should be GPLv3 and we are the copyright owner. However, some plugins might have additional authors or might originate from code with a different license. These issues have to be resolved first. Also check the years in the copyright. If you need to find all contributors of a repository including their contribution period use the following rake task:
rake copyright:authors:show['../Path/to/repository/']
There is a rake task in the core to perform this job. Use rake copyright:update['path_to_plugin'] (e.g. rake copyright:update['../plugins/openproject-global_roles']) to add the copyright header in COPYRIGHT_short to all relevant plugin files.
If no such file exists, COPYRIGHT_short from the core is used.
doc/COPYRIGHT.md and doc/GPL.txt if referenced by the copyright notice.There should be a file README.md containing:
If you’re unsure about if/who to give credit, you should take a look into the changelog:
git log --pretty=format:%aN | sort | uniq -c | sort -rn
For your convenience you may use the following rake task, that extracts all authors from a repository
rake copyright:authors:show['../Path/to/repository/']
doc folder, the db folder if there are any migrations, the CHANGELOG.md, and the README.md).git push --tags.gem update --systemgem build <name>.gemspecgem push <name>-<version>.gem. This asks for your user/passwordPlugins that extend the frontend application may be packaged as npm modules.
These plugins must contain a package.json in the root directory of the plugin.
Plugins are responsible for loading their own assets, including additional images, styles and I18n translations.
Translations are processed by I18n.js through Rails and will be picked up from config/locales/js-<locale>.js.
Pure frontend plugins are currently not possible without modifications to the OpenProject core package.json.
We instead recommend to create a hybrid gem plugin instead (see below).
Plugins that extend both the Rails and frontend applications are possible. They
must contain both a Gem::Specification and package.json.
CAVEAT: npm dependencies for hybrid plugins are not yet resolved.
To use a hybrid plugin:
Gemfile.plugins within the :opf_plugins group
using the Bundler DSL.bundle install.Provided Ruby Bundler is aware of these plugins, Webpack (our node-based build pipeline) will bundle their assets.