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

27th
May 2015
Eugen Martynov
@emartynov
May 27 2015 14:23
Hi guys
I'm trying to run ruby script frmo gradle
*from
and having issues
Here is start of ruby script:

!/usr/bin/ruby

require 'rubygems'
require 'fileutils'
require 'roo'
gradle file is basically copy from repo redame
*readme
I also added unpackGems task
When I run it with next line: gradle jrubyPrepare runLocalizationScript
Ruby can not find Roo
Aha
I was able to run it
I should run unpackGems custom task
Eugen Martynov
@emartynov
May 27 2015 14:29
and also provide gemWorkDir for run task
Thanks you!
one more thing I noticed sometimes gems dependency is too slow
Schalk W. Cronjé
@ysb33r
May 27 2015 14:29
jrubyPrepareGems usually do that
Eugen Martynov
@emartynov
May 27 2015 14:29
Thanks
looks like it was not doing it correctly
Schalk W. Cronjé
@ysb33r
May 27 2015 14:29
torquebox is a bit slow
Eugen Martynov
@emartynov
May 27 2015 14:30
let me check dependencies from gradle
today midday in Western Europe it was super slow
Christian Meier
@mkristian
May 27 2015 14:31
actually the torquebox server was DOS'ed not sure if things are already back to normal now
Schalk W. Cronjé
@ysb33r
May 27 2015 14:32
I have to wonder why services like torquebox get DDoS’d. What have to ever done to the world that is bad.
Christian Meier
@mkristian
May 27 2015 14:33
actually just got the notice that it is back to normal now. not sure what such a situation does to the cache gradle has.
Schalk W. Cronjé
@ysb33r
May 27 2015 14:34
it should nto affect it, but if you are unsure run gradle with —refresh-dependencies
Eugen Martynov
@emartynov
May 27 2015 14:36
gradle jrubyPrepareGems runLocalizationScript
last one is my task that extends JRubyExec
it can not find "roo"
Christian Meier
@mkristian
May 27 2015 14:37
@ysb33r yesterday I had quite some trouble to get local builds from gradle plugins to be used. in between I had the feeling deleting .gradle from my project directory helped - but in the end was not sure
Eugen Martynov
@emartynov
May 27 2015 14:38
how to trace/debug issue
Christian Meier
@mkristian
May 27 2015 14:38
@emartynov could you just add p $GEM_PATH; p $LOAD_PATH at the second line of your script ?
Eugen Martynov
@emartynov
May 27 2015 14:38
to check that prepare gems are sourcing gems correctly
Christian Meier
@mkristian
May 27 2015 14:39
to see if the script runs in the right context these two variables a good overview
Eugen Martynov
@emartynov
May 27 2015 14:40
sorry, I'm not so experienced, p is parameter for gradle or ruby?
ah
probably ruby script
moment
Christian Meier
@mkristian
May 27 2015 14:40
'p' prints to console
ruby
just in the line after !/usr/bin/ruby
Eugen Martynov
@emartynov
May 27 2015 14:42
yup
should I just paste it here?
Christian Meier
@mkristian
May 27 2015 14:43
yes - just go ahead
Eugen Martynov
@emartynov
May 27 2015 14:43
"file:/Users/310198568/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.20/f784b3d9d760b80b2f9d78ede80ee1d8d85e786/jruby-complete-1.7.20.jar!/META-INF/jruby.home/lib/ruby/1.9/site_ruby", "file:/Users/310198568/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.20/f784b3d9d760b80b2f9d78ede80ee1d8d85e786/jruby-complete-1.7.20.jar!/META-INF/jruby.home/lib/ruby/shared";, "file:/Users/310198568/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.20/f784b3d9d760b80b2f9d78ede80ee1d8d85e786/jruby-complete-1.7.20.jar!/META-INF/jruby.home/lib/ruby/1.9";
Working directory: /Users/310198568/Development/source/Philips/ugrow-android/Source/uGrow/app Command: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /Users/310198568/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.20/f784b3d9d760b80b2f9d78ede80ee1d8d85e786/jruby-complete-1.7.20.jar:/Users/310198568/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.50/be504b4901d75cbe129a178f5830e6c358ec214c/bcprov-jdk15on-1.50.jar org.jruby.Main /Users/310198568/Development/source/Philips/ugrow-android/Source/uGrow/app/TranslationScripts/010_parse_csv_to_stringsfile.rb
Christian Meier
@mkristian
May 27 2015 14:46
so the GEM_PATH output clearly shows that the installed gems are not that path
Eugen Martynov
@emartynov
May 27 2015 14:46
ok
task runLocalizationScript( type: JRubyExec ) {
//gemWorkDir buildDir
script 'TranslationScripts/010_parse_csv_to_stringsfile.rb'
}
here is my task, sorry for comments, work is till in progress
I'm using 0.1.17 version
Christian Meier
@mkristian
May 27 2015 14:47
which version of the plugin are you using ?
:)
Eugen Martynov
@emartynov
May 27 2015 14:47
gradle 2.4
Christian Meier
@mkristian
May 27 2015 14:47
let me see if I can reproduce the problem here.
Eugen Martynov
@emartynov
May 27 2015 14:48
O can provide you gradle file
*I
to speed up
Christian Meier
@mkristian
May 27 2015 14:48
yes
Eugen Martynov
@emartynov
May 27 2015 14:48

