Build a fat jar but with jars inside instead of class files


(behnam.rezaei) #1

Hi, I am trying to convert some of our ivy/ant scripts to gradle. We had a target that would generate jar files that included all dependency jar files in a lib folder (So its different that fatjar/uberjar/shadowjar) that you include the jars instead of classes in your jar. We need this for one of our older map reduce clusters that requires this jar format to run mapred jobs. Any suggestion how I can do this in gradle? This was my ivy/ant build script

<target name="mapred-jar" depends="mapred-jar-default" description=" make distribution jar, collapses jars and configs and classes directory ">
                  <jar destfile="${build.dir}/${ant.project.name}-${version}-mapred.jar">
                        <fileset dir="${classes.dir}" />
                        <zipfileset dir="${mapredjar.tmp.dir}/lib" prefix="lib">
                                  <!-- <exclude name="commons*.jar" /> -->
                                <!-- <include name="hadoop*.jar" /> -->
                          </zipfileset>
                </jar>
                  <delete dir="${mapredjar.tmp.dir}" />
        </target>

Thanks for your help.


(Peter Niederwieser) #2
jar {
    into("lib") {
        from configurations.runtime
    }
}