gradle何时存储在.m2中,何时存储在缓存中? [英] When does gradle store in .m2 and when in cache?

查看:530
本文介绍了gradle何时存储在.m2中,何时存储在缓存中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪种情况下,应将工件存储在目录.m2中,并且在哪种情况下,会将工件存储在gradle\caches中?

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才会从本地maven存储库中读取 :

Gradle will read from your local maven repository only when you declare it as a valid repository:

repositories {
    mavenLocal()
}

只有当您发布工件并将其发布到本地Maven存储库中时,Gradle才会写入到本地Maven存储库.

Gradle will write to your local maven repository only when you publish artifacts and tell it to publish to the local maven repo.

  • If you are using the maven plugin, when executing the task install
  • If you are using the maven-publish plugin, when executing the task publishToMavenLocal

Gradle将使用其自己的内部缓存来解决所有的依赖关系,包括来自本地maven存储库的依赖关系.

Gradle will use its own internal cache for all resolved dependencies, including ones coming from the local maven repository.

例如,如果您使用maven本地存储库中的依赖项org:foo:1.0,则元数据和工件将在第一个分辨率下复制到Gradle缓存中.从那时起,依赖关系将从Gradle缓存中解决.

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.

但是,如果依赖关系发生变化,例如使用-SNAPSHOT版本,则Gradle缓存默认情况下会将最后一个解析时间保持24小时.之后,它将执行新的解决方案,在此示例中,再次单击本地Maven存储库.

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.

这篇关于gradle何时存储在.m2中,何时存储在缓存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