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

24th
Aug 2015
R. Tyler Croy
@rtyler
Aug 24 2015 15:17
@mkristian why not start the server when the repositories{} block is evaluated
i.e. if we use rubygems { url 'foo' } then start the proxy server?
Christian Meier
@mkristian
Aug 24 2015 15:30
because it does not startup without classloader errors
R. Tyler Croy
@rtyler
Aug 24 2015 15:31
This message was deleted
Christian Meier
@mkristian
Aug 24 2015 15:31
and it can not, first I need to collect all rubygems urls
for each I need to configure a webcontext
once I have them all I can start the server
R. Tyler Croy
@rtyler
Aug 24 2015 15:31
I don't understand how the classloader errors are an not an indication that something is wrong
stuffing this into "first task" really seems like an ugly hack to me
do you have an integration test locally already running with this?
Christian Meier
@mkristian
Aug 24 2015 15:33
well, I can put my test build.gradle into a test.
I really have no idea how gradle builds its classloaders, so debugging means first to unwrap those classloaders to find out which jars are loaded where.
and how
R. Tyler Croy
@rtyler
Aug 24 2015 15:34
well, the buildscript{} has a dependencies{}block for stuff to be placed on the classpath for the execution of the build.gradle
is that not happening
Christian Meier
@mkristian
Aug 24 2015 15:35
well, the jetty starts but throws funny classloader errors
I get your point. since I have things working now, it is time to revisit the starting of jetty from the plugin.
Christian Meier
@mkristian
Aug 24 2015 16:04
@rtyler moving the start server into the afterEval callback results in those errors: https://gist.github.com/mkristian/634e43882c00b46f0243
R. Tyler Croy
@rtyler
Aug 24 2015 16:05
what package is javax/servlet/ServletContextListener supposed to be in? I thought that was default JRE stuff
Christian Meier
@mkristian
Aug 24 2015 16:06
no this is javax.servlet jar which comes with one of those jetty dependencies
R. Tyler Croy
@rtyler
Aug 24 2015 16:06
but if its loading jetty, why doesn't it know about that?
Christian Meier
@mkristian
Aug 24 2015 16:06
but you see a similar error with jetty class
for I did before: the classloader in the eval closure and the "startEmbeddedServer" task is the same. so I do not see why one is working and the other one is not working
the next thing I did to defer the starting when I first evaluate the url https://github.com/jruby-gradle/jruby-gradle-plugin/pull/199/files#diff-ed6d5f77c769d54a9e8c51de8bfc8c3bR76
R. Tyler Croy
@rtyler
Aug 24 2015 16:10
this is attempting to start in the same JVM as Gradle yeah?
Christian Meier
@mkristian
Aug 24 2015 16:11
this produces RubygemsServlet not a javax.Servlet error
of course I try to start it in the same JVM. and of course I can just pick all those jetty dependencies and build nice and clean classlaoder and start it from there
but that is more work then the "task" approach
R. Tyler Croy
@rtyler
Aug 24 2015 16:12
I wonder if Gradle has its own custom classloader, and then Jetty does too and Jetty is expecting to be the "parent" or root classloader in the JVM
how does one tell the Jetty classloader where to find/load classes from?
Christian Meier
@mkristian
Aug 24 2015 16:13
usually new URLClassLoader just takes the current thread context classloader as parent
I did try to set the jetty parent classloader explicitly with no change
so if you think the task approach is too hacky then I will go for the clean classloader way
it straight forward but just a bit more of code to write
R. Tyler Croy
@rtyler
Aug 24 2015 16:15
the task approach I'm concerned about the viability and maintainability of
Christian Meier
@mkristian
Aug 24 2015 16:17
so I go for the separated classloader approach
R. Tyler Croy
@rtyler
Aug 24 2015 16:19
honestly, I'm surprised the task appraoch even works
are you sure your local project is hitting the embedded server and not going straight to lasagna.io?
Christian Meier
@mkristian
Aug 24 2015 16:20
yes, I am sure
there no other server used and the debug log shows clearly the servlet logs
and you also see how the dependencies get resolved just before a task gets executed
R. Tyler Croy
@rtyler
Aug 24 2015 16:22
but that doesn't make sense
how does the task execute after resolution happens o_O
doFirst{} is the first action in the action list, which AFAICT is supposed to be the start of execution
rtyler @rtyler is very confused
R. Tyler Croy
@rtyler
Aug 24 2015 16:24
@mkristian perhaps you could implement that integration test, then I can see this work on my machine as well?
Christian Meier
@mkristian
Aug 24 2015 16:26
ok
Christian Meier
@mkristian
Aug 24 2015 16:48
@rtyler the integrationtest produces even more classloader errors. other ones since I do have a jruby embedded inside the rubygems.war as well one which is provided :( - no way I go further this way. the classloader setup for the integration test is even totally different from running gradle from the commandline.
R. Tyler Croy
@rtyler
Aug 24 2015 16:48
heh
hooray!
Blane Dabney
@raelik
Aug 24 2015 19:05
I'm just now updating my build.gradle files to use jruby-gradle 1.0.+, and I'm noticing that when I run ./gradlew jrubyJar, my jar dependencies are being put into a jars/ subdirectory in the jar file, and aren't being automatically added to my classpath
I'm guessing this is intentional, and that I need to change something to get this working again
Blane Dabney
@raelik
Aug 24 2015 19:33
I should just need to add -rjars/setup to my command line, but that doesn't appear to be working
Christian Meier
@mkristian
Aug 24 2015 19:41
@raelik -rjars/setup does load the jars into jruby-classloader but it also needs JARS_HOME=uri:classloader://jars and the Jars.lock file
Blane Dabney
@raelik
Aug 24 2015 19:45
ah, ok, just needed that env var
R. Tyler Croy
@rtyler
Aug 24 2015 20:37
@raelik this is automatically done when using the jruby-mains and runnable() for the initscript
R. Tyler Croy
@rtyler
Aug 24 2015 20:43
(fwiw)
Blane Dabney
@raelik
Aug 24 2015 21:01
looks like I still need Jars.lock in the root of my project
also, I get this error when I try to use org.jruby.Main
R. Tyler Croy
@rtyler
Aug 24 2015 21:02
the plugin should be generating a Jars.lock for you already
is there one in build/dirinfo?
Blane Dabney
@raelik
Aug 24 2015 21:03
no
R. Tyler Croy
@rtyler
Aug 24 2015 21:03
er, jar
lemme build up a gem
Blane Dabney
@raelik
Aug 24 2015 21:04
maybe I'm missing something else that I need. I'm just running ./gradlew jrubyJar to build my fat jar
R. Tyler Croy
@rtyler
Aug 24 2015 21:06
yeah, that should work just fine
are your jar dependencies defined in gradle?
Blane Dabney
@raelik
Aug 24 2015 21:07
yeah
R. Tyler Croy
@rtyler
Aug 24 2015 21:07
which configuration?
Blane Dabney
@raelik
Aug 24 2015 21:07
they all end up in there
R. Tyler Croy
@rtyler
Aug 24 2015 21:07
ah good
Blane Dabney
@raelik
Aug 24 2015 21:07
I have them under runtime in mine
R. Tyler Croy
@rtyler
Aug 24 2015 21:07
try:
configurations {
jrubyJar.extendsFrom runtime
}
Blane Dabney
@raelik
Aug 24 2015 21:07
I have that
R. Tyler Croy
@rtyler
Aug 24 2015 21:08
well bollocks
is your gradle file open source?
i'm assuming your initScript is bin/jvsql?
Blane Dabney
@raelik
Aug 24 2015 21:10
no, I'm explicitly specifying that with -C
this isn't being run through gradle
R. Tyler Croy
@rtyler
Aug 24 2015 21:10
you mean -S?
what's -C o_O
Blane Dabney
@raelik
Aug 24 2015 21:11
I'm sorry, not -C
just as a script argument
java ... -cp build/libs/fat.jar org.jruby.Main -C . bin/jvsql.rb
I was just doing -jar, but I had to add -rjars/setup and set the JARS_HOME environment variable
R. Tyler Croy
@rtyler
Aug 24 2015 21:12
is the fatjar created with initScript library()?
Blane Dabney
@raelik
Aug 24 2015 21:13
I used runnable()
R. Tyler Croy
@rtyler
Aug 24 2015 21:14
hrm, this is definitely being in a way that I've never seen or tested before
Blane Dabney
@raelik
Aug 24 2015 21:15
oddly, if I have a Jars.lock directory in my project root, ./gradlew jrubyJar also fails with that same error
R. Tyler Croy
@rtyler
Aug 24 2015 21:15
there's a MainClass set for jruby-mains already, and jruby-mains will set up the JRUBY_HOME and current directory for the Ruby execution environment
Blane Dabney
@raelik
Aug 24 2015 21:15
if I remove it, it works
The app I'm using this in is a plain Rack app
it has its own scripts in bin/ that aren't in the jar file
R. Tyler Croy
@rtyler
Aug 24 2015 21:19
what's the goal here?
just want to make sure I'm understanding the intent
Blane Dabney
@raelik
Aug 24 2015 21:19
to be able to run those scripts from the command line
maybe I just need library() and not runnable()
R. Tyler Croy
@rtyler
Aug 24 2015 21:20
I would be wrong there
library() isn't going to embed jruby-complete for you IIRC
Blane Dabney
@raelik
Aug 24 2015 21:20
right, that's what I thought
R. Tyler Croy
@rtyler
Aug 24 2015 21:21
hrnm
so would you be expecting the scripts to be embedded in the jar, or external to the jar?
Blane Dabney
@raelik
Aug 24 2015 21:21
so this does work just fine if I use -jar build/libs/fat.jar, manually set JARS_HOME and add -rjars/setup to the command line
the scripts are external to the jar
All I expect to be in the jar is jruby-complete and all the dependencies
R. Tyler Croy
@rtyler
Aug 24 2015 21:23
so I believe this should work, provided its a runnable artifact: java -jar fatjar.jar -S ./bin/thing
I'm not sure if it's going to try to look for ./bin/thing in the artifact itself
@raelik I'm going to be in and out the rest of the day, if you shoot something to the mailing list or just pop on tomorrow, I"ll be here :)
I'm in the PDT timezone
Blane Dabney
@raelik
Aug 24 2015 21:24
kk
R. Tyler Croy
@rtyler
Aug 24 2015 21:24
I'll think more about this usecase
Blane Dabney
@raelik
Aug 24 2015 21:25
oddly, I'm not seeing any of my gems in the jar anymore
just jar-dependencies
R. Tyler Croy
@rtyler
Aug 24 2015 21:25
GHOSTS
Blane Dabney
@raelik
Aug 24 2015 21:25
didn't notice that before, because this script I'm testing doesn't use any of the gems
Blane Dabney
@raelik
Aug 24 2015 21:54
ok, so it did create build/dirinfo/jrubyJar and all the files in there
not going crazy
still, isn't putting any of my gems in there, only jar-dependencies