javamavengradlejardependencies

How to bring all dependencies jars with Gradle?


I have simple java (Gradle) project which depends on several JARs, obtained automatically from Maven repositories.

Now I wish to call my jar with external application (MATLAB). Unfortunately, application does not see any dependencies after I call build, jar and similar goals.

Me myself also don't know dependencies, since they are managed automatically with Gradle and may contain nested dependencies, not listed in build.gradle.

Is it possible to collect all required JARs in one place to run them freely?


Solution

  • You can write a custom task to collect your runtime dependencies into a jar

    task copyToLib(type: Copy) {
        into "$buildDir/libs"
        from configurations.runtime
    }
    

    You could also look into the application and distribution gradle plugins, that provide similar packaging and distribution functionality