You do not know exactly how you want to use your (J) Ruby code, so I will give one example of many possible approaches.
Letβs create a directory structure and put Java and Ruby files in it,
.
βββ buildfile
βββ src
βββ main
βββ java
β βββ Foo.java
βββ ruby
βββ app.rb
with the content Foo.javaas follows:
public class Foo {
public int bar() {
return 42;
}
}
and a simple app.rbscript run,
puts "Foo.bar is #{Java::Foo.new.bar}"
Yours buildfilewill look something like this:
VERSION_NUMBER = "1.0.0"
repositories.remote << "http://www.ibiblio.org/maven2/"
JRUBY = "org.jruby:jruby-complete:jar:1.6.3"
define "ruby-example" do
project.version = VERSION_NUMBER
project.group = "org.example"
run.with JRUBY
run.using :main => ['org.jruby.Main', _(:src, :main, :ruby, "app.rb")]
end
(task rundocumented at http://buildr.apache.org/more_stuff.html#run )
and now you can run your application by typing
$ buildr run
and get the following output:
$ buildr run
(in /home/boisvert/tmp/ruby-example, development)
Foo.bar is 42
Completed in 1.884s