有哪些好的 java make 实用程序?
我正在寻找一个用于构建大型 java 程序的 make 实用程序。 我已经知道 ANT,但想看看还有什么可用的。
理想情况下,它应该能够处理导致 GNU Make 混乱的 .java->.class 包目录怪异现象。
Win32,但跨平台是一个优点。
编辑: 我看到使用 ANT 的一些缺点,这就是为什么我想看到其他选项,尽管我可能最终会使用它,只是因为它有效。
- 需要不平凡的 XML makefile,“HelloWorld”已经有 25 行,任何更合理的程序都会很快变得很大。
- ant 教程显示了 ant build.xml 文件的比较,这些文件与仅运行所有 java 命令的大 .bat 文件大致相同,只是更长。 http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html ,我已经有了其中之一。
- Xml 意味着每个依赖项、变量、目标、规则和项目都有额外的缺陷,它只会使行难以阅读。 尖括号税
- 为我解决了所有错误的问题。
- ant 使编写 jar 和 javac 命令行更容易,生成清单更容易,指定 .java 源文件更容易,指定 jvm/java 属性更容易,编写自定义构建工具更容易。
- ant 并没有使 java 类依赖关系变得更容易,并且似乎没有更强大的变量系统,这两件事通常通过 make 实用程序来解决。
我会使用 gnu make,但它无法弄清楚带有包声明的 .java 文件的 .class 文件将在哪里结束。
I'm looking for a make utility for building large java programs. I'm aware of ANT already, but want to see what else is available.
Ideally, it should be able to handle the .java->.class package directory weirdness that fouls up GNU Make.
Win32, but cross platform is a plus.
EDIT:
I see some cons to using ANT, which is why I wanted to see other options, though I'll probably end up using it anyway, just because it works.
- requires nontrivial XML makefiles, "HelloWorld" is already 25 lines, and any more reasonable program gets large quickly.
- The ant tutorials show comparisons of ant build.xml files that are roughly identical to big .bat files that just run all the java commands, only longer. http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html, I've already got one of those.
- Xml means that every single dependency, variable, target, rule and project has extra cruft on it, it just makes lines hard to read. The Angle Bracket Tax
- solves all the wrong problems for me.
- ant makes writing jar and javac command lines easier, generating manifests easier, specifying .java source files easier, specifying jvm/java properties easier, writing custom build tools easier.
- ant does not make java class dependencies easier, and does not seem to have a more powerful variable system, both things usually solved by make utilities.
I'd use gnu make, but it can't figure out where the .class file for a .java file with a package declaration is going to end up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
Ant和Maven绝对是两个标准。 如果您已经熟悉 Ant 并且想要 Maven 附带的依赖管理,您可以看看 Ivy< /a>.
Ant 和 Maven 缺乏的一件事是构建脚本中真正的控制结构。 您可以下载一些 Ant 插件来提供一些此类控制,但是(同样,如果您已经熟悉 Ant)您可以查看 Gant 这是 Ant 的 Groovy 包装器。
Ant and Maven are definitely the two standards. If you're already familiar with Ant and want the dependency management that comes with Maven, you might take a look at Ivy.
One thing both Ant and Maven lack is true control structures in your build scripts. There are plugins you can download for Ant that provide some of this control, but (again, if you're already familiar with Ant) you may take a look at Gant which is a Groovy wrapper for Ant.
如果您正在开始一个新项目,您可能需要查看 maven。 最初有点困难,但它可以为您处理很多事情,包括依赖项。
如果您已经有一个想要为其创建构建文件的项目,那么除了前面提到的 ant 之外,我没有任何建议。
If you're starting a new project you may want to look into maven. It's kinda hard intially, but it handles a bunch of stuff for you including dependencies.
If you already have a project which you want to make a build file for, then I don't have any recommendations apart from the aforementioned ant.
忘掉 ANT!!
Apache Maven 如果你问我的话,那就是正确的选择。
我最喜欢的功能是它内置于依赖管理中。
这意味着您不必将第 3 方 JAR 检入您的源代码控制项目。
您在 Maven POM(项目对象模型 - 基本上是项目的 XML 描述)中指定依赖项,maven 会自动下载、编译它们并将它们与您的应用程序打包在一起。
其他非常好的功能是:
发布管理和分发发布
- 使用 Maven 控制台命令执行发布。 此功能将在源代码管理中标记您的代码库。 签出一个干净的副本,构建它并创建它。 将其打包以进行部署。 第二个命令会将其上传到您的存储库,以便分发给其他最终用户。
已经使用 Maven 的大型且不断增长的库存储库
- 每个 Apache 项目都使用 Maven。 船上还有更多人。 亲自看看,这是主要的存储库
能够托管自己的存储库。
- 您可以在其中发布自己的构建,还可以上传其他公共存储库中不存在的 JAR(如大多数 SUN jar)
Forget ANT!!
Apache Maven is the way to go if you ask me.
The feature i like the most is it built in in dependency management.
This means you dont have to check 3rd party JARs into your source control project.
You specify your dependencies in the maven POM (Project Object Model - Its basically an XML description of your project) and maven automatically downloads, compiles against them and packages them with your app.
Other really nice features are:
Release management and distribution publication
- Perform releases using maven console commands. This feature will tag your code base in source control. Checkout a clean copy, build it & package it for deployment. A second command will upload it to your repository for distribution to other end users.
A large and growing repository of libraries already using maven
- EVERY Apache project uses maven. LOADS more are on board also. See for yourself, here's the main repo
Ability to host your own repo.
- Where you can release your own builds and also upload JARs that dont exist in other public repos (like most SUN jars)
这与其说是一个答案,不如说是一个问题。 ANT 是构建 Java 的标准方法。 它与 Java、无数的 Java 工具以及 Cruise Control 配合得很好。 那么你为什么想尝试其他事情呢?
除非您遇到 ANT 无法覆盖的边缘情况,否则我建议您坚持使用 ANT。
当然,我很高兴有一个更有知识的人指出为什么我的态度是愚蠢的以及为什么有一个很好的理由来寻找替代方案;)
This isn't so much an answer as a question. ANT is the standard way of building Java. It works well with Java, the myriad of Java tools out there and with Cruise Control. So why would you want to try anything else?
Unless you have an edge case that ANT doesn't cover, then I'd recommend you stick with ANT.
Of course I'd be happy for a more knowledgeable person to point out why my attitude is stupid and why there is a good case for looking at alternatives ;)
如果你想要一些非常轻量级的东西,另一种选择是 scons 。 我使用过它一点,发现它非常容易理解,特别是如果你已经了解 python 语法的话。 另一个选择是 maven,但无论如何它都不简单。 但是,它确实提供了许多附加功能,例如帮助管理文档。 不过,我不会将其称为 make 替代品;)
One alternative is scons if you want something pretty lightweight. I've used it a little and found it to be pretty easy to understand, especially if you already know python syntax. Another option is maven, but it is not simple by any means. However, it does provide a lot of additional facilities such as helping to manage docs. I wouldn't refer to it as a make replacement however;)
蚂蚁金服多年来一直处于领先地位。 但它的 build.xml 是基于 xml 的,所以非常冗长。 通过与ivy耦合可以实现依赖管理。
maven 致力于提供 ant+ivy tandem 所提供的开箱即用的功能,它在工作时很好。 如果它停止这样做,并且您必须找出它在依赖管理方面造成的混乱,那么这很可能是您可以想象的最糟糕的地狱。 还有pom.xml...是用xml编写的。
sbt是皇家scala构建工具,使用ivy进行依赖管理,构建文件是用scala DSL编写的。 相当成熟,但 scala 方言可能不合你的口味。
buildr 构建文件在 ruby 中指定。 与 Maven 存储库兼容并自带依赖管理。 Ant 集成也在那里。
gradle 使用 groovy 作为其构建文件。 除了 Maven 或 ivy 支持之外,在过去使用 ivy 但不满意之后,它现在有了自己的依赖管理器。 无缝蚂蚁集成。 具有迄今为止最简单的语法。
ant、ivy、maven、buildr 是 apache 项目。
TL;DR
检查 gradle 或 构建器。
ant has been the leader for years. But its build.xml being, well, xml-based, it is very verbose. Dependency management can be achieved by coupling it with ivy.
maven strives to provide out of the box what the ant+ivy tandem provides, it is nice while it works. If it stops doing that and you have to find out where it messes up with dependency management, it may very likely be the worst hell you can imagine. Also it's pom.xml... is written in xml.
sbt is the royal scala build tool, uses ivy for dependency management, and the build files are writen in a scala DSL. Quite mature, but the scala dialect may not be to your liking.
buildr build files are specified in ruby. Compatible with maven repositories and brings it's own dependency management. Ant integration is there, too.
gradle uses groovy for its build files. Beside maven or ivy support it has it's own dependency manager now after having used ivy in the past and not being satisfied. Seamless ant integration. Has the easiest syntax by far.
ant, ivy, maven, buildr are apache projects.
TL;DR
Check gradle or buildr.
jmk。 它很原始,但很小,您可以将其嵌入到源 .tar.gz 文件中并且几乎不改变其大小。
jmk. It's primitive, but so small that you can embed it in a source .tar.gz file and barely change its size.
除非 Maven 最近确实有所改进,否则我会避开它。 当然,除非您有某种具有无数依赖项的怪物“多项目”。
在尝试做最简单的事情(例如通过 FTP 将
war
文件传输到服务器)时看到完全无用且无益的错误后,Maven 被抛弃,Ant 也被抛弃。 从那以后我就没有回头。Unless Maven has really improved recently, I'd steer well clear of it. Unless you have some kind of monster "multi-project" with a gazillion dependencies of course.
After getting sick of looking at completely useless and unhelpful errors when attempting to do the simplest things (like FTP a
war
file to a server), Maven was thrown away and Ant dusted off. I haven't looked back since.嗯,显然,有经典的 make(make、gmake、nmake)实用程序,还有(我认为)一些用 Ruby 或 Python 编写的构建系统。 它们不是特定于 Java 的,而只是可编写脚本的构建系统。
但 ANT 已经成为该领域的领导者,已经有 8-9 年的历史了,而且就基础知识而言,它非常容易上手。
过去,make from 对于编译 java 来说特别糟糕,因为它通常为每个文件单独调用 javac 编译器。 ANT 不会受到这个问题的影响,并且也许可以修改 make 来避免这样做。 但这是 ANT 如此受欢迎的要素之一。 简直太快了。
我知道 ANT 可能不是完美的解决方案,但它确实实用。
Well, obviously, there's the classic make (make, gmake, nmake) utilities, there's also (I think) some build systems written in Ruby, or maybe Python. They aren't Java specific, rather just scriptable build systems.
But ANT has been the leader of the pack pushing 8-9 years now, and in terms of the basics, it's pretty easy to get started with.
Back in the day, make from particularly horrible for compiling java because it was typically invoking the javac compiler for each file individually. ANT doesn't suffer from this, and, perhaps, make could be modified to not do that. But it was one of the elements of ANT that made it so popular. It was simply fast.
I appreciate that ANT may not be the perfect solution, but it sure it practical.
我从 Ant 转换为 Maven 2 从那以后就再也没有回头过。 Ant 和 Maven 2 种不同的构建方式。使用 Ant,您可以给出有关如何构建事物的说明。 而在 Maven 2 中,您可以告诉它您想要构建什么。 如果您有现有的 Ant build.xml,您可以通过将其包装在 Maven 2 pom.xml 中来重构您的构建。
I converted from Ant to Maven 2 and have not looked back since. Ant and Maven 2 different ways of building.With Ant you are giving instructions on how to build things. Whereas with Maven 2 you tell it what you want built. If you have an existing Ant build,xml you can take a first step in refactoring you build by wrapping that in an Maven 2 pom.xml.
1)如果你已有ant的投资,ant + ivy是相当不错的。 您不必仅仅为了依赖项而从 ant 迁移到 Maven。
2)gant和ant:它们如何比较:http://java .dzone.com/articles/ant-or-gant-part-1
3) http://www .gradle.org/——使用groovy!
BR,
~A
1) ant + ivy is pretty good if you have existing investment in ant. You don't have to move from ant to maven just for the dependency goodies.
2) gant and ant : how do they compare : http://java.dzone.com/articles/ant-or-gant-part-1
3) http://www.gradle.org/ -- uses groovy!
BR,
~A
我喜欢将 ant 与 ant4eclipse 一起使用。 这允许我在 Eclipse 中设置依赖项,在 Eclipse 中进行开发构建和测试,并使用 ant 进行连续构建。
I like to use ant with ant4eclipse. This allows me to set up dependencies in eclipse, do development builds and testing in eclipse, and do continuous builds using ant.
我一直用ANT。 这是因为我使用 Google Web Toolkit (GWT) 开发 Web 应用程序,它有一个将客户端 java 编译为 java 脚本的额外步骤。 对于 ant,我只需要知道 GWT 是如何工作的,然后我自己编排构建。 使用maven,我必须等到有人写插件。 或者我自己写一篇。 有可能会出现其他不遵循通常约定的框架和工具。 我不必一直寻找 Maven 插件。 有了ant,我可以以透明的方式做任何我想做的事情。 我也喜欢编写 xml 文件。 (我必须这样做,因为我必须编写几个 - web.xml、application.xml、persistence.xml、SqlMap.xml、dataset.xml 等我的观点 _ XML 是你必须学会喜欢的一件事)
I use ANT all the time. This is because i develop web applications using Google Web Toolkit (GWT) which has an extra step of compiling client side java into java script. With ant, all i needed to know is how GWT works and then i orchestrate the build myself. With maven, i have to wait till someone writes a plugin. or i write one myself. There is a possibility that other frameworks and tools that dont follow the usual conventions will come up. i dont have to keep looking for maven plugins all the time. With ant, i can do whatever i want in a transparent manner. I also enjoy writting xml files. (i have to because i have to write several - web.xml, application.xml, persistence.xml, SqlMap.xml, dataset.xml e.t.c. My point _ XML is one thing you have to learn to like)