Skip to content
This repository has been archived by the owner on May 19, 2019. It is now read-only.

WIP create executable jar using jruby-main artifact #38

Merged
merged 1 commit into from
May 11, 2015

Conversation

mkristian
Copy link
Contributor

  • pack all jar-dependencies into root of the jar using a maven repository layout
  • use either main which runs completely from the jar or an extracting main which
    first extracts the jar into a temporary directory
  • shades both jruby-complete and jruby-mains into the executable jar using
    gradle zipTree, i.e. all shadowJar is gone
  • remove compat version and let jruby-mains pick .jrubyrc from the jar-file
    which can set the compat version when needed
  • init script support is broken

Sponsored by Lookout Inc.

@mkristian mkristian changed the title create executable jar using jruby-main artifact WIP create executable jar using jruby-main artifact Apr 18, 2015
@mkristian
Copy link
Contributor Author

depends on jruby-gradle/jruby-gradle-plugin#110

still work to be done

@mkristian
Copy link
Contributor Author

needs: jruby/jruby-mains#1

@mkristian
Copy link
Contributor Author

some remarks:

  • the defaultMain will not work
    • with older jruby-versions - jruby-1.7.19+ work with running directly from the jar
    • when the code tries to relaunch "ruby" like the rspec task for rake does then you need to use the extractingMain. the extractingMain is slower on startup since it first needs unpack the jar
  • gem dependencies with or without jar-dependencies work
  • adding "extra" jar artifacts along with the gems does only work if the application does Jars.require_jars_lock! (part of jar-dependencies) at some point.
  • there a two more issues open with jruby-mains:

@@ -24,15 +24,6 @@ class JRubyJarConfigurator {
configure()
}

@PackageScope
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether I am happy with dropping shadowJar support completely. What I do think is to definitely remove it from a fixed dependency in build.gradle. It might still be worthwhile for someone who want to use that instead to go that way bu explicitly including it in their buildscript and applying the plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, sounds fair to treat jar and shadowJar alike. will put it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought: I moved back the shadowJar option for jruby-gradle-jar-plugin BUT things will not really work when you use it since all those embedded jars are gone and jruby-main will look for them and not find them.

@ysb33r
Copy link
Contributor

ysb33r commented Apr 20, 2015

with older jruby-versions - jruby-1.7.19+ work with running directly from the jar

We can just force this to say that as from v0.1.4, jruby 1.7.19 is a requirement. We could print a warning at least in the code.

when the code tries to relaunch "ruby" like the rspec task for rake does then you need to use the extractingMain. the extractingMain is slower on startup since it first needs unpack the jar

Will extractingMain clean up the temporary files afterwards?

@mkristian
Copy link
Contributor Author

@ysb33r
https://github.com/mkristian/jruby-mains/blob/master/src/main/java/de/saumya/mojo/mains/ExtractedZip.java#L54

this works more or less. if you have more or better ideas please speak up - especially on windows things are bit stricter.

@rtyler
Copy link
Member

rtyler commented Apr 29, 2015

Now that I've created the 0.1.16 base plugin, should this be updated?

@mkristian mkristian force-pushed the jruby-mains branch 3 times, most recently from fac5e43 to b94549e Compare May 1, 2015 20:46
}
project.tasks.withType(Jar) { task ->
if (task.name == 'jar') {
finalizedBy( 'jrubyJar' )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this finalizeBy is a hack - any suggestions on how to do it better are welcome.

but the idea is 'jar' tasks collects all resources and on the fly gnerates those .jrubydir files for this resourecs

after this 'jrubyJar' takes the first jar and all jrubyJars and packs the fat-jar

@rtyler
Copy link
Member

rtyler commented May 1, 2015

At first blush this looks ifne to me, I'll wait for @ysb33r to take a peek before I merge it.

testRepo ('org.jruby:jruby-complete:1.7.19') {
transitive = false
}
testRepo ('de.saumya.mojo:jruby-mains:0.1.0') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be 0.2.0

@@ -116,8 +69,51 @@ class JRubyJarPlugin implements Plugin<Project> {
project.afterEvaluate {
project.dependencies {
jrubyJar group: 'org.jruby', name: 'jruby-complete', version: project.jruby.defaultVersion
// TODO remove hardcoded version to config
jrubyJar group: 'de.saumya.mojo', name: 'jruby-mains', version: '0.2.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to fix this after merge and before release.

transitive = false
}
testRepo ("org.spockframework:spock-core:0.7-groovy-2.0") {
transitive = false
}

testRepo 'com.github.jengelman.gradle.plugins:shadow:1.1.2'

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the removal of this final closing } ius causing the build to fail in Travis

* pack all jar-dependencies into root of the jar using a maven repository layout
* use either main which runs completely from the jar or an extracting main which
  first extracts the jar into a temporary directory
* shades both jruby-complete and jruby-mains into the executable jar using
  gradle zipTree, i.e. all shadowJar is gone
* remove compat version and let jruby-mains pick .jrubyrc from the jar-file
  which can set the compat version when needed. (pending feature on jruby-mains)
* init script support needs jruby-mains-0.1.1.jar released
* generate .jrubydir files on resources added to jar

Sponsored by Lookout Inc.
@rtyler rtyler added this to the 0.1.4 milestone May 11, 2015
rtyler pushed a commit that referenced this pull request May 11, 2015
WIP create executable jar using jruby-main artifact
@rtyler rtyler merged commit 4b8de17 into jruby-gradle:master May 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants