gradle to bundle nested jar dependencies into modu

2019-05-08 06:51发布

问题:

How to make gradle to included some dependencies into module resulted jar as jar? i.e. to make jar with nested jar's e.g. in lib folder ?

This is not Android project, and this should be done for many modules in multi-module project, so fatJar, uberJar, shadowJar alike solutions seem not to fit.

回答1:

You just need to add an additional from directive to include dependencies in your jar:

task jarJar(type: Jar) {
    baseName = project.name + '-jarjar'
    from { configurations.compile }
    with jar
}