These are chat archives for jruby-gradle/jruby-gradle-plugin

12th
Nov 2015
Ernest Bursa
@swistaczek
Nov 12 2015 06:12
hi @rtyler , what is best convention for aliasing jrubyJar task in gradle to 'build' task?
Ernest Bursa
@swistaczek
Nov 12 2015 06:28
@rtyler please also help me with specifing JAR dependencies inside my ruby code, I would like to include for example some libs to my project, should I use java plugin and 'compile' function in depdencency block?
Ernest Bursa
@swistaczek
Nov 12 2015 10:20
Does anybody know how to do something like $:.unshift(File.expand_path('./../../lib', __FILE__)) inside JAR?
Christian Meier
@mkristian
Nov 12 2015 10:20
which jruby version ? should work :)
Ernest Bursa
@swistaczek
Nov 12 2015 10:21
I am using latest jruby-gradle
expanded path looks like uri:classloader:/lib inside java runtime
but after I extracted this Jar I cant see 'my code' under ./lib
Christian Meier
@mkristian
Nov 12 2015 10:22
what is __FILE__ ?
Ernest Bursa
@swistaczek
Nov 12 2015 10:24
@mkristian , strange - I cant see any other files than 'boot' specified as initScript
should I define somewhare list of files that should be included in jar?
(I mean somewhere in build.gradle)
Christian Meier
@mkristian
Nov 12 2015 10:25
jrubyJar { from(".") { includes "lib/**"}} or something
Ernest Bursa
@swistaczek
Nov 12 2015 10:25
o, it looks essential :)
I think readme miss any information about this required include
Christian Meier
@mkristian
Nov 12 2015 10:28
@swistaczek please file an issue so we get this into the readme
especially without the from(".") you get all kind of unexpected jars :)
Ernest Bursa
@swistaczek
Nov 12 2015 10:29
what do you mean by unexpected jars?
Christian Meier
@mkristian
Nov 12 2015 10:30
wrong english. the jars will miss essential parts like the embedded classes from jruby itself
as they are not inside a lib directory
only with the from you give the include a directory context
Ernest Bursa
@swistaczek
Nov 12 2015 10:32
> No signature of method: org.gradle.api.internal.file.copy.CopySpecWrapper_Decorated.includes() is applicable for argument types: (java.lang.String) values: [lib/**] Possible solutions: include([Ljava.lang.String;), include(groovy.lang.Closure), include(java.lang.Iterable), include(org.gradle.api.specs.Spec), getIncludes(), exclude([Ljava.lang.String;)
Schalk W. Cronjé
@ysb33r
Nov 12 2015 10:32
@swistaczek If you don’t have a build task then do the following
task build { finalizedBy ‘jrubyJar’ }
Christian Meier
@mkristian
Nov 12 2015 10:32
@swistaczek take include 'lib/**' and not includes
Ernest Bursa
@swistaczek
Nov 12 2015 10:33
ok, which plugins provide this DSL?
Christian Meier
@mkristian
Nov 12 2015 10:33
the regular jar tasks from the java plugin
Ernest Bursa
@swistaczek
Nov 12 2015 10:36
thanks :)
What is your plans related to parsing internally rubygems to maven rather than using bundled web service?
Ernest Bursa
@swistaczek
Nov 12 2015 10:41
One more question, Is it possible to run for example script bundled inside JAR, for example rake?
Christian Meier
@mkristian
Nov 12 2015 10:41
@swistaczek do you mean get rid of the embedded jetty server ? without some changes to gradle core this is not possible to implement from plugin
Ernest Bursa
@swistaczek
Nov 12 2015 10:41
Warbler created some methods like this
I would like to call rake after I have bundled fat jar, without gradle
Christian Meier
@mkristian
Nov 12 2015 10:42
if you bundle rake gems then you can execute it with -S rake but only without initScript
Ernest Bursa
@swistaczek
Nov 12 2015 10:42
what you mean by without initScript?
which file in jruby-gradle make 'this routing' :)?
Christian Meier
@mkristian
Nov 12 2015 10:44
jruby-mains looks for jar-bootstrap.rb inside the jar if found it will pass all the ARGV to it. otherwise it will just execute jruby with the given ARGV
so any command dispatch wanted from your side goes into the initScript
Ernest Bursa
@swistaczek
Nov 12 2015 10:45
ok, so I could extend this bootstrap script as dispatcher or remove it
Christian Meier
@mkristian
Nov 12 2015 10:45
the bootstrap you only need if you want the jar to do something when there are no ARGV given
yes extend or remove it
Ernest Bursa
@swistaczek
Nov 12 2015 10:47
I also discovered that if I would like to run without gradle I should do something like this:
# encoding: utf-8
# Bootstrap environment for local runtime without gradle
vendored_gems = File.expand_path(File.dirname(__FILE__) + '../../../../build/dirinfo/jrubyJar/gems')
if File.exists?(vendored_gems)
  ENV['GEM_HOME'] = vendored_gems
  ENV['GEM_PATH'] = vendored_gems
end

vendored_jars = File.expand_path(File.dirname(__FILE__) + '../../../../build/dirinfo/jrubyJar/jars')
if File.exists?(vendored_jars)
  ENV['JARS_HOME'] = vendored_jars

  JBUNDLER_CLASSPATH = []
  Dir.glob("#{vendored_jars}/**/*").each do |file|
    JBUNDLER_CLASSPATH << file if File.file? file
  end
  JBUNDLER_CLASSPATH.each { |c| require c }
end
Is this correct?
Christian Meier
@mkristian
Nov 12 2015 10:49
run what without gradle ? the fat jar ? no not needed
Ernest Bursa
@swistaczek
Nov 12 2015 10:49
no, I would like to run it before bundling fat jar :)
so I can shorten the turnarround time while developing
Christian Meier
@mkristian
Nov 12 2015 10:50
jrubyExec will do all the magic for you
Ernest Bursa
@swistaczek
Nov 12 2015 10:50
are you sure?
Take a look at this:
[2] pry(main)> ENV['GEM_HOME']
=> "/Users/ernest.bursa/Projects/allegro/flp/taxonomy-discovery_tool/build/dirinfo/jrubyJar/gems"
[3] pry(main)> ENV['GEM_PATH']
=> "/Users/ernest.bursa/Projects/allegro/flp/taxonomy-discovery_tool/build/dirinfo/jrubyJar/gems"
[4] pry(main)> Faraday.method(:new).source_location
NameError: uninitialized constant Faraday
from org/jruby/RubyModule.java:3166:in `const_missing'
[5] pry(main)> require 'faraday'
=> true
[6] pry(main)> Faraday.method(:new).source_location
=> ["/Users/ernest.bursa/.rbenv/versions/jruby-9.0.1.0/lib/ruby/gems/shared/gems/faraday-0.9.1/lib/faraday.rb", 67]
I have bundled faraday inside (via deps in build.gradle) but it still uses the globally shared one.
Christian Meier
@mkristian
Nov 12 2015 10:52
this is run how ? can you give me the java execution command - should see it with gradle -i
Ernest Bursa
@swistaczek
Nov 12 2015 11:05
Executing with configuration: jrubyExec
Starting process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java''. Working directory: /Users/ernest.bursa/Projects/allegro/flp/taxonomy-discovery_tool Command: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -Duser.country=PL -Duser.language=pl -Duser.variant -cp /Users/ernest.bursa/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/9.0.1.0/523f0054455d85cdfc53af6eb8e925228feb9777/jruby-complete-9.0.1.0.jar org.jruby.Main -I /Users/ernest.bursa/Projects/allegro/flp/taxonomy-discovery_tool/build/tmp/jrubyExec/gems/jar-dependencies-0.1.15/lib -rjars/setup -S rake /Users/ernest.bursa/Projects/allegro/flp/taxonomy-discovery_tool/Rakefile console
rake aborted!
LoadError: no such file to load -- colorize
/Users/ernest.bursa/Projects/allegro/flp/taxonomy-discovery_tool/lib/taxonomy/boot.rb:3:in `<top>'
Christian Meier
@mkristian
Nov 12 2015 11:12
this looks like the dependencies for jrubyExec do not inherit your gems - gradlew dependencies will show.
Ernest Bursa
@swistaczek
Nov 12 2015 11:53
@mkristian do I need to repeat dependencies (the same) for jrubyJar and jrubyExec?
I would like to run full REPL for application env
Christian Meier
@mkristian
Nov 12 2015 11:55
no repeat but add jrubyExec.extendsFrom jrubyJar or so inside configuration
Ernest Bursa
@swistaczek
Nov 12 2015 11:56
great, thanks for hints ;)
Ernest Bursa
@swistaczek
Nov 12 2015 12:01
* What went wrong:
A problem occurred evaluating root project 'taxonomy-discovery_tool'.
> Could not find property 'jrubyExec' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@516592b1.
Ernest Bursa
@swistaczek
Nov 12 2015 12:15
@mkristian should I call this variable in other way?
R. Tyler Croy
@rtyler
Nov 12 2015 15:46
moin moin
looks like I've missed some fun
Ernest Bursa
@swistaczek
Nov 12 2015 19:09
Yeah, I think so :)
How should I reuse jrubyJar dependencies in jrubyExec ;)?
R. Tyler Croy
@rtyler
Nov 12 2015 19:31
oh man I have a ticket to describe that still
I need to get on the ball with some of my documentation tickets
@swistaczek the pattern that I've been using is putting all common dependencies in the gems configuration and then using configurations { jrubyJar.extendsFrom gems } etc
Blane Dabney
@raelik
Nov 12 2015 20:58
@rtyler That's what I've done as well
in my case, my only jrubyExec task is a spec runner, so I created a spec configuration just for it (with things like rspec, etc in it). That config extends my runtime configuration, which is where I put all my jar dependencies
Christian Meier
@mkristian
Nov 12 2015 21:09
there are no more .jrubydir files for /specifications/ and /gems/ which fails applications depending on it. actually on jruby-9k it only works since Gem::Specification.dirs still adds the my.jar!/specifications to the list.
see #258