Search code examples
javagradledependencies

Gradle: what are Dependencies?


Learning gradle, it seems to be a build tool for Java. But i'm confused to what dependencies really is. What do dependencies section in Gradle really mean? What purpose does it serves?


Solution

  • Your software depends on other software

    A dependency is simply a piece of software that you want to call from your own code. So, your software depends on that other software.

    A transitive dependency is yet another piece of software used by one of your dependencies. So, your software depends on some other software that depends on some other software.

    You simply tell Gradle what software you want to call upon. Gradle takes care of locating a copy of that software in a Maven repository (a centralized catalog of publicly available software), downloading a copy across the Internet, and making that downloaded copy available to your own code in your project. Gradle also takes care of determining transitive libraries that are needed by the libraries you need. Those get downloaded for you as well.

    👉🏽 Using Gradle saves you the trouble of manually locating and copying the needed software yourself.

    As a build automation tool, Gradle manages your software dependencies as part of its duties. Gradle also compiles your code, and packages your compiled code into an artifact such as a JAR file or WAR file.

    You may browse a Maven repository to see the millions of available pieces of software.


    By the way, Maven is both a dependency management tool and a build automation tool. Maven has been quite successful at both. However, Gradle has been growing in popularity as an alternative build automation tool. For its dependency management part, Gradle leverages existing Maven repositories rather than re-inventing the wheel.