Skip to content

Instantly share code, notes, and snippets.

@gdinwiddie
Created February 9, 2012 20:44
Show Gist options
  • Save gdinwiddie/1782945 to your computer and use it in GitHub Desktop.
Save gdinwiddie/1782945 to your computer and use it in GitHub Desktop.
ant target for running cucumber
cuke4:
[java] Gem::LoadError: Could not find RubyGem cucumber (>= 0)
[java]
[java] report_activate_error at /Users/gdinwiddie/jruby-1.6.2/lib/ruby/site_ruby/1.8/rubygems.rb:861
[java] activate at /Users/gdinwiddie/jruby-1.6.2/lib/ruby/site_ruby/1.8/rubygems.rb:255
[java] gem at /Users/gdinwiddie/jruby-1.6.2/lib/ruby/site_ruby/1.8/rubygems.rb:1215
[java] (root) at /Users/gdinwiddie/jruby-1.6.2/bin/cucumber:18
<target name="cuke4" description="Run the cucumber tests">
<java classname="org.jruby.Main" fork="true" failonerror="true">
<classpath>
<fileset dir="${jruby.home}/lib">
<include name="*.jar"/><!-- finds 'jruby' -->
<include name="**/*.rb" /><!-- doesn't help -->
</fileset>
<pathelement location="${jruby.home}/lib/ruby/site_ruby/1.8"/><!-- finds 'rubygems' -->
<pathelement location="${jruby.home}/lib/ruby/gems/**/lib"/><!-- doesn't help -->
<pathelement location="${jruby.home}/lib/ruby/gems/1.8/gems/cucumber-1.0.0/lib"/><!-- doesn't help -->
<pathelement location="${jruby.home}/lib/ruby/gems/1.8/gems"/><!-- doesn't help -->
<pathelement location="${jruby.home}/lib/ruby/gems/1.8"/><!-- doesn't help -->
<pathelement location="${jruby.home}/lib"/><!-- doesn't help -->
</classpath>
<arg value="-S"/>
<arg value="${jruby.home}/bin/cucumber"/>
</java>
</target>
gempath:
[java] NameError: uninitialized constant Gem
[java] const_missing at org/jruby/RubyModule.java:2569
[java] (root) at -e:1
<target name="gempath" description="display the gem path">
<java classname="org.jruby.Main" fork="true" failonerror="true">
<classpath>
<fileset dir="${jruby.home}/lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${jruby.home}/lib/ruby/site_ruby/1.8"/><!-- finds 'rubygems' -->
</classpath>
<arg value="-e"/>
<arg value="puts Gem.path"/>
</java>
</target>
@gdinwiddie
Copy link
Author

Note: I started with the simple and obvious:

<target name="cuke1" description="Run the cucumber tests">
    <exec executable="cucumber" >
        <env key="PATH" path="${jruby.home}/bin" />
    </exec>
</target>

but that gives me "java.lang.ClassNotFoundException: org.jruby.Main"

@gdinwiddie
Copy link
Author

I went back to the simple and obvious start, and, once I found the key to reading the OS environment variables, got it working with the following:

<target name="cucumber" description="Run the cucumber tests">
    <property environment="env" />
    <exec executable="cucumber" >
        <env key="PATH" path="${env.PATH}:${jruby.home}/bin" />
        <env key="CLASSPATH" file="${jruby.home}/lib/jruby.jar" />
    </exec>
</target>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment