Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

JRuby Example Plugin

This is an example Alassian plugin using JRuby and Java.

The plugin shows:

  • How to embed the JRuby runtime (via the JRuby Embed API),
  • How to execute Ruby scripts that are part of the plugin
  • How to set variables from Java to be used in Ruby scripts
  • How to work with the output of Ruby scripts
  • How to automatically install and bundle Ruby libraries (RubyGems)

Working with Ruby objects in Java

Ruby Sinatra app running in Confluence


This plugin is for demonstration purposes. Hence it is incomplete and not production ready.


Development

Prerequisite:

Make sure that you have installed the Atlassian Plugin SDK and that the various atlas-* commands are available on your PATH.

Clone the repository and start Confluence from within the plugin project

atlas-debug

The first time this command is executed, the required RubyGem libraries will be automatically downloaded and copied to the src/main/ruby/rubygems directory.

The Maven project is set up to copy the Ruby scripts in src/main/ruby/** into your plugin.

The list of RubyGems is defined in the required.gems property. Feel free to change this list to add the RubyGems you need for your own implementation.

<required.gems>sinatra jruby-rack rio nokogiri</required.gems>

After updating the list, the new RubyGems can be downloaded by running:

mvn -Prubygems process-resources

Note: The build process creates an index file META-INF/gemspec.index that is used by the ScriptingContainerProviderImpl to correctly set the Ruby LOAD_PATH so that all the RubyGems can be read from the classpath.

Running Tests

At the moment the Ruby tests need to be run manually (they are not executed as part of the Maven build yet).

With jruby available on your PATH run (see http://jruby.org/getting-started to get started):

jruby -S bundle install
jruby -S rake test

References

https://github.com/jruby/jruby/wiki/JRubyCompiler

https://github.com/jruby/jruby/wiki/FAQs#Calling_Into_Java

https://github.com/jruby/jruby/wiki/GeneratingJavaClasses

http://www.sinatrarb.com/

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.