Created
September 12, 2012 17:10
-
-
Save sam/3708231 to your computer and use it in GitHub Desktop.
Simplest possible JRuby+Java test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.foo; | |
public class Bar { | |
public static int baz() { | |
return 1; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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?)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or I could:
git add pom.xml
mvn dependency:copy-dependencies
mkdir jars
cp target/dependency/*.jar jars/
git add jars
JRuby::Ant
support to compile my Java code on-the-fly when harnessing my tests and packaging a GemThen 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.