I'm trying to get jruby building in eclipse so I can use the debugger to investigate an issue in jruby's java code. I'm having
trouble getting the annotations processed correctly.
Caveat: I don't have much experience with annotations ...
Right now the compiler is set to JDK 1.5 and I've added the following jars to
the classpath for building:
build_lib/junit-4.7.jar
build_lib/livetribe-jsr223-2.0.6.jar
I've also enabled project-specific Annotation processing and set the generated
source directory to src_gen.
In the project settings for Annotation Processing/Factory Path I added the
build_lib/apt-mirror-api.jar.
I'm generating lots of code in src_gen/ but Eclipse reports the code has errors
like:
"The declared package org.jruby.gen does not match the expected package"
The generated class file output into src_gen is flat -- it should probably be in a dir structure that maps to the package
structure. I haven't set any annotation processor options in eclipse yet ... perhaps there is an option for generating the code
into the proper package dir structure?
I realize I also don't understand the compile-annotation-binder ant task which
has javac compile the following:
org/jruby/anno/FrameField.java
org/jruby/anno/AnnotationBinder.java
org/jruby/anno/JRubyMethod.java
org/jruby/anno/FrameField.java
org/jruby/CompatVersion.java
org/jruby/runtime/Visibility.java
org/jruby/util/CodegenUtils.java
Is this creating a new annotation factory?
How can this be represented in Eclipse?
There's also the _gmc_internal_ ant task which generates invokers and compiles
populators -- ho should this be integrated.
I can use Eclipse's external tool builder to use ant to compile JRuby but I'm
looking for something faster.
I've added this class to org.jruby.embed which I use with an Eclipse launcher that passes the selected file as the argument.
This lets me select a ruby file and run it in the Java perspective -- which means I can set a breakpoint somehere in JRuby's
java code, launch JRuby setup to run the ruby code with the Java debugger. Perhaps there's an easier way?
$ cat src/org/jruby/embed/JRubyRunner.java
package org.jruby.embed;
import java.util.ArrayList;
import java.util.List;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import org.jruby.Ruby;
import org.jruby.javasupport.JavaEmbedUtils;
import org.jruby.RubyInstanceConfig;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.builtin.IRubyObject;
/**
* Runs a ruby script passed in as the first program argument in JRuby
*/
public class JRubyRunner {
private Ruby runtime;
public JRubyRunner(String args[]) {
final RubyInstanceConfig config = new RubyInstanceConfig();
config.setObjectSpaceEnabled(false);
String jRubyHome = config.getCurrentDirectory();
config.setJRubyHome(jRubyHome);
List<String> loadPaths = new ArrayList<String>();
loadPaths.add(jRubyHome + "/lib/ruby/site_ruby/1.8");
loadPaths.add(jRubyHome + "/lib/ruby/site_ruby");
loadPaths.add(jRubyHome + "/lib/ruby/1.8");
runtime = JavaEmbedUtils.initialize(loadPaths, config);
IRubyObject rubyObject =
JavaUtil.convertJavaToUsableRubyObject(runtime, this);
runtime.defineGlobalConstant("JRUBY_APPLICATION", rubyObject);
IRubyObject mainClass = JavaUtil.convertJavaToUsableRubyObject(runtime,
args[0]);
runtime.defineGlobalConstant("JRUBY_MAIN_CLASS", mainClass);
try {
BufferedInputStream code = new BufferedInputStream(new
FileInputStream(args[0]));
runtime.runFromMain(code, args[0]);
} catch (IOException e) {
System.err.println("Error: " + e.getCause());
}
}
static public void main(String args[]) {
JRubyRunner launcher = new JRubyRunner(args);
}
}
[
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email