Java轻量级构建工具
我正在寻找一个轻量级的 Java 构建工具。尽可能轻。即使以牺牲功能为代价。有什么建议吗?
I am looking for an lightweight Java build tool. As light as possible. Even at the expense of features. Any recommendations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
尽可能轻?那必须是从批处理文件或 shell 脚本中运行的 javac。
但为什么?
As light as possible? That must be javac running from within a batch file or shell script.
But why?
实际上只有两个选择:Ant 或 Maven。
Ant 本质上是一个脚本工具,您可以用它做任何事情,但您必须自己编写所有内容。
Maven 附带了许多预定义的项目类型。它会向你规定一个目录结构(有些人不喜欢),但也会处理依赖关系(Ant 可以用 Ivy 来做到这一点)。
我个人更喜欢Maven。几行 XML 即可让您执行运行单元测试、停止和启动 Web 容器(例如 Jetty 或 Tomcat)等任务。
There are only really two choices: Ant or Maven.
Ant is essentially a scripting tool that you can do anything with but you have to write everything yourself.
Maven comes with a lot of predefined project types. It will dictate a directory structure to you (which some people don't like) but will also handle dependencies (which Ant can sorta do with Ivy).
Personally I prefer Maven. A few lines of XML will get you the tasks to run unit tests, stop and start a Web container (eg Jetty or Tomcat), etc.
正如其他地方所说,您真正的选择是在 Maven 或 ant 之间。为了呼应其他观点,我发现 ant 有更多的配置,所以我更喜欢 Maven。也就是说,很多人倾向于批评maven,因为尽管你需要的配置较少,但它下载了很多依赖项(以及依赖项/依赖项),所以这完全取决于你所说的“轻”是什么意思 - 你的意思是轻在配置或依赖jar下载/安装大小?
如果您想要简单的配置和下载,那么最好使用 shell 脚本,但只有您有时间才能实现功能丰富!
As said elsewhere, your real choice is between maven or ant. To echo other sentiments, I find there is more configuration to do with ant, so I prefer maven. That said, a lot of people tend to criticise maven in that although you need less configuration, it downloads a lot of dependencies (and dependencies/ dependencies), so it all depends on what you mean by "light" - do you mean light in configuration or light in dependency jar downloads/installation size?
If you want something light in terms of config and downloads, you are better off with a shell script, but that will only be as feature-rich as you have time to make it!
我再次推荐 Maven2 - 通过使用插件,它的功能非常丰富,但它也可以非常“轻”(取决于这意味着什么):
当然,另一种选择是 ant,但我发现它不太“轻”。 我发现它不那么轻松,因为 ant 脚本变得丑陋且不可预测,并且变得难以管理,而 Maven 脚本则保持简单,因为该工具提供了丰富的功能。
I'd again recommend Maven2 - it is very feature rich through the use of plugins, but it can also be very "light" (depending on what that means):
Of course, an alternative is ant, but I find it less "light". And I find it less light, because ant scripts grow ugly and unpredictable, and become hard to manage, while maven scripts stay simple, because of the rich functionality provided with the tool.
这实际上取决于您对“光”的定义。您是否想要一个只需很少工作即可使用的工具(只需少量代码)?如果是这样,Maven 或 Gradle 可能是一个不错的选择。 Maven 已经存在有一段时间了。如果您正在做一些遵循其约定的事情,那么您将需要在 pom.xml 文件中编写很少的内容。如果你开始偏离规范,就很难让它满足你的需要(让事情变得不那么轻松)。 Gradle 也是一个选择。它的存在时间不如 Maven,但可以让您更轻松地偏离约定。
如果您正在寻找工具本身轻量级的东西,Apache ant 可能是更好的选择选项。它没有像 Maven 那样内置约定。如果您有一个非常简单的非标准构建,则可以创建一个非常轻量级的 Ant 脚本来完成您的构建。
It really depends on your definition of 'light'. Do you want a tool that requires very little work to use (light on code)? If so, Maven or Gradle might be a good option. Maven has been around for a while. If you are doing something that follows their conventions, then you will need to write very little in your pom.xml files. If you start deviating from the norm it can get difficult to make it do what you need (making things less light). Gradle is also an option. It hasn't be around as long as Maven, but allows you to deviate from the convention easier.
If you are looking for something that is light in terms of the tools itself being lightweight, Apache ant may be a better option. It doesn't have the conventions built in like Maven. If you have a non-standard build that is pretty simple it might be possible to create a very light ant script to do your build.
如果您遵循 Maven 的目录结构,它是最简单的。如果你在linux或unix系统上,我会使用shell脚本。或者您可以考虑 IDE eclipse 或 netbeans,它们会为您完成这项工作,并且依赖项非常容易配置。
Maven is simplest if you follow its directory structure. If you are on linux or unix system, I would use shell script. Or you could consider IDEs eclipse or netbeans, they will do the job for you, and dependencies are very easy to configure.
您尝试过 BlueJ (http://www.bluej.org/) 吗?几年前我用它来教学生。从某种意义上说,它很简单,您只需复制/粘贴代码并运行它即可。它是为了教授学生而创建的,因此非常简单并且适合 Java 初学者。请注意,它是一个完整的 IDE,而不是像 maven 或 ant 这样的命令行工具。
Have you tried BlueJ (http://www.bluej.org/) ?. I used it a few years ago to teach students. It is simple in the sense you can just copy/paste code and run it. It was created to teach students, hence is very simple and good for java starters. Note that it is is a full IDE, not a command line tool like maven or ant.
如果您要坚持标准,Maven 是最好的选择。
如果您想要灵活性,请考虑 Groovy AntBuilder。简洁的语法,以及 ant 和 groovy 脚本的全部功能。
If you are going to stick with standards, Maven is the best bet.
If you want flexibility consider Groovy AntBuilder. terse syntax, and full power of ant and groovy scripting.