How to include sub-project jar files in main jar

I have a project set-up, with a main project and a number of sub projects. The projects are organized in a flat file system.

In the MainProject settings.gradle I have something like:

includeFlat "SubProjectA", "SubProjectB"

In the MainProject build.gradle I have specified the project dependencies like:

dependencies {
    compile 'org.projectlombok:lombok:1.12.2'
    compile fileTree(customCfg.oracleJdbc).include('**/*.jar')
    compile project(':SubProjectA')
     compile project(':SubProjectB')

In the resulting MainProject.jar jar files for Lombok and the OracleJdbc are included. But how do I make Gradle include the jar files for SubProjectA and SubProjectB?

Dependencies aren’t included automatically. To include all runtime dependencies:

jar {
    from configurations.runtime

If some dependencies are included already, you have to be careful not to end up with duplicates, for example by including every dependency just once, or by setting ‘jar.duplicatesStrategy’ (see Gradle Build Language Reference for details).

Well, that sure included a lot of Jar files!! :smiley:

Thank you for your fast reply, Peter!