Gradle
  1. Gradle
  2. GRADLE-566

fatJar option for building jar-with-dependencies

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None

      Description

      <shameless copy-paste from the mailing list>

      I think I'm missing the concept of 'fat jar' in Gradle. Many times
      when I worked on a library/console app I needed to stick all
      dependencies in single jar. It would be great if java plugin added
      extra task that could produce fat jar (or mavenized:
      jar-with-dependencies) out of the box.

      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 {
      add srcDir // srcDir is not String but a rich object, which knows all of the srcDir including its classpath
      fat = true
      }

      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!>

        Activity

        Hide
        Robert Fischer added a comment -

        I'm on it.

        Show
        Robert Fischer added a comment - I'm on it.
        Hide
        Ben McCann added a comment -

        Awesome. Thanks so much for being super responsive and providing this plugin. I'll be really excited to use it.

        Show
        Ben McCann added a comment - Awesome. Thanks so much for being super responsive and providing this plugin. I'll be really excited to use it.
        Hide
        Ben McCann added a comment -

        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:
        http://jira.codehaus.org/browse/GRADLE-1361

        Show
        Ben McCann added a comment - 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: http://jira.codehaus.org/browse/GRADLE-1361
        Hide
        Ravi Teja added a comment - - edited
        Show
        Ravi Teja added a comment - - edited 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 Example: http://stackoverflow.com/questions/9749032/create-a-groovy-executable-jar-with-gradle
        Hide
        Diwaker Gupta added a comment -

        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:

        • excluding 'META-INF/.RSA', 'META-INF/.DSA' etc. to avoid signing issues when building executable jars
        • combining META-INF/services files to avoid failures when applications use the ServiceLoader framework (easy to hit when you build an app that supports multiple JDBC drivers, for instance)
        • combining NOTICE files, LICENSE files and other useful transformations

        Basically, a plugin that can match maven shade/assembly in features

        Show
        Diwaker Gupta added a comment - 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: excluding 'META-INF/ .RSA', 'META-INF/ .DSA' etc. to avoid signing issues when building executable jars combining META-INF/services files to avoid failures when applications use the ServiceLoader framework (easy to hit when you build an app that supports multiple JDBC drivers, for instance) combining NOTICE files, LICENSE files and other useful transformations Basically, a plugin that can match maven shade/assembly in features

          People

          • Assignee:
            Unassigned
            Reporter:
            Szczepan Faber
          • Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:

              Development