Gradle缓存目录文件命名规则

Posted 南极冰川雪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Gradle缓存目录文件命名规则相关的知识,希望对你有一定的参考价值。

在打开android Studio项目的时候,会下载项目对应版本的gradle,该版本是在项目根目录下\\gradle\\wrapper\\gradle-wrapper.properties文件中指定的:

下载的gradle文件在Windows电脑上会缓存在C:\\Users\\xxx(用户名)\\.gradle\\wrapper\\dists\\gradle-3.3-all\\55gk2rcmfc6p2dg9u9ohc3hw9目录下

那这个目录名55gk2rcmfc6p2dg9u9ohc3hw9是根据什么规则生成的呢?看似没有规律,研究了一下,发现也是按照一定规则生成的,如下:

1.从gradle/wrapper/gradle-wrapper.properties中得到distributionUrl,即https://services.gradle.org/distributions/gradle-3.3-all.zip,注意文件中的\\不算

2.对distributionUrl进行MD5运算

3.根据MD5值构造一个uint 128位整数

4.将整数利用base36得到base36的值(取小写)

java代码如下:

 public static String getFileName(String distributionUrl)
    {
        MessageDigest messageDigest = null;
        try
        {
            messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.update(distributionUrl.getBytes());
            String str = new BigInteger(1, messageDigest.digest()).toString(36);
            return str;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }

 

distributionUrl

base36

https://services.gradle.org/distributions/gradle-4.7-all.zip

4cret0dgl5o3b21weaoncl7ys

https://services.gradle.org/distributions/gradle-4.6-all.zip

bcst21l2brirad8k2ben1letg

https://services.gradle.org/distributions/gradle-4.5.1-all.zip

87kuriyahurjjkki3zii366f2

https://services.gradle.org/distributions/gradle-4.5-all.zip

cg9lyzfg3iwv6fa00os9gcgj4

https://services.gradle.org/distributions/gradle-4.4.1-all.zip

2kpyt0ea6hyxavvt21uml23gd

https://services.gradle.org/distributions/gradle-4.4-all.zip

9br9xq1tocpiv8o6njlyu5op1

https://services.gradle.org/distributions/gradle-4.3.1-all.zip

97nfwr7im082t7xwc6bkwfrg9

https://services.gradle.org/distributions/gradle-4.3-all.zip

2c1rgv6vofd95kl0ugolfeu5r

https://services.gradle.org/distributions/gradle-4.2.1-all.zip

domrskppdhf3wtn5mziw0c2zr

https://services.gradle.org/distributions/gradle-4.2-all.zip

35kgqhc6h01n0g1he8zslvs9l

https://services.gradle.org/distributions/gradle-4.1-all.zip

bzyivzo6n839fup2jbap0tjew

https://services.gradle.org/distributions/gradle-4.0.2-all.zip

680wmhe205zg4atnbsmvvt28p

https://services.gradle.org/distributions/gradle-4.0.1-all.zip

26awvqv6f41r14q9x72t4n0s

https://services.gradle.org/distributions/gradle-4.0-all.zip

ac27o8rbd0ic8ih41or9l32mv

https://services.gradle.org/distributions/gradle-3.5.1-all.zip

42vjebfdws9pjts3l4bouoq0p

https://services.gradle.org/distributions/gradle-3.5-all.zip

exhrs6ca08n232b14ue48lbye

https://services.gradle.org/distributions/gradle-3.4.1-all.zip

c3ib5obfnqr0no9szq6qc17do

https://services.gradle.org/distributions/gradle-3.4-all.zip

4bi7dnjj1pmknw0wphqavp2sz

https://services.gradle.org/distributions/gradle-3.3-all.zip

55gk2rcmfc6p2dg9u9ohc3hw9

https://services.gradle.org/distributions/gradle-3.2-all.zip

97ld1dyml0oep92x4lyn4g235

https://services.gradle.org/distributions/gradle-3.1-all.zip

ejgglywf033yp6s4x8ahmgm74

https://services.gradle.org/distributions/gradle-3.0-all.zip

6v8c6qg2jpi8twyfv2a5s9mii

https://services.gradle.org/distributions/gradle-2.14.1-all.zip

8bnwg5hd3w55iofp58khbp6yv

https://services.gradle.org/distributions/gradle-2.14-all.zip

t7wfomcrmv8dmyii9c9waem8

https://services.gradle.org/distributions/gradle-2.13-all.zip

1b9wlm73elu4cqnbc0rk7r7qn

https://services.gradle.org/distributions/gradle-2.12-all.zip

8ywkdai6puj5z81fume4e7njw

https://services.gradle.org/distributions/gradle-2.11-all.zip

ace7yl0a7udokebb27mt9s3qr

https://services.gradle.org/distributions/gradle-2.10-all.zip

a4w5fzrkeut1ox71xslb49gst

 

以上是关于Gradle缓存目录文件命名规则的主要内容,如果未能解决你的问题,请参考以下文章

Mac递归删除指定目录及其子目录下所有符合给定命名规则的文件

IDEA项目Gradle文件不在Git上传规则中被标红

设置gradle默认缓存文件路径-(笔记)

如何清除gradle缓存?

前端编码规范

gradle用户目录本地库移动设置