Skip to content

Instantly share code, notes, and snippets.

@CrazyBoyFeng
Last active August 14, 2021 17:49
Show Gist options
  • Select an option

  • Save CrazyBoyFeng/936680de7dd0a7cdd5558c7ba6e8fe84 to your computer and use it in GitHub Desktop.

Select an option

Save CrazyBoyFeng/936680de7dd0a7cdd5558c7ba6e8fe84 to your computer and use it in GitHub Desktop.
我讨厌 Gradle!!!I HATE Gradle!!!

我讨厌 Gradle!!!

我只是需要比 Maven 更快的工具而已。

资源占用

Gradle 在我的电脑上占用的内存甚至超过了 IDE。而且经常在编辑代码时占满 CPU。
同时打开多个 Gradle 项目时,它占用的资源成倍增长。

在开发小型项目时,尤其能感受到 Gradle 的庞大和笨重。

过于灵活

使用脚本而不是一种固定的格式来进行构建,非常灵活,能满足各种需求,但没有必要。
构建过程虽然复杂,但总的范式都是一样的,都是:编译、打包、发布……无非是细节的区别。
这种复杂度还不至于使用脚本。而且绝大多数开发者也都没有这种复杂需求。
即便有这种复杂的个性化需求,可以用插件的形式实现,就像 Maven 那样。

在多人协作时,过于灵活就意味着个人风格浓厚,别人可能就看不懂。

难以调试

使用动态语言脚本进行构建的另一个缺点就是:IDE 检查不了其中的错误,同时智能化提示也很逊。
这在换用 Kotlin 之后有所改善。

以前版本的 Gradle 的出错信息特别简陋。
甚至无法从出错信息判断问题在哪。
这随着 Gradle 的版本升级也逐渐有所改善。

不够稳定

Gradle 版本日新月异。还经常有破坏性更新,不兼容之前的版本。

在多人协作时,这个问题尤其明显。团队需要先开会约定 Gradle 版本。

当有插件要求使用指定版本,或者与其它团队合作,或者引入第三方模块时,就会陷入适配工作的地狱。

Wrapper

Gradle 团队也知道不同版本之间兼容性太差是个大问题,所以他们推出了 Wrapper。 Wrapper 像病毒一样在所有人的电脑上复制、传播它的二进制文件。
甚至通过修改 distributionUrl 就能传播真正的恶意软件。

然而这也没解决核心问题:Gradle 不同版本之间的兼容性太差。 它只是使同一个 Gradle 版本在协作时能部署得更方便而已。

如果我们打开过很多 Gradle 项目,最终我们的电脑上会同时存在很多不同版本的 Gradle。
每个版本的 Gradle 还有属于它自己的单独的依赖缓存。 占用掉巨量的硬盘空间。

而且这个 Wrapper 非常鸡肋。它用来帮助在没有 Gradle 的电脑上自动安装 Gradle。但是运行它需要先安装 JRE 或 JDK。
如果是在 IDE 里,那么根本没必要到处放一个 Wrapper,只需要定义 URL 或者仅仅定义 Gradle 版本即可。
如果是单独使用,且不说这种情况非常少见。即便真的需要单独使用,那这台电脑仍然需要手动安装 JRE 或 JDK。最终也并没有真的省事。
用户既然会手动安装 Java,为什么不会,或者不能手动安装 Gradle 呢?

I HATE Gradle!!!

I just need a tool that is faster than Maven.

Resource Hog

Gradle uses more memory on my computer than even the IDE, and often fills up the CPU while editing code.
When multiple Gradle projects are open at the same time, it takes up exponentially more resources.

The huge and heavy weight of Gradle is especially noticeable when developing small projects.

Too Flexible

Using scripts instead of a fixed format to build is flexible enough to meet various needs, but not necessary.
The build process is complex, but the general paradigm is the same: compile, package, release, etc... It's just the details that make the difference.
This complexity is not enough to use scripts. And almost all the developers don't have such complex needs either.
Even if they do have such complex and individual needs, they can be implemented in the form of plugins, as Maven does.

When working with multiple people, too much flexibility means a strong personal style that others may not understand.

Difficult To Debug

Another disadvantage of building with dynamic language scripts is that the IDE doesn't check for errors and the intelligent hints are lame.
This has improved since switching to Kotlin.

The error messages in previous versions of Gradle were very sketchy.
You couldn't even tell where the problem was from the error messages.
This has gradually improved as Gradle has been upgraded.

Not Stable

Gradle versions change very fast. There are also frequent breaking updates that are not compatible with previous versions.

This is especially a problem when working with multiple people. The team needs to meet first to agree on a Gradle version. When a plugin requires a specific version, or collaborates with other teams, or brings in third-party modules, it can be a hell of an adaptation effort.

Wrapper

The Gradle team also knew that poor compatibility between versions was a big problem, so they introduced Wrapper. Wrapper copies and spreads its binaries like a virus on everyone's computer.
It can even spread real malware by modifying distributionUrl.

However, this does not solve the core problem: compatibility between different versions of Gradle is too poor. It just makes it easier to deploy the same Gradle version when collaborating.

If we opened many Gradle projects, we would end up with many different versions of Gradle on our computers at the same time.
Each version of Gradle also has its own separate dependency cache. They take up a lot of disk space.

And this Wrapper is very weak. It is used to help install Gradle automatically on computers without Gradle, but to run it you need to install JRE or JDK first.
If it is in the IDE, there is no need to put a Wrapper everywhere, just define the URL or just define the Gradle version.
If it's used as a standalone, which is very rare, there is no need to put a Wrapper everywhere, too. Even if it does, the computer still needs to have a JRE or JDK installed manually, which doesn't really save you any time in the end.
If the user can install Java manually, why not, or why cannot, install Gradle manually?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment