-
-
Save sam/3708231 to your computer and use it in GitHub Desktop.
package org.foo; | |
public class Bar { | |
public static int baz() { | |
return 1; | |
} | |
} |
#!/usr/bin/env jruby | |
require "minitest/autorun" | |
describe org.foo.Bar do | |
describe "baz" do | |
it "must return 1" do | |
org.foo.Bar.baz.must_equal 1 | |
end | |
end | |
end |
Looking for alternatives, I could:
- Satisfy Dependency issues with a combination of JBundler and Bundler
- Compile with JRuby's built-in Ant support
- Package as normal with Rubygems
That means I'd be stuck using Rake, and I'd have at-least four files to define my build-process:
- project.gemspec
- Gemfile
- Jarfile
- Rakefile
I'd like to end up being able to make a Ruby script executable and just run a Listener on my tests/libs like this: https://github.com/sam/harbor/blob/master/test/watch.rb
Not really sure how that's going to work throwing Rake into the mix as a requirement. Not to mention Rake tends to just slow everything down IME.
Or I could:
- Specify my Ruby dependencies with Bundler
- Add my Java dependencies to a pom.xml
git add pom.xml
mvn dependency:copy-dependencies
mkdir jars
cp target/dependency/*.jar jars/
git add jars
- Use
JRuby::Ant
support to compile my Java code on-the-fly when harnessing my tests and packaging a Gem
Then in my Ruby scripts, after bundler/setup
I can just: Dir["jars/*.jar"].each { |jar| require jar }
A standard rake-task could handle actually releasing a gem of the library I'm developing by adding the jars to the FileList
.
It's //so// dirty, but it'd work, and I'm drawing a blank thinking of anything better.
Buildr is so close... but it's just much too huge of a project to fix, and the internals are just mind-bending since it's built on top of Rake. Plus it wouldn't let me setup a class-path and ensure the build as a pre-requisite outside of Rake, and I much prefer directly executable test/spec-files.
As an example of the above mention of direct execution, you can:
- Clone this project: https://github.com/sam/blog
./install-dependencies
bundle install
test/watch.rb
Which is basically the setup I mention above, except using Maven instead of Ant to compile. (Only because I assume using a non-Maven source tree structure, and custom build-dir would be a little simpler with Ant?)
The goal is to find a packaging tool for creating mixed Java/Ruby projects with JRuby. Something that will:
Buildr will download your dependencies (both Gems and JARS!), compile your Java (if you use nasty Maven paths everywhere), set your class-path, and execute your Ruby for testing, but it doesn't support Minitest (and adding your own TestFramework is incredibly complicated).
That said, Buildr comes to closest to a working solution I've tried. It has 1.9.3 warnings (RbConfig), and seems only mildly supported though.
Honestly. How are people doing this? Mixed Java/Ruby projects would seem like JRuby's #1 killer feature, but there's so little guidance out there on how to create a SANE build-process. (Or I'm just looking at all the wrong places.)