import com.github.jrubygradle.JRubyExec
import com.github.jrubygradle.JRubyPrepareGems

buildscript {
repositories {
jcenter()
}

dependencies {
    classpath 'com.github.ben-manes:gradle-versions-plugin:0.9'
    classpath 'com.github.jruby-gradle:jruby-gradle-plugin:0.1.17'
}

}
apply plugin: 'com.github.jruby-gradle.base'
apply plugin: 'com.github.ben-manes.versions'

dependencies{
gems 'rubygems:roo:2.0.0'
}

task unpackGems( type : JRubyPrepareGems ) {

// Parent directory for unpacking GEMs.
// Gems will end up in a subdirectory 'gems/GemName-GemVersion'
outputDir buildDir

// Add one or more gems
// Can be String(s), File(s), FileCollection(s) or Configuration(s)
gems project.configurations.gems

}

task runLocalizationScript( type: JRubyExec ) {
//gemWorkDir buildDir
script 'TranslationScripts/010_parse_csv_to_stringsfile.rb'
}

task checkRubyVersionCommandLine(type: Exec) {
commandLine 'ruby', 'TranslationScripts/010_parse_csv_to_stringsfile.rb'
}

I run it like "gradle jrubyPrepareGems runLocalizationScript "
sorry again for mess
I'm working with script that was originally written by Indian part of team
that is why task names do not reflect what they are doing
Schalk W. Cronjé
@ysb33r
May 27 2015 14:53
Ignore what I just said...
Eugen Martynov
@emartynov
May 27 2015 14:55
why
it worked with this change
Schalk W. Cronjé
@ysb33r
May 27 2015 14:56
because it was not quite the right thing to do
but if it works for now, good.
jrubyExec is really used to load the correct jruby-complete JAR.
by default a JRubyExec instance will use the GEMs that are unpacked by the default jrubyPrepareGems task.
Eugen Martynov
@emartynov
May 27 2015 14:58
Thanks a lot
it works now
I will clean up script and write back to India :)
Schalk W. Cronjé
@ysb33r
May 27 2015 14:58
If you supplied your own JRubyPrepareGems task, it will unpack to a different folder.
Remember to ask then if they went through the trouble to read the plugin’s README… :)
Eugen Martynov
@emartynov
May 27 2015 15:00
I went myself several times
So na blames here for them
Schalk W. Cronjé
@ysb33r
May 27 2015 15:03
Having just read the README myself - it does actually state that

JRubyExec - Task for Executing a Ruby Script

In a similar vein to JavaExec and RhinoShellExec, the JRubyExec allows for Ruby scripts to be executed
in a Gradle script using JRuby.
import com.github.jrubygradle.JRubyExec

dependencies {
    jrubyExec 'rubygems:credit_card_validator:1.2.0'
}

