另一个针对Java的构建工具能给我带来什么?
如果你使用Gradle而不是其他工具,为什么?
另一个针对Java的构建工具能给我带来什么?
如果你使用Gradle而不是其他工具,为什么?
当前回答
Gradle put the fun back into building/assembling software. I used ant to build software my entire career and I have always considered the actual "buildit" part of the dev work being a necessary evil. A few months back our company grew tired of not using a binary repo (aka checking in jars into the vcs) and I was given the task to investigate this. Started with ivy since it could be bolted on top of ant, didn't have much luck getting my built artifacts published like I wanted. I went for maven and hacked away with xml, worked splendid for some simple helper libs but I ran into serious problems trying to bundle applications ready for deploy. Hassled quite a while googling plugins and reading forums and wound up downloading trillions of support jars for various plugins which I had a hard time using. Finally I went for gradle (getting quite bitter at this point, and annoyed that "It shouldn't be THIS hard!")
But from day one my mood started to improve. I was getting somewhere. Took me like two hours to migrate my first ant module and the build file was basically nothing. Easily fitted one screen. The big "wow" was: build scripts in xml, how stupid is that? the fact that declaring one dependency takes ONE row is very appealing to me -> you can easily see all dependencies for a certain project on one page. From then on I been on a constant roll, for every problem I faced so far there is a simple and elegant solution. I think these are the reasons:
Groovy对于Java开发人员来说非常直观 文档是非常棒的 灵活性是无限的
现在,我每天都在努力想出新功能来添加到我们的构建过程中。这有多恶心?
其他回答
Gradle put the fun back into building/assembling software. I used ant to build software my entire career and I have always considered the actual "buildit" part of the dev work being a necessary evil. A few months back our company grew tired of not using a binary repo (aka checking in jars into the vcs) and I was given the task to investigate this. Started with ivy since it could be bolted on top of ant, didn't have much luck getting my built artifacts published like I wanted. I went for maven and hacked away with xml, worked splendid for some simple helper libs but I ran into serious problems trying to bundle applications ready for deploy. Hassled quite a while googling plugins and reading forums and wound up downloading trillions of support jars for various plugins which I had a hard time using. Finally I went for gradle (getting quite bitter at this point, and annoyed that "It shouldn't be THIS hard!")
But from day one my mood started to improve. I was getting somewhere. Took me like two hours to migrate my first ant module and the build file was basically nothing. Easily fitted one screen. The big "wow" was: build scripts in xml, how stupid is that? the fact that declaring one dependency takes ONE row is very appealing to me -> you can easily see all dependencies for a certain project on one page. From then on I been on a constant roll, for every problem I faced so far there is a simple and elegant solution. I think these are the reasons:
Groovy对于Java开发人员来说非常直观 文档是非常棒的 灵活性是无限的
现在,我每天都在努力想出新功能来添加到我们的构建过程中。这有多恶心?
管理本地构建也容易得多。Ant和Maven实际上只支持java。存在一些Maven插件,试图处理一些本地项目,但它们没有有效地完成工作。可以编写Ant任务来编译本地项目,但它们太复杂和笨拙了。
我们用JNI和许多其他原生位来做Java。Gradle大大简化了我们的Ant混乱。当我们开始将依赖管理引入本地项目时,它很混乱。我们让Maven来做这件事,但等效的Gradle代码只是Maven所需要的一小部分,人们可以阅读和理解它,而不必成为Maven专家。
我自己并没有因为愤怒而使用Gradle(到目前为止只是一个玩具项目)[作者的意思是他们到目前为止只在一个玩具项目中使用过Gradle,并不是说Gradle是一个玩具项目-见评论],但我想说的是,人们考虑使用它的原因是Ant和Maven的挫折。
在我的经验中,Ant通常是只写的(是的,我知道可以编写漂亮的模块化、优雅的构建,但事实是大多数人不这样做)。对于任何重要的项目来说,它都是令人费解的,并且需要非常小心地确保复杂的构建是真正可移植的。它的命令性可以导致在构建之间复制配置(尽管宏在这里可以提供帮助)。
Maven采取相反的方法,并期望您完全集成到Maven生命周期中。有经验的Ant用户会发现这一点尤其不和谐,因为Maven删除了您在Ant中拥有的许多自由。例如,有一个Sonatype博客列举了许多对Maven的批评和他们的回应。
The Maven plugin mechanism allows for very powerful build configurations, and the inheritance model means you can define a small set of parent POMs encapsulating your build configurations for the whole enterprise and individual projects can inherit those configurations, leaving them lightweight. Maven configuration is very verbose (though Maven 3 promises to address this), and if you want to do anything that is "not the Maven way" you have to write a plugin or use the hacky Ant integration. Note I happen to like writing Maven plugins but appreciate that many will object to the effort involved.
Gradle有望达到Ant和Maven之间的最佳点。它使用Ivy的方法进行依赖项解析。它允许约定优于配置,但也将Ant任务作为第一类公民。它还明智地允许您使用现有的Maven/Ivy存储库。
So if you've hit and got stuck with any of the Ant/Maven pain points, it is probably worth trying Gradle out, though in my opinion it remains to be seen if you wouldn't just be trading known problems for unknown ones. The proof of the pudding is in the eating though so I would reserve judgment until the product is a little more mature and others have ironed out any kinks (they call it bleeding edge for a reason). I'll still be using it in my toy projects though, It's always good to be aware of the options.
我在一定程度上同意Ed Staub的观点。与maven相比,Gradle无疑更强大,从长远来看也提供了更多的灵活性。
在执行从maven到gradle的评估之后,我们决定在两个问题上坚持使用maven本身 我们遇到gradle(速度比maven慢,代理不工作)。
这不是我的答案,但它确实引起了我的共鸣。这是来自ThoughtWorks 2012年10月的“技术雷达”:
Two things have caused fatigue with XML-based build tools like Ant and Maven: too many angry pointy braces and the coarseness of plug-in architectures. While syntax issues can be dealt with through generation, plug-in architectures severely limit the ability for build tools to grow gracefully as projects become more complex. We have come to feel that plug-ins are the wrong level of abstraction, and prefer language-based tools like Gradle and Rake instead, because they offer finer-grained abstractions and more flexibility long term.