In which scenario will gradle store artifacts in the directory .m2
and in which scenario will it store them in gradle\caches
?
I am trying to resolve my issue wherein I have a dependency within my local build
Gradle caches artifacts in USER_HOME/. gradle folder.
If no settings. xml is available, Gradle uses the default location USER_HOME/. m2/repository . Note, however, that Gradle cautions against using the local Maven repository unless you really need it.
Gradle will use its own internal cache for all resolved dependencies, including ones coming from the local maven repository. For example, if you use a dependency org:foo:1.0 from your maven local repository, the metadata and artifact will be copied to the Gradle cache on first resolution.
Gradle supports a local and a remote build cache that can be configured separately. When both build caches are enabled, Gradle tries to load build outputs from the local build cache first, and then tries the remote build cache if no build outputs are found.
Gradle will read from your local maven repository only when you declare it as a valid repository:
repositories {
mavenLocal()
}
Gradle will write to your local maven repository only when you publish artifacts and tell it to publish to the local maven repo.
maven
plugin, when executing the task install
maven-publish
plugin, when executing the task publishToMavenLocal
Gradle will use its own internal cache for all resolved dependencies, including ones coming from the local maven repository.
For example, if you use a dependency org:foo:1.0
from your maven local repository, the metadata and artifact will be copied to the Gradle cache on first resolution. From then on, the dependency will be resolved from the Gradle cache.
However, if the dependency is changing, such as when using a -SNAPSHOT
version, the Gradle cache will by default keep the last one resolved for 24h. After which it will perform a new resolution, hitting again the local maven repository in this example.
See the documentation for controlling that cache duration for dynamic and/or changing dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With