Do you want to create a JRuby extension?

Previously you may have seen guides by Yoko Harada (yokolet) and James Coglan which suggest you use the Rake-Compiler to compile your code. However those recommendations were made before the polyglot maven compiler existed, which is now the recommended way to compile and jar your ruby code. You can now write your pom file in ruby (and get regular pom.xml emitted useful when working with a java ide such as netbeans). For a basic example see jruby-examples which demonstrates how to create a ruby class and ruby module in java. The article by James Coglan remains in interesting, as it shows how you should create a java extension of a gem with an existing MRI extension. The beauty of maven is that you can pull in jar dependencies from maven central including jruby-base.jar which is the recommended jruby dependency when compiling jruby extension (was jruby.jar but that may cause dependency conflicts).

For a JRubyArt example see the Vec3D class, you can use/abuse this class like any regular ruby class, it can be monkey-patched or refined like any other ruby class see a previous blog entry. Another interesting example is the MathTool module in particular the grid and mesh_grid methods, which demonstrates how to create a method that takes a ruby block (uses yield).

See also this jruby wiki entry.

Creating a maven wrapper

If you want to specify the a version of of maven used, or allow users to build your project without installing maven, you could add a maven wrapper, to do this run the following command in your project folder:-

mvn -N io.takari:maven:wrapper -Dmaven=3.8.3

Users are then able to build your project using the local maven wrapper command mvnw on unix based systems or mvnw.cmd on windows. In practice you will probably create a Rakefile at this stage, which will use the wrapper command to execute maven tasks in order. See for example Rakefile for JRubyArt.