解决 intellij 插件构建时 gradle 下载缓慢的问题

Wuzi

October 2024, 18

3 min read

解决 intellij 插件构建时 gradle 下载缓慢的问题

Download IDE

在下载之前,需要知道IDE的的类型和版本,例如下面的片段

gradle.properties
1
...
2
3
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
4
platformType = IC
5
platformVersion = 2022.2.5
6
7
...

它一般会配置在 gradle.properties 文件. 当然这个也取决于自己的项目配置。但我相信这应该不会难到你。我们可以很轻松就得到这个上面两个信息。

我们一共需要下载两个文件,分别是:

  • IDE发行版(ideaIC-2022.2.5)
  • IDE发行版源码包(ideaIC-2022.2.5-sources.jar)

下载发行版

URL的格式为

1
https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/idea<platformType>/<platformVersion>/idea<platformType>-<platformVersion>.zip

带入类型和版本之后

1
https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIC/2022.2.5/ideaIC-2022.2.5.zip

文件下载完成以后,需要放到 gradle 目录

1
~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/idea<platformType>/<platformVersion>

带入类型和版本之后

1
~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.2.5

没有的话,需要先新建这个目录

然后计算下载的这个文件的SHA1值

在Windows可以使用计算

1
certutil -hashfile <path\to\ideaIC-2022.2.5.zip> SHA1

在macOS / Linux 可以使用计算

1
shasum -a 1 </path/to/ideaIC-2022.2.5.zip>

然后再刚才的

1
~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.2.5

下面在新建一个文件夹,文件夹的名字就是 计算出来的SHA1的值。

例如我们计算出来的SHA1是

1
836d1896d66b8d410f65d76e8cbc910b16d9edab

,新建文件夹之后,进入

1
~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.2.5/836d1896d66b8d410f65d76e8cbc910b16d9edab**

这个文件夹。然后把 ideaIC-2022.2.5.zip 放到这个文件夹里面。

下载发行版源码包

URL的格式为

1
https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/idea<platformType>/<platformVersion>/idea<platformType>-<platformVersion>-sources.jar

带入类型和版本之后

1
https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIC/2022.2.5/ideaIC-2022.2.5-sources.jar

文件下载完成以后,需要放到 gradle 目录

1
~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/idea<platformType>/<platformVersion>

带入类型和版本之后

1
~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.2.5

没有的话,需要先新建这个目录

然后计算下载的这个文件的SHA1值

在Windows可以使用计算

1
certutil -hashfile <path\to\ideaIC-2022.2.5-sources.jar> SHA1

在macOS / Linux 可以使用计算

1
shasum -a 1 </path/to/ideaIC-2022.2.5-sources.jar>

然后再刚才的

1
~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.2.5

下面在新建一个文件夹,文件夹的名字就是 计算出来的SHA1的值。

例如我们计算出来的SHA1是

1
d96d1896d66b8d410f65d76e8cbc910b16d9edac**

,新建文件夹之后,进入

1
~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.2.5/d96d1896d66b8d410f65d76e8cbc910b16d9edac**

这个文件夹。然后把 ideaIC-2022.2.5-sources.jar 放到这个文件夹里面。

Tweet this article