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

10th
May 2017
amiracam
@amiracam
May 10 2017 10:03
@raelik I"m specifying both
amiracam
@amiracam
May 10 2017 10:27
I've tried it just specifying the jar plugin, but I just realized that although the gems show up under the IDEA External Libraries folder that they are not actually being installed in the specific RVM gemset , I bumped into this because yesterday I grabbed jruby-9.1.8.0 and when I go to the Gem Manager for IDEA they do not show up there even though I have repeatedly re-imported the Gradle project which suffices for other Gradle based projects i.e. Groovy, Java, Kotlin, again perhaps a disconnect with IDEA . I'll try doing this in a terminal where I'm sure i'm in the context of 9.1.8.0 i.e. by doing an RVM use to 9.1.8.0 and then doing the gradle build
amiracam
@amiracam
May 10 2017 10:33
@raelik gems show up, the correct facet shows up i.e. 9.1.8.0 , but in the gem manager , see here: https://www.screencast.com/t/mbtmqTkiITbt , it clearly shows that the gems did not get loaded, granted all being done via the IDEA Gradle UI
amiracam
@amiracam
May 10 2017 10:42
@raelik so I did the gradle build manually , and then did a gem list and the specific gems in my build.gradle do not show up, I see a generateGradleRB, is that supposed to run ? I see that the jrubyPrepare ran but again the gems apparently were not added to the gem set for the current RVM jruby
@raelik well actually , the :jrubyPrepae shows as UP-TO-DATE so I assume it didn't actually do anything
amiracam
@amiracam
May 10 2017 10:56
@raelik sorry , am I misunderstanding something, if I run outside of IDEA i.e.. in a terminal , and do a gradle build making sure the target Ruby is in context, after the build should I not be able to confirm that gems were added to the gem set i.e. via gem list ?
amiracam
@amiracam
May 10 2017 11:02
@raelik sorry , I don't understand this at all, see here: https://www.screencast.com/t/UockcWOCI , that gem got in there by me specifically doing a gem install, not thru the jruby-gradle plugin , I must have missed something foundational that you must assume I didn't
amiracam
@amiracam
May 10 2017 11:36
@raelik so from what i can tell doing gradle build doesn't install into the current ruby but rather downloads and sets up a build directory within the project and one' s source, must make sure to point to it ? i.e. via LOAD_PATH ? , not sure how to make that work for IDEA, where it thinks that those gems are not available to the source i.e. require "myFile" indicates that file is missing but myFile was actually downloaded by JGradle and cached into the build folder
Blane Dabney
@raelik
May 10 2017 14:07
@amiracam Yes, Gradle (using the jruby-gradle plugin) is a completely separate environment from say RVM, or chruby/chgems. It does not integrate with them. I've never attempted to integrate a jRuby application using the jruby-gradle plugin with IntelliJ (I've only ever used it with Gradle and a regular Java application), so your efforts may be completely futile.
Christian Meier
@mkristian
May 10 2017 14:39
yes, the big question is what IntelliJ expects the plugin to provide. we never had such a scenario in mind when developing the plugin. gradle commandline basically. here it seems that the jruby plugin does some unusual stuff which is not compatible to IntelliJ
amiracam
@amiracam
May 10 2017 15:38
@mkristian well, never mind what you envisioned although interesting since I just assumed most Jruby apps would tend to use IDEA or RubyMine, so I wonder what scenarios u all then do ?, anyhow I've been using Bundler of course, both manually and thru the IDEA integration, that just updates the gem set under the IDEA configured Ruby for the project,,however once I embarked on apps that required external Java dependencies , then the notion of Gradle became very interesting and in particular if you are doing polyglot projects which I am. IDEA does have the notion of a LOAD_PATH tab for which one obviously can add locations, I"m wondering if I add what the JGradle plugin generates i.e. under ./build as a location , if that works, alternatively which would be painful, I can somehow disconnect the IDEA Gradle integration, run builds manually and then copy runtime libs to my lib folder under the project, and add said folder as a dependency folder in IDEA, not sure if that would work for Gems or just for Jar dependencies, it may be possible that I use Gradle for Jar dependencies but still may need to use Bundler for standard Ruby ecosystem gems,in that case not sure what the value would be of the JRuby Gradle plugin, it seems that you all don't get much call for this i.e. JRuby projects built with IDEA that would benefit from Gradle integration, but that would be beautiful , thanks for the help, we think that Jruby could potentially be the next big enterprise language and especially once the truffle/GraalVM integration takes place, so getting this all smooth is important for us
R. Tyler Croy
@rtyler
May 10 2017 15:41
o/
amiracam
@amiracam
May 10 2017 16:03
@mkristian @raelik , another thought is just to do something like this:
require '../../../build/gems/gems/colorize-0.8.1/lib/colorize' but I have not evaluated if that will hold once the project is packaged, but I guess I could live with it
sorry, that only gets me half way, I still have to re-apply the project but at least I get the file and since I only have to re-apply the project only once the build file is changed then I guess I could live with that as well, need to test tho if this all holds
Christian Meier
@mkristian
May 10 2017 16:25
@amiracam it looks like ruby does not find your gems. you need to set GEM_HOME to ../../../build/gems/gems then require 'colorize' should do. maybe that is all you need to do.
Blane Dabney
@raelik
May 10 2017 16:25
@amiracam The jruby-gradle plugin (correct me if I'm wrong @rtyler, @mkristian) was designed with production deployments in mind, using either the jar plugin to generate an artifact jar containing jRuby, all of the gem and jar dependencies, and optionally the Ruby application code for deployment in a custom environment, OR the war plugin to generate a war file containing all of the above for deployment on a Java application server.
@mkristian That's not a bad idea, didn't think about that.
R. Tyler Croy
@rtyler
May 10 2017 16:26
that was part of it
it was originally aimed at packaging up jruby projects, but also executing ruby scripts as part of a gradle process
Blane Dabney
@raelik
May 10 2017 16:27
Oh yeah, forgot about jrubyExec.
R. Tyler Croy
@rtyler
May 10 2017 16:27
such as is done in the compass-gradle plugin
Blane Dabney
@raelik
May 10 2017 16:28
@amiracam I currently develop my jRuby apps in a pretty old school vim based dev environment, but I'll probably be switching over to IntelliJ soon, so I'm going to have to go through the same exercise.
amiracam
@amiracam
May 10 2017 18:26

@mkristian that's exactly what it is and because its explicitly looking at 9.1.8.0 which is the configured SDK for the project, but u don't mean as part of my e.g. bash_profile ? i.e. what if I have multiple projects , but that does remind me of something and that's the gradle.rb which was generated by one of the Jruby gradle tasks that I experimented with i.e. generateGradleRb which I could not find any docs on , but this is what it provides:
`#!/bin/sh

Hack our GEM_HOME to make sure that the rubygems support can find our

jars and unpacked gems in the given GEMFOLDER

export GEM_HOME="/Users/charles/IdeaProjects/JRubyGradleTest4/build/gems"
export GEM_PATH="/Users/charles/IdeaProjects/JRubyGradleTest4/build/gems"
export JARS_HOME=$GEM_HOME/jars
export JARS_LOCK=$GEM_HOME/Jars.lock

exec java -cp /Users/charles/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/9.1.8.0/d6b98ab4b7d9ad305e3331eca5528bd03960cf76/jruby-complete-9.1.8.0.jar org.jruby.Main -rjars/setup -S $@
`I don't understand what is supposed to trigger it , I assumed it to be something that the Jruby-gradle plugin was tapping into, or did it need this in order to know where to unpack to ? i.e. that path is successfully created, so perhaps that is what its for, also note however that the last line i.e. the exec directive won't work , that path does not exist. I would have to find a way of telling IDEA as much, and indeed that is what I was attempting with this: https://www.screencast.com/t/TN88bzhorNl
my understanding is that IDEA sets the GEM_HOME depending on what the selected Ruby SDK is for the current project. If that's the case one solution would be for the JRuby-Gradle plugin do what bundler does and install the Gems in the current Ruby or I could setup a redundant Gemfile and do it myself which would entail RVM use <desired Ruby which is Ruby SDK used for project> and then running bundle install, not ideal

amiracam
@amiracam
May 10 2017 19:09
@mkristian @raelik , so using a Gemfile to enforce that the necessary gems are available locally in the project Ruby SDK gemset allows me to run, debug, have intellisense on the source code etc, doing a gradle build does invalidate the SDK requiring "re-applying" via IDEA but only required if the build.gradle file changes, the JRuby-Gradle plugin provides jar dependency loading needed for dev so I can access Java ecosystem only jars and I assume any jar dependencies related to a Jruby gem , the jruby plugin also provides for jar/war creation, not exactly smooth but do-able @raelik glad you will be joining the IDEA family perhaps you won't stand the this pain too long :)
R. Tyler Croy
@rtyler
May 10 2017 19:55
2/win3
derp