[GRADLE-566] fatJar option for building jar-with-dependencies Created: 23/Jul/09 Updated: 10/Feb/17 Resolved: 10/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | ||
Reporter: | Szczepan Faber | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 5 |
Description |
<shameless copy-paste from the mailing list> I think I'm missing the concept of 'fat jar' in Gradle. Many times It would be easy to provide such a fatJar task for the default jar task. This would be the framework way of doing things (like Maven does). But it would be much cooler, if there were the pattern fat<JarName> which works for any jar that is related to source directories. To make this possible we need a richer abstraction for source directories which we plan to do for 0.8. If we have such source dir objects you could also define a jar like: task mySrcJar { This would work with any project layout, not just with single src root projects. And it would enable to provide a rule for a pattern like above. Toolset over Framework rules <you bet!> |
Comments |
Comment by Tomek Kaczanowski [ 24/Sep/09 ] |
Hi Szczepan, Thomas Kinnen was kind to provide a solution for fat-jar creation - see http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-Creatingafatjar It is not a fully-fledged solution, but can be sufficient in some cases. – |
Comment by Hans Dockter [ 20/Jan/10 ] |
We are kind of conservative to making our API bigger. We want to be really sure that its worth it. With the newest Gradle there is now a fantastic way to 'stage' potential API enhancement candidates. Any script can now be a plugin. Those scripts can live on your local machine or remotely. I have added a fatjar plugin script. You can say now (with the latest Gradle): apply url: 'http://github.com/hansd/huglins/raw/master/fatjar.gradle' jar { merge configurations.runtime } task otherJar { merge files(fileTree('lib').matching { include '**/.jar' }) } |
Comment by Ben McCann [ 25/Jan/11 ] |
I would very much like to see something along the lines of the Maven Assembly Plugin's jar-with-dependencies added. Hans, I attempted to use the plugin you posted and recieved: |
Comment by Ben McCann [ 25/Jan/11 ] |
I tried the following and it seemed to load the script though it looks like there are problems with the script still: |
Comment by Robert Fischer [ 25/Jan/11 ] |
BTW, I've got a OneJar plugin: https://github.com/RobertFischer/gradle-plugins |
Comment by Ben McCann [ 25/Jan/11 ] |
Thanks, Robert. I'm anxious to try it out. I'm getting the error message below right now: I have a multi-maven project. I've attached the build.gradle file from the parent project where I included the plugin in case you see anything obvious that I did wrong (which is likely since I'm still new to gradle :o) Thanks, |
Comment by Ben McCann [ 25/Jan/11 ] |
I updated my build script, but still cannot get Robert's plugin to work. I didn't realize the first time around that buildscript was a reserved word in gradle. I'm still getting the same error: |
Comment by Ben McCann [ 25/Jan/11 ] |
Finally got it figured out. I left "Plugin" off the plugin name. I filed a new bug (http://jira.codehaus.org/browse/GRADLE-1352) asking for Gradle to give back a better error message in this situation. I'll try out the plugin now and let you know how it works. Thanks! |
Comment by Ben McCann [ 25/Jan/11 ] |
I'm sorry, I still can't figure this out. Robert, could you post an example of how to use the plugin? I have it installed now, but am not sure how to call it. |
Comment by Peter Niederwieser [ 26/Jan/11 ] |
Have you tried gradle oneJar? |
Comment by Ben McCann [ 26/Jan/11 ] |
Yep, no luck. $ gradle oneJar FAILURE: Build failed with an exception.
|
Comment by Peter Niederwieser [ 26/Jan/11 ] |
Please provide such information upfront rather than letting us guess what the problem might be. I can confirm that the OneJar plugin doesn't work for multi-project builds, at least not with Gradle 0.9.2. |
Comment by Ben McCann [ 26/Jan/11 ] |
Thanks. I wasn't sure that "gradle oneJar" was the correct invocation since there were no docs. I filed a bug requesting that it be clarified: https://github.com/RobertFischer/gradle-plugins/issues/issue/3 I also filed a bug for the fact that it's broken on multi-project builds: |
Comment by Robert Fischer [ 26/Jan/11 ] |
I'm on it. |
Comment by Ben McCann [ 26/Jan/11 ] |
Awesome. Thanks so much for being super responsive and providing this plugin. I'll be really excited to use it. |
Comment by Ben McCann [ 01/Feb/11 ] |
It looks like the Gradle Cookbook also has a tip on how to do this, but it doesn't seem to work, so I filed a new bug for that: |
Comment by Ravi Teja [ 25/Jul/12 ] |
I created a similar sample project using uberjar example but anyway need this feature. Code: https://github.com/bond-/gradle-groovy-jar-example/blob/master/build.gradle |
Comment by Diwaker Gupta [ 18/Sep/12 ] |
I think gradle should provide a standard plugin (or even in core) for this functionality. While there are many "quick" plugins, scripts, snippets and Cookbook recipes to build a fat jar out there, none of them work out of the box for me. Building a working fat jar requires numerous (potential) steps, including but not limited to:
Basically, a plugin that can match maven shade/assembly in features |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Benjamin Muschko [ 10/Feb/17 ] |
Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved. |