task runMyScript( type: JRubyExec ) {
    script 'scripts/runme.rb'
    scriptArgs '-x', '-y'
}
I was just going through the code to see whether the README is still up to date with the code.
So according to the README, jrubyExec is the default configuration used for JRubyExec tasks, and gems is the configuration used for building JRuby stuff.
IN any case I need to check. Thx for the feedback.
Christian Meier
@mkristian
May 27 2015 15:09
@ysb33r I had the feeling that the gems is only used when building the jruby-jar ?!
Schalk W. Cronjé
@ysb33r
May 27 2015 15:13
@mkristian In asciidoctorj it is used to download all the dependencies to pack into the jar. The jruby-jar plugin is not used in that project.
Christian Meier
@mkristian
May 27 2015 15:14
ok - it has some other use cases ;)
Christian Meier
@mkristian
May 27 2015 18:56
@ysb33r I have a new PR to look at - whenever you find some time for it: jruby-gradle/jruby-gradle-jar-plugin#52
Schalk W. Cronjé
@ysb33r
May 27 2015 18:58
Ok
let me just merge that diff to a local tree quickly and have a look
Schalk W. Cronjé
@ysb33r
May 27 2015 19:14
I hope you understand the big comment I left.
I would not merge that as it is.
Christian Meier
@mkristian
May 27 2015 19:15
don't I will ask if needed
R. Tyler Croy
@rtyler
May 27 2015 19:15
@ysb33r I cannot yet announce any specifics publicly yet, but I can give you notice that I will be in Berlin, and hopefully @mkristian will too, at the end of July/beginning of august
Schalk W. Cronjé
@ysb33r
May 27 2015 19:16
OK.
R. Tyler Croy
@rtyler
May 27 2015 19:16
orient your scheduled accordingly if possible :D
Schalk W. Cronjé
@ysb33r
May 27 2015 19:16
31 Jul?
R. Tyler Croy
@rtyler
May 27 2015 19:16
yes
@mkristian and I need to work out some travel logistics still with our employer I believe
Schalk W. Cronjé
@ysb33r
May 27 2015 19:17
I should be able to make a weekend of it.
R. Tyler Croy
@rtyler
May 27 2015 19:18
devoxx is in the spring right/
Christian Meier
@mkristian
May 27 2015 19:18
@ysb33r question: how to add functionality to a Jar task or Bundle task without that configurator ? looking at the JRubyJar own its own I understand your comment and makes sense.
I am also OK to say we do not want the Jar task with extra jruby config - all I would miss is build OSGi bundles with embedded gems
Schalk W. Cronjé
@ysb33r
May 27 2015 19:20
@mkristian you can add all of those methods and properties to the JRubyJar class. They will not pollute the Jar class.
copy-paste solutionm :) (Or if you have IntelliJ then Refactor-Move can help a lot).
@rtyler no idea
Christian Meier
@mkristian
May 27 2015 19:22
@ysb33r ok - let's keep it simple until we really need something else. copy-and-paste is probably faster then installing IntelliJ (one day I will install it . . . )
Schalk W. Cronjé
@ysb33r
May 27 2015 19:25
sure.
Once you have moved them, you can also annotate the getters. IN that way you can take advantage of Gradle property caching.
@mkristian I think we can probably simplify it too once the code has moved.
Schalk W. Cronjé
@ysb33r
May 27 2015 19:38
@rtyler I reckon I can make it to Berlin on the Thursday evening, and I might then go to Hannover on the Saturday morning.
R. Tyler Croy
@rtyler
May 27 2015 19:38
FYI, eurucamp is in Potsdam
Schalk W. Cronjé
@ysb33r
May 27 2015 19:39
For me Potsdam & Berlin is the same thing :)
Christian Meier
@mkristian
May 27 2015 19:39
for me too
R. Tyler Croy
@rtyler
May 27 2015 19:40
if you land at Tegel you will soon find out that they are much different :P
Schalk W. Cronjé
@ysb33r
May 27 2015 19:41
LOL. I’ve been before, but I used the other airport (cannot remember its name). WIll be going via Tegel this time.
R. Tyler Croy
@rtyler
May 27 2015 19:41
scho"nefeld
Schalk W. Cronjé
@ysb33r
May 27 2015 19:41
that’s the one
R. Tyler Croy
@rtyler
May 27 2015 19:41
they were building a new one, but I think they gave up
the shitty thing about tegel is you have to take a bus to get to fucking anywhere
the whole thing feels like a bus station as a result
rtyler @rtyler cannot wait to return to Germany
Schalk W. Cronjé
@ysb33r
May 27 2015 19:46
because “German beer is chemical free and German tarts are wunderschön” ?
R. Tyler Croy
@rtyler
May 27 2015 19:46
heh, die Chemie macht alles scheisse!
no, because it's one of my two adopted homelands
Northern California being the other :)
Schalk W. Cronjé
@ysb33r
May 27 2015 19:47
(I would be surprised if you guessed which song that line came from).
R. Tyler Croy
@rtyler
May 27 2015 19:48
I would too!
Schalk W. Cronjé
@ysb33r
May 27 2015 19:48
Way Aye Man - Mark Knopfler
rtyler @rtyler muss sein Deutsch u"ben
Schalk W. Cronjé
@ysb33r
May 27 2015 19:56
Well JFK went to Germany and said ‘ Ich bin ein Berliner’, which is at least better than Napoleon who tried to impress the Dutch by trying to say ‘Ik is julle koning’ (I am your king), but instead said ‘Ik is julle konijn’ (I am your bunny),
R. Tyler Croy
@rtyler
May 27 2015 19:57
heh
Schalk W. Cronjé
@ysb33r
May 27 2015 19:57
so I’ve been told in some Amsterdam museum
Christian Meier
@mkristian
May 27 2015 19:57
@ysb33r if I put everything inside the JRubyJar task then I do not have a nested jruby{} closure anymore, everything goes into top level. or is there way to have such jruby{} even then ?
Schalk W. Cronjé
@ysb33r
May 27 2015 19:58
yes, you can, but do you actually still need it?
Christian Meier
@mkristian
May 27 2015 19:59
not really but it break backwards compability
Schalk W. Cronjé
@ysb33r
May 27 2015 19:59
unless you want it to look like the Jar task.
Christian Meier
@mkristian
May 27 2015 19:59
so I leave jruby{} out ?
Schalk W. Cronjé
@ysb33r
May 27 2015 20:02
@mkristian I would suggest doing the following:
void jruby(Closure cfg) {
 project.logger.info “It is no longer necessary to use the jruby closure on a JRubyJar task”. 
  def cl = cfg.clone()
  cl.delegate = this
  cl.call()
}
That can allow it to call back to the main task.
Christian Meier
@mkristian
May 27 2015 20:03
cool - sure
torquebox proxy is still not reachable from travis :P
R. Tyler Croy
@rtyler
May 27 2015 20:04
_<
Schalk W. Cronjé
@ysb33r
May 27 2015 20:05
What you guys can do internally, if you have an Artifactory instance is to proxy the public repos. You can then use an initscript with gradle to speed up development on OSS project, without breaking the project
speed up downloading, I meant
R. Tyler Croy
@rtyler
May 27 2015 20:06
we operate an internal rubygems-servlet server which proxies our Artifactory instane
Christian Meier
@mkristian
May 27 2015 20:07
locally I run the same rubygems-servlet but on travis I have no way to workaround - right now
all but rspec gems I need are on maven-central as well, but I just wanted to get travis green to move on . . .
Schalk W. Cronjé
@ysb33r
May 27 2015 20:08

