我不明白使用 Gradle / Maven 的意义。

huangapple go评论61阅读模式
英文:

I don't see the point of Gradle / Maven

问题

我不明白为什么有人想要使用像Gradle或者Maven这样的工具,我的意思是它们到底有什么作用?我试图理解并使用它们,但是我一无所获,它们只是不必要地使事情复杂化,并创建了许多看起来完全无用的文件。所以,为什么要费心使用这些工具,它们有什么用处呢?

英文:

I don't get why would anyone want to use tools like Gradle or Maven, I mean what do they even do? I tried to understand and use them but that got me no where they just unnecessarily complicate things and create a lot of what seems to be absolutely useless files.

So, why bother at all and use these tools and what are they good for?

答案1

得分: 2

首先,Gradle 和 Maven 是管理依赖项的绝佳工具,同时它们也为你提供了简化构建过程的选项。如果没有这些工具,你将不得不手动下载 *.jar 文件,并将它们复制到项目文件夹的某个位置。如果你想要更新,就必须再次打开网站,下载并替换现有的 JAR 包。

很多时候,这些 JAR 包本身有依赖关系,因此你还需要手动下载它们。

我能理解一开始设置 Maven / Gradle 可能会耗费时间,但通常这是值得的,因为你只需要声明:我需要版本为 1.2.3com.example.package,然后只需运行一个简单的安装命令,它们会负责下载所有所需内容。

其次,你可以声明命令来描述如何运行你的测试,它们通常会确保你的测试不会与最终编译的包混淆。

此外,这对于协作非常有益,因为一旦共享了这个配置,每个开发人员都可以在不必费力配置开发环境的情况下使用它。另一个好处是它与任何 IDE 无关,因此你的项目不是 IntelliJ 或 Eclipse 项目,每个人都可以使用他们喜欢的 IDE/编辑器。

**基本思想是:**你只需进行一次配置,然后就可以享受自动化带来的便利。

然而,如果你的项目非常小,只依赖很少的几个包,你可能不需要它。

英文:

First of all Gradle and Maven are great tools for managing your dependencies and also giving you the option to simplify your build process. Without these tools you would have to manually download *.jar files. And copy them somewhere in your project folder.
And if you want to update, you would have to open the website again, download it and replace your existing JAR.

Quite often JARs themself have dependencies, so you would have to manually download them as well.

I can understand that the setup of Maven / Gradle at first can be time consuming, but it's usually worth the time since you just have to declare: I need package com.example.package in version 1.2.3 and you just have to run a simple install command and they will take care of downloading everything needed.

Secondly, you can declare commands describing how to run your tests and they will usually take care of your tests not getting mixed up with your final and compiled package.

Also this is good for collaboration because once this config is shared, every developer can use it without going much of a hassle of configuring your development environment. Another good point is that it is independent of any IDE, so your project is not an IntelliJ or Eclipse project and everyone can use the IDE/editor they prefer.

Basically the idea is: You configure it once and then you can enjoy the automatism.

However, if your project is really small and relying on only a few dependencies you might not need it.

huangapple
  • 本文由 发表于 2020年10月14日 06:26:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/64344026.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定