Search code examples
javascalajarjruby

Package Ruby Library (permailer) as .jar (using JRuby)


Essentially, we need to use Premailer (https://github.com/premailer/premailer) as part of our Scala backend, however since it is coded in Ruby we need to use something likeJRuby so we can execute it on the JVM.

Ideally we would want to create a separate clean .jar which just contains JRuby (either as a dependency or in the actual JAR itself), Premailer plus a thin Java wrapper that would let us call the Premailer API in Java (and hence in Scala).

The idea is then we would obviously just include the premailer jar as a dependency in our Scala backend through SBT and just call the thin Java wrapper. Does anyone know if there is a tool that lets you do this, or if there is a tutorial on how to do this?

EDIT: It appears a java wrapper already exists, it is here https://github.com/r-shah/java-premailer-wrapper, so it appears its now just a question of packaging it properly


Solution

  • seems like the work needed to create an interface (so that you abstract away from JRuby's Java/embed APIs) is done - as you've find out.

    the project already packages using Maven including the JRuby jar and the ruby dependencies for the premailer gem.

    while those are not to be found (on Maven Central) they should work as they are auto-generated from https://rubygems.org assets (the rubygems-proxy.torquebox.org does that) ... thus mvn install locally and you should be all set