Gradle stores downloaded JAR files in a directory known as the dependency cache, which is typically located in the .gradle/caches folder under the user's home directory. Specifically, dependencies are stored in the modules-2/files-2.1 directory.
In this cache directory, Gradle organizes JAR files by different organizations and modules. For example, if your project depends on org.apache.commons:commons-lang3:3.9, Gradle stores the JAR file and its associated metadata in the modules-2/files-2.1/org.apache.commons/commons-lang3/3.9 directory.
The key advantage of this caching mechanism is improved build efficiency. When you rebuild the project or build other projects that depend on the same dependencies, Gradle can reuse the downloaded dependencies instead of downloading them again from remote repositories, which significantly speeds up the build process.
For instance, in a large Java project I worked on, which depended on hundreds of third-party libraries, leveraging Gradle's dependency caching mechanism meant that the initial build took a long time to download all dependencies, but subsequent builds reduced by approximately 60% or more, as most dependencies can be retrieved directly from the local cache, significantly improving development efficiency and team collaboration speed.