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

12th
May 2015
R. Tyler Croy
@rtyler
May 12 2015 21:13
@mkristian @ysb33r since jrubyJavaBootstrap is gone now from the jar plugin, I think we should jump it to 0.2.0 instead of just incrementing to 0.1.4, thoughts?
Schalk W. Cronjé
@ysb33r
May 12 2015 21:13
Good idea
Christian Meier
@mkristian
May 12 2015 21:14
+1
R. Tyler Croy
@rtyler
May 12 2015 21:14
@mkristian how do I provide a custom script to be executed instead of jar-bootstrap.rb?
is that no longer possible
Christian Meier
@mkristian
May 12 2015 21:15
the same old iniScript declaration will do.
it will be renamed to jar-bootstrap.rb inside the jar
R. Tyler Croy
@rtyler
May 12 2015 21:15
where would I be declaring that though? that's what I'm missing I think
Christian Meier
@mkristian
May 12 2015 21:16
inside the jruby closure of build.gradle. as before - no change for build.gradle
R. Tyler Croy
@rtyler
May 12 2015 21:18
Christian Meier
@mkristian
May 12 2015 21:19
ah I see. I used it like jar { jruby { initScript 'meandthecorner.rb' } }
Schalk W. Cronjé
@ysb33r
May 12 2015 21:22
:+1:
Christian Meier
@mkristian
May 12 2015 21:22
this also triggers the jruby-complete + jruby-jars to be shaded into the jar
R. Tyler Croy
@rtyler
May 12 2015 21:22
right, I think I will need to make some surgery in the service-artifact plugin I'm working on
Christian Meier
@mkristian
May 12 2015 21:22
jruby-mains I mean
and I do not know about how much this breaks on the storm plugin
R. Tyler Croy
@rtyler
May 12 2015 21:23
hm
I'm not sure this isn't really really breaking something for me, will need to spend some time tinkering
@mkristian we have some internal topologies you should be able to verify your changes with, can you take a look at it?
Christian Meier
@mkristian
May 12 2015 21:25
I can
R. Tyler Croy
@rtyler
May 12 2015 21:41
@mkristian do you have a working example of that syntax you used above?
I'm getting:
wait, I think I found it
initScript = 'foo' --> `initScript 'foo'
subtle if you're not looking for it :P
Christian Meier
@mkristian
May 12 2015 21:44
did I change this ? well not on purpose
R. Tyler Croy
@rtyler
May 12 2015 21:44
well, it's more correct anyways :P
Christian Meier
@mkristian
May 12 2015 21:45
yes my sample uses initScript( 'bla.rb' )
R. Tyler Croy
@rtyler
May 12 2015 21:46
@mkristian once you've got some sanity checking done with storm plugins, I'll cut a release of the base and jar plugins I think
hrm, how would I add the dependencies from a specific configuration into the jar?
Christian Meier
@mkristian
May 12 2015 21:50
how do you do such things in general ?
better question: how to add the gems from specific configuration into the jar (as this did not change) ?
R. Tyler Croy
@rtyler
May 12 2015 21:52
that's been sometihng handled by the gemInstallDir which I'm not terribly keen on but whatever
Christian Meier
@mkristian
May 12 2015 21:54
I added the jar on my testing to "gems" configuration or dependencies
shadow plgun allows me to just add a whole configuration
and dependencies in that configuration will be included into the fat jar
I see the jarDir thing, but as a user I don't want to care about how the plugin gets jars into the packed fat jar
Christian Meier
@mkristian
May 12 2015 22:01
the jarDir is just a counter part to gemInstallDir and has a default.
rtyler @rtyler nods
R. Tyler Croy
@rtyler
May 12 2015 22:16
@mkristian is there a purpose of the default jjar task with these changes, or does it only exist top have files copied into the jrubyJar?
in order to avoid publishing multiple artifacts (default jar, and "all" jar) I've been disabling the default jar task in many projects
since I don't actually want it
Christian Meier
@mkristian
May 12 2015 22:21
hmm. so currenly the default jar contains all the resource files, i.e. ruby files. which gets unpacked and then the .jrubydir files will be generated. finally I pack the unpacked directory along with shaded jars into the "all" jar.
maybe it is possible to use the jar name for both purposes. but not sure about the UPTODATE check though
R. Tyler Croy
@rtyler
May 12 2015 22:23
well, I think we could go one of two directions here:
  1. remove the use of project.zipTree in jrubyJar and move the logic to create the right directory structure into some subtree under build/
  2. Do 1, and then overwrite the default behavior of the jar task to create the shaded jar properly invoked
I personally like 2, but is more work, and I'm not sure how @ysb33r feels about overwriting the default jar task
Christian Meier
@mkristian
May 12 2015 22:24
is the problem that there are two jars inside the build/libs/ directory or how does gradle decides which jars to publish ?
R. Tyler Croy
@rtyler
May 12 2015 22:25
gradle has an artifacts {} DSL which defines which artifacts will be published, whatever is produced by the jar task is there by default
it doesn't care how many jar files are in build/libs
Christian Meier
@mkristian
May 12 2015 22:28
ok. not sure how easy it is to copy the resource from jar task into some directory. I think I tried this.
R. Tyler Croy
@rtyler
May 12 2015 22:29
hrm
so this eachFile method, I believe that is just going to yield the closure the contents of the main source set
I'm not sure what is going to set that so it includes the ruby files properly
looking around now
Christian Meier
@mkristian
May 12 2015 22:37
the problem with eachFile was that it creates files which needs to added to jar as well.
R. Tyler Croy
@rtyler
May 12 2015 22:38
yeah, I don't think that's a problem
if we generate a dir, let's say build/packed-jar-contents then the jrubyJar task would only need to do from("${buildDir}/packed-jar-contents") and it'd create the riight structure
Schalk W. Cronjé
@ysb33r
May 12 2015 22:40
I would nto want to overwrite jar task behaviour - it is for that reason that I left jar and shadowJar as two separate tasks. Not everyone wants executable jars containing jruby code.
R. Tyler Croy
@rtyler
May 12 2015 22:41
I kind of get that, but I the current behavior is rather confusing for new users
at least users coming into gradle via jruby-gradle, aka my colleagues
Schalk W. Cronjé
@ysb33r
May 12 2015 22:42
I was about to say that :)
R. Tyler Croy
@rtyler
May 12 2015 22:42
they see one garbage jar, and one jar they care about being created
Christian Meier
@mkristian
May 12 2015 22:42
this is understood. but how do "iterate" over the jar content before packing the jar ? is there a way to "clone" the config from jar task ?
Schalk W. Cronjé
@ysb33r
May 12 2015 22:43
yes
I think so
R. Tyler Croy
@rtyler
May 12 2015 22:43
what config would be coming off the jar task?
if I want to create a shaded jar, I don't want anything to do with the default jar task
Christian Meier
@mkristian
May 12 2015 22:44
anything you want to add to your jar 'config.ru', 'lib/*/.rb', etc
R. Tyler Croy
@rtyler
May 12 2015 22:44
we do have projects which built traditional jar libraries, but those are subprojects in Gradle
Schalk W. Cronjé
@ysb33r
May 12 2015 22:44
I would just say to add a jar.enabled = false in you build.grade file
R. Tyler Croy
@rtyler
May 12 2015 22:44
@mkristian right, but IMO those should be sourcesets
@ysb33r that doesn't disable the artifact
you have to also forcefully remove the artifact from the list of artifacts, there's not a clean API AFAIK for that
Schalk W. Cronjé
@ysb33r
May 12 2015 22:45
you’re right
Christian Meier
@mkristian
May 12 2015 22:46
this has nothing to do with shading jruby-complete - even without this the .jrubydir needs to be generated.
Schalk W. Cronjé
@ysb33r
May 12 2015 22:46
that is default behaviour introduce by the java plugin I think
R. Tyler Croy
@rtyler
May 12 2015 22:46
jar.eneabled = false
configurations.archives.artifacts.removeAll { it.archiveTask.is jar }
rtyler @rtyler vomits
Christian Meier
@mkristian
May 12 2015 22:47
sourceSets maybe a way but I just did jar { from 'lib' } as new user !
R. Tyler Croy
@rtyler
May 12 2015 22:47
yeah, and I think that's bad
maybe:
jrubyJar {
  from 'lib'
}
if the jar task is going to stick around, I'm okay with that, but I don't think users should be adding their configuration to jar when they really should be adding it to jrubyJar
Schalk W. Cronjé
@ysb33r
May 12 2015 22:48
so here’s two issues? 1 creating/ not creating jar [2] getting fat jar to include what you want ?
R. Tyler Croy
@rtyler
May 12 2015 22:49
for 2. s/include/configured with/
but more or less, for 1. I'm stating that if jar isn't going to be overwritten with our JRuby behavior, we shouldn't touch it at all
otherwise, we might as well overwrite it to give users a reasonable expectation and API
Christian Meier
@mkristian
May 12 2015 22:50
even the non-fat jar needs from 'lib' and there the .jrubydir files needs to created and added.
R. Tyler Croy
@rtyler
May 12 2015 22:51
why?
I'm asserting that there is no point to a non-fat jar for JRuby code
or are you concernde with a library type jar, instead of a gem?
Christian Meier
@mkristian
May 12 2015 22:51
yes, I do have a jar artifacts with packed gems and ruby resources.
which uses ScriptingContainer from jruby or jruby scripting from java
R. Tyler Croy
@rtyler
May 12 2015 22:53
right, so these are two very discrete and separate use-cases
that makes sense to me to support in the plugin, and under the jar task
that to me would need to be definitely separate from the configuration of jrubyJar
and use sourcesets
Christian Meier
@mkristian
May 12 2015 22:57
why separate ? the only difference is that once you declare a Main or not
Schalk W. Cronjé
@ysb33r
May 12 2015 22:57

I'm asserting that there is no point to a non-fat jar for JRuby code
or are you concernde with a library type jar, instead of a gem?

I always think asciidoctorj is a good example.

Christian Meier
@mkristian
May 12 2015 22:58
use sourceSets could solve my problem I had implementing the generation of the jrubydir files
R. Tyler Croy
@rtyler
May 12 2015 22:58
@mkristian the library-type jar wouldn't be including all the jar and gem dependencies though would it?
those would be transitive dependencies that would need to go into the pom right?
Christian Meier
@mkristian
May 12 2015 22:58
yes it would - in my mindset
R. Tyler Croy
@rtyler
May 12 2015 22:58
so the fat-jar would contain all dependencies, and it would contain a main
if I'm building a library, I wouldn't nceessarily want to include all my configuration and other runtime type stuff, I would wan the library code itself and that's about it IMO
Christian Meier
@mkristian
May 12 2015 22:59
well, that is tricky point. all jars used by jruby should be packed and the ones used by java should go as transitive dependencies
not sure if this is possible
Schalk W. Cronjé
@ysb33r
May 12 2015 23:00
it would be possible
Christian Meier
@mkristian
May 12 2015 23:00
with gradle I had the feeling this is possible - with maven I do not see simple way :)
R. Tyler Croy
@rtyler
May 12 2015 23:00
@ysb33r I think asciidoctorj might be a configurable variation of what I'm thinking as far as "library jars" go
Schalk W. Cronjé
@ysb33r
May 12 2015 23:00
do they need to be packed or unpacked inside the jar
?
R. Tyler Croy
@rtyler
May 12 2015 23:01
asciidoctorj needs ruby dependencies included inside the library jar right?
code + gems = jar
Schalk W. Cronjé
@ysb33r
May 12 2015 23:01
@rtyler indeed
Christian Meier
@mkristian
May 12 2015 23:01
jruby needs packed jars to work properly
Schalk W. Cronjé
@ysb33r
May 12 2015 23:02
@mkristian in that case, not to difficult.
R. Tyler Croy
@rtyler
May 12 2015 23:02
@ysb33r so a library jar for that case might be jar { jruby { includeGems() } }
whereas something where I just need code, would just be jar { } with the appropriate additions to the main sourceset
and a fat jar might be: jrubyJar { initScript 'app.rb' }
Schalk W. Cronjé
@ysb33r
May 12 2015 23:03
@rtyler roughly so
R. Tyler Croy
@rtyler
May 12 2015 23:03
all three should use the main sourceset though IMO
as the source of their ruby code
Christian Meier
@mkristian
May 12 2015 23:03
I am ok with the sourceset
R. Tyler Croy
@rtyler
May 12 2015 23:04
in terms of what we'd need to do to preserve jruby sanity though @mkristian would all three need .jrubydir/ changes?
Schalk W. Cronjé
@ysb33r
May 12 2015 23:04
@mkristian you can achive that today in a normal script by doing
jar {
  from ‘/path/to/other.jar
}
Christian Meier
@mkristian
May 12 2015 23:05
but jar { jruby { initScript 'app.rb' } } looks more consistent to me for fat jar
Schalk W. Cronjé
@ysb33r
May 12 2015 23:05
@rtyler I suspect that if you pack ruby code into a jar you can just as well add .jrubydir info
irrespective of whether it is fat or not
@mkristian based upon convention all fat jar-like tasks in Gradle uses a task name other than jar i.e. shadowJar, oneJar. So sticking with that jrubyJar is the correct name for a fat jar
Christian Meier
@mkristian
May 12 2015 23:08
ok - np then
R. Tyler Croy
@rtyler
May 12 2015 23:09
okay, I'm going to write up some issues for tihs real quick and maybe you guys can sanity check to make sure we're in agreement
If I were writing a new shadow plugin that wasn't jruby related I'd call it shattenfreude
Christian Meier
@mkristian
May 12 2015 23:13
:)
R. Tyler Croy
@rtyler
May 12 2015 23:15
alright jruby-gradle-jar-plugin#41 jruby-gradle-jar-plugin#42 and jruby-gradle-jar-plugin#43
that didn't link properly, damnit
jruby-gradle/jruby-gradle-jar-plugin#41 jruby-gradle/jruby-gradle-jar-plugin#42 jruby-gradle/jruby-gradle-jar-plugin#43
Schalk W. Cronjé
@ysb33r
May 12 2015 23:18
I’ll have a look tomorrow
R. Tyler Croy
@rtyler
May 12 2015 23:18
rats
Christian Meier
@mkristian
May 12 2015 23:19
installGems will include the jar dependencies as well. what about adding "extra" jars for you jruby code ?
I add them to "gems" configuration/dependencies ?
R. Tyler Croy
@rtyler
May 12 2015 23:20
@mkristian related to jruby-gradle/jruby-gradle-jar-plugin#43?
Christian Meier
@mkristian
May 12 2015 23:20
yes
R. Tyler Croy
@rtyler
May 12 2015 23:21
jars I would expect to still be expressed as a transitive dependency
Christian Meier
@mkristian
May 12 2015 23:26
well, my overall point with is gems and jars are kind of symmetrical which I also expressed in prepareJRubyGems and prepareJRubyJars. so I guess I miss the jars in installGems
R. Tyler Croy
@rtyler
May 12 2015 23:26
but for a library jar they're not symmetrical in the case like asciidoctorj
which is "i'm building a library which wraps around ruby code and must be distributed and incorporated into some other dude's maven or gradle project"
ten you want to bundle in the ruby code, but still express your java transitive deps properly
Christian Meier
@mkristian
May 12 2015 23:28
yes, if my ruby code has require 'slf4j-simple' then I need to provide the jar as packed jar inside the library jar
that is the jbundler case
Christian Meier
@mkristian
May 12 2015 23:33
let's pick this up later again (or not) - since I am going to bed now
R. Tyler Croy
@rtyler
May 12 2015 23:33
I only need to require something if it's not already on the classpath
right?
Christian Meier
@mkristian
May 12 2015 23:34
probably right
R. Tyler Croy
@rtyler
May 12 2015 23:34
heh
we can pick this up tomorrow, I'll continue forging ahead with all my config on jrubyJar for my downstream dependencies of the jar plugin
Christian Meier
@mkristian
May 12 2015 23:35
cool you correct things with gitter :)
the initScript is optional as well. without you can just pick any script which is inside jar as file argument on commandline
related to #41
or use -S rake for the executables from gems
R. Tyler Croy
@rtyler
May 12 2015 23:39
will you note that in the ticket?
Christian Meier
@mkristian
May 12 2015 23:39
will do
R. Tyler Croy
@rtyler
May 12 2015 23:41
thanks for talking through this all, I feel much better about where the jar plugin is heading in general now
not ust for lookout's usecases, but as a general purpose tool
Christian Meier
@mkristian
May 12 2015 23:42
yes, it goes into the right direction and I have to admit I am quite excited about it ;)
R. Tyler Croy
@rtyler
May 12 2015 23:43
\o/
get some rest, i'll catch you tomorrow
Christian Meier
@mkristian
May 12 2015 23:44
see you tomorrow . . . gute nacht
R. Tyler Croy
@rtyler
May 12 2015 23:44
tschussi