问题描述
我已经用摇篮作为构建系统最近开始。
他们首先比较的摇篮与Ant和Maven的喜欢使的是,
Ant是一个的必须的构建系统,而Maven是一个 声明的构建系统。
尽管摇篮是的声明的构建系统而不会被强制执行的Maven的刚性。
I have recently started using Gradle as a build system.They first comparison that Gradle makes with the likes of Ant and Maven is that,Ant is an imperative build system, whereas Maven is a declarative build system.While Gradle is a declarative build system without the rigidity enforced by Maven.
我想了解这些术语的声明的和的必须的时候还谈到构建系统。更好
I wanted to understand these terms declarative and imperative better when it comes to talking about build systems.
推荐答案
在总之,Ant脚本告诉Ant工具做什么 - 编译这些文件,然后将它们复制到该文件夹。然后利用这个文件夹的内容,并创建归档。
In short, an ant script tells the ant tool what to do - "compile these files and then copy them to that folder. Then take the contents of this folder and create an archive."
虽然行家 POM
声明的我们想什么,有作为结果 - 这里有项目依赖于库的名称,我们希望生成一个Web归档。行家知道如何获取库和在哪里可以找到它自己的源类。
While a maven pom
declares what we would like to have as the result - "here are the names of the libraries the project depends upon, and we would like to generate a web archive". Maven knows how to fetch the libraries and where to find the source classes on it's own.
虽然蚂蚁为您提供了更大的灵活性,这也迫使你不断推倒重来。
While ant gives you more flexibility, it also forces you to constantly reinvent the wheel.
Maven的另一边需要较少的配置,但可能会觉得太制约,特别是如果你使用一个不同的工作流程。
Maven on the other side requires less configuration, but may feel too constraining, especially if you are used to a different workflow.
编辑:蚂蚁行家比较的一个重要方面是,Maven有一个会议,描述那里的文件应该说谎,那里的依赖关系被发现,哪里把所得到的神器,而蚂蚁没有。
An important aspect of the ant-maven comparison is that maven has a convention, describing where the files should lie, where the dependencies are found, where to put the resulting artifact, while ant does not.
所以你可以考虑使用像坐上公共汽车行家 - 你选择你进入停止并在你离开的人。使用Ant就像驾驶汽车 - 你必须自己做。你不必告诉公交车司机做什么,但停止可能从那里你要适可而止。
So you can think of using maven like riding a bus - you select the stop where you enter and the one where you leave. Using ant is like driving a car - you have to do it yourself. You dont have to tell the bus driver what to do, but the stops may be too far from where you want to go.
EDIT2:重新发明轮子的比喻似乎比我所希望的那么清楚。这就是我的意思是:
'Reinventing the wheel' metaphor seems to be less clear than I had hoped. This is what I mean:
如果没有合理的默认值/约定,你必须明确地定义项目结构和构建生命周期为每一个项目,往往使得它的口味和舆论的问题。作为preferences团队和公司有所不同,因此做的构建过程中。这需要新的项目成员,后来维护者更多的认知努力。根据开发商的经验和专业知识,最终的解决方案可能很难扩展和使用。
Without sensible defaults/conventions, you have to define the project structure and the build lifecycle explicitly for each project, often making it a matter of taste and opinion. As preferences vary between teams and companies, so do build processes. This requires more cognitive effort for new project members and later maintainers. Depending on the experience and expertise of the developers, the final solution may be hard to extend and use.
我在下面留言说,虽然建立存在蚂蚁的最佳实践,他们仍然有每个项目的实施,还是从项目复制粘贴的项目,而不是成为外装即用的默认的构建工具本身。
As I said in a comment below, while best practices for ant builds exist, they still have to be implemented for each project, or copy-pasted from project to project, instead of becoming an out-of-the-box default of the build tool itself.
Maven是一个位在权衡对我的口味的另一边太远。更改默认设置是不容易,因为它可以和应该的。
Maven is a bit too far on the other side of the trade-off for my taste. Changing the defaults is not as easy as it could and should be.
这篇关于当务之急VS声明构建系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!