Why is it almost routine, whenever anyone looks for advice on this
Forum, to be advised to use things like RVM and Bundler (apparently
there is now even a JBundler).
These things may be useful for MRI Ruby (RVM certainly is) but JRuby
doesn’t need them.
As far as I can see the simplest way to use JRuby is to download the zip
file with your preferred version and extract it into the directory where
you will build your project. Then create a short shell script or batch
file that will (a) add the JRuby /bin directory to the PATH and (b) open
a terminal at the project directory.
From that point on if you add gems (the usual way with gem install XXX)
they will be stored within the project. You can create a sub-directory
for jars to keep things tidy (perhaps /lib) and include them with
“require ‘/lib/xxx.jar’”
Everything is within the project directory and nothing can be mixed up
with any other project.
And if you want to run a copy of your project on another PC all you have
to do is copy the project directory and all its contents. The only thing
needed on the other PC is the JVM.
I can’t understand why people spend dozens or hundreds of hours creating
something like Bundler (or JBundler) when a half dozen hours writing an
explanation of what needs to be done and how to do it would be a lot
“cheaper” in programmer-hours and more useful because then the users
would actually learn something rather than blindly following “black box”
instructions.
From that point on if you add gems (the usual way with gem install XXX)
they will be stored within the project. You can create a sub-directory
for jars to keep things tidy (perhaps /lib) and include them with
“require ‘/lib/xxx.jar’”
It really depends on your personal needs.
If you need to have some copy-pastable deployment, then either using
bundler’s cache or your system (called “vendoring” sometimes) makes
sense.
I have some oldish JRuby 1.4 deployments where I do vendor gems manually
and it works perfectly well.
Now if this is some software that you plan to update/maintain regularly,
Bundler helps to make sure you’ll just have to update the number, which
saves time (and I do that mostly now).
In our projects we do exactly what your say, and even more: We check
the java and JRuby directories into version control, including the
installed gems. That way you only need to check out the project, and
you are good to go.
It ensures all developers have the same version of everything, and that
production is identical to development and test.
We sometimes wonder if we should change our practice, but regularly
decide to keep the current setup.
Interesting replies. It must be fun managing a project with so many JARs
as Kristian has. But I suspect that is not a typical situation, and
certainly not for a newcomer to JRuby.
People obviously have systems that work for themselves but it would
surely be very useful to have guidelines on the JRuby website for a
simple and transparent system that makes the best use of JRuby’s
strengths - at least for newcomers or new projects.
It seems to me JRuby can greatly simplify Ruby program development and
that opportunity is being ignored by a slavish adherence to MRI Ruby
practices.
To me, the ideal way to handle this is the way it’s done by Gradle.
Instead of checking in the entire runtime environment, you simple check
in
scripts that are smart enough to download and install the runtime you
need.
Seems like the best of both worlds, you get the safety of everyone
using
the exact version of the software you want, but you don’t have to
check
in entire runtimes in to SCM.
We use this on several projects and I love it. Wouldn’t ever want to do
it
differently now.