Your initscript:


allprojects {
  buildscript {
     repositories {
    maven {
      url ‘http://our/local/m2'
   }
  }
   repositories {
    maven {
      url ‘http://our/local/m2'
   }
 }
}

Then run ./gradlew —initscript /path/to/init.gradle …….

Yip, you’re a bit screwed on Travis
Christian Meier
@mkristian
May 27 2015 20:09
ah - that is also a good place to at mavenLocal() without changing the actual build.gradle
Schalk W. Cronjé
@ysb33r
May 27 2015 20:11
yip, and those repoS will get loaded before the ones in the script, which mean they get checked first.
Christian Meier
@mkristian
May 27 2015 20:30
I moved things and now back to those jrubyJar dependencies
Schalk W. Cronjé
@ysb33r
May 27 2015 20:31
@mkristian Are you saying you’re having a problem with deps?
Christian Meier
@mkristian
May 27 2015 20:31
I can have jrubyJar { ....} and a task runnable( type: JRubyJar ) {...}
when I configure those dependencies { jrubyJar group: 'org.jruby', name: 'jruby-complete', version: project.jruby.defaultVersion } from which JRubyJar task do I take the version property ?
Schalk W. Cronjé
@ysb33r
May 27 2015 20:35
That is back-to-front thinking. The question that you are trying to get answered is. How do I configure which jruby-complete Jar will be consumed by my task (especially if more than one task exists).
Christian Meier
@mkristian
May 27 2015 20:35
yes probably close
Schalk W. Cronjé
@ysb33r
May 27 2015 20:36
The answer is that ‘basealready creates a configuration which sets the dependency viaproject.ruby.defaultVersion`. All that has to happen in your task is to taek care of that configuration.
it is called jrubyEmbeds I believe
Christian Meier
@mkristian
May 27 2015 20:37
I never understood where this jrubyEmbeds get used - still do not see it
Schalk W. Cronjé
@ysb33r
May 27 2015 20:38
This, exactly this situation, is what it was designed for.
The name still comes from @rtyler ’s original plugin code
THe thing is that we spent so much time getting JRubyExec right, is that this has really gone under the radar.
but looking at the code now, I think, it is no longer populated.
Christian Meier
@mkristian
May 27 2015 20:42
only WarblerBootstrap does use it
Schalk W. Cronjé
@ysb33r
May 27 2015 20:43
right, I see.
ysb33r @ysb33r scratches around
Schalk W. Cronjé
@ysb33r
May 27 2015 20:45
But we no longer use warbler-bootstrap anyway. Right?
Christian Meier
@mkristian
May 27 2015 20:46
well, I did not look at the warbler plugin much. but no we do not need it for jar plugin
Schalk W. Cronjé
@ysb33r
May 27 2015 20:47
Right, let’s assume for a moment that changes to base is out of bounds.
The solution to get to, is to add project.ruby.defaultVersion to a configuration. Then the JRubyJar tasks can use that.
Christian Meier
@mkristian
May 27 2015 20:49
this means one defaultVersion for all JRubyJar tasks - correct ?
Schalk W. Cronjé
@ysb33r
May 27 2015 20:50
It would make sense for most projects (we can add something to the task to add flexibility later).
I see you also have a jrubyJar configuration.
Christian Meier
@mkristian
May 27 2015 20:50
yes, exactly and I learn gradle step by step ;)
Schalk W. Cronjé
@ysb33r
May 27 2015 20:51
By which you already have the afterEvaluate hook too.
Christian Meier
@mkristian
May 27 2015 20:51
yes, that is good enough
Schalk W. Cronjé
@ysb33r
May 27 2015 20:52
the fancy trick is to create a configuration for every JRubyJar task which has the same name as the task - I can point you to an example of that - but let’s just fix this one thing.
By changing addAfterEvaluateHooks, you can make it read the config from jrubyJar task instance and then add the correct version for jruby-mains
(later you can make it iterate over all the JRubyJar instances and set dependencies for each in a similar way - there is a tasks.withType for that).
This message was deleted
Christian Meier
@mkristian
May 27 2015 20:56
any ways getting tired and problems keeping my eyes open . . . will update the PR tomorrow morning. already copied the configurator + tests and deleted it. will see to the properties and jrubyVersion (using the project.jruby.defaultVersion) but will stick to jrubyJar for now
Schalk W. Cronjé
@ysb33r
May 27 2015 20:57
cool. We can look at it tomorrow evening. I might have some time.
Christian Meier
@mkristian
May 27 2015 20:58
any ways you gave loads of input and I need to play around with this a bit . . . thanx
Schalk W. Cronjé
@ysb33r
May 27 2015 20:59
:) I can get back to my asciidoctor->leanpub converter now