只是每个Java项目,我已经见过或者采用专家或蚂蚁。他们都很好的工具,我认为只是关于任何项目的可以使用它们。但什么都发生了 ?它的用于各种各样的非Java项目和可以很容易地处理Java。确保你已经下载make.exe 如果您使用的窗口,但是蚂蚁和家还不来与JAVA.

是否有一些根本性的缺陷,使当使用与Java?只是因为蚂蚁和家都写在Java?

有帮助吗?

解决方案

与制作和Java的基本问题是,让您拥有指定依赖性前提下,再一个规则的作品,以解决该相关性。

使用基本的C,典型地“发送的main.c文件转换为main.o文件,运行 “CC main.c中”。

您可以做到这一点在Java中,但你很快学到一些东西。

大部分是javac编译器是慢启动。

之间的差:

javac Main.java
javac This.java
javac That.java
javac Other.java

javac Main.java This.java That.java Other.java

是白天和黑夜。

加剧与几百个类,它只是变为站不住脚的。

然后你结合起来,与该Java的往往是组织为目录中的文件组,对C等,其向扁平化结构趋向的事实。让没有太多直接的支持与文件层次的工作。

请在确定文件是过时的东西,在集合级别也不是很好。

通过蚂蚁,它会经过并总结了所有过时的文件,然后编译它们一气呵成。做只会调用每个单独的文件的Java编译器。有使无法做到这一点,需要足够的外部工具真正的表演,使是没有达到的任务。

这就是为什么像Ant和Maven的替代品起来。

其他提示

在古老的make程序处理分别编译如C和C ++语言相当好。您编译模块,它采用#include在其他文本拉包含文件,并写入一个目标文件作为输出。编译器是非常一在-一个时间系统,与单独的连接步骤,以将目标文件装订成可执行的二进制

然而,在Java中,编译器实际上是导入与import编译的其他类。虽然有可能编写生成从Java源代码中的所有必要的依赖的东西,以便make将在建立时间以正确的顺序一个类,这仍然不会处理的情况下,例如圆形的依赖关系。

Java编译器也可以是通过缓存其他类的已编译的结果,而在编译取决于已编译者的结果进一步的类更有效。这种自动依赖性的评价是不是真的有可能单独用make

其实,使得可以处理重新编译所有过时的java文件的一个命令。更改第一个行,如果你不想编译所有目录中的文件或想要一个特定的顺序...

JAVA_FILES:=$(wildcard *.java)
#
# the rest is independent of the directory
#
JAVA_CLASSES:=$(patsubst %.java,%.class,$(JAVA_FILES))

.PHONY: classes
LIST:=

classes: $(JAVA_CLASSES)
        if [ ! -z "$(LIST)" ] ; then \
                javac $(LIST) ; \
        fi

$(JAVA_CLASSES) : %.class : %.java
        $(eval LIST+=$$<)

关于每个技术优势的其他的答案是正确的。 AntMaven可能更适合于Java的比作,或者作为汉克盖伊所指出的,它们不得:)

但是,你问,这是否事项Ant和Maven是用Java编写。虽然在计算器上我们并不认为这样的想法(关闭!不是编程相关的!等),当然,这是事物的一部分。在轨道上,我们用耙,C帅哥使用make,在Java中,我们使用Ant和Maven。虽然这是真的,蚂蚁或Maven开发者将寻找Java开发者也许以后比别人好,这里还有另外一个问题:你写的东西Ant任务吗? Java的。如果你是一个Java开发人员,这是一个容易的选择。

所以,是的,它的一部分是用写在你所用的工具语言工具。

Ant和后来的Maven被设计以解决由Make有些头痛(在创建的过程中新的)它仅仅是进化。

  

...此后不久,几个开源Java项目意识到,蚂蚁可以解决他们与Makefile文件的问题....

http://ant.apache.org/faq.html#history

不管他们解决任何问题或只是创建一个额外的格式,学习是一种主观的话题。事实是,这几乎是每一个新发明的历史:创造者说,它解决了很多问题和原来的用户说,这些都是美德。

它具有的主要优点,是用java整合的可能性。

我想有类似的历史将与rake的实例。

一个Maven的解决的主要问题(和常春藤启用蚂蚁设置)在提出的是自动化的依赖罐子的依赖解析和下载。

我认为最可能的解释是,有若干因素不鼓励使用使内Java社会在一个关键的时期(1990年代):

  1. 因为Java涵盖多个平台,Java程序一般都不擅长的Unix工具是程序员通常仅限于Unix环境的(例如,C和Perl编程人员).注意,这是一般。毫无疑问,有与是有天赋的Java程序有一个深入的了解Unix。
  2. 因此他们不太擅长做并不知道如何使用作有效。
  3. 虽然它可以编写一个短期和简单的生成文件汇编Java有效的、额外的护理需要这样做在一个独立于平台的方式。
  4. 因此,有一个对一个本质上独立于平台的建立工具。
  5. 正是在这种环境中的蚂蚁和以后的专家。

在短期,同时让大多数肯定可以用于Java项目,有一个时刻的机会,使它事实上的Java建立工具。那一刻已经过去了。

请脚本本身就易于依赖于平台。 Java的应该是平台无关的。因此具有构建系统,仅适用于一个平台用于多平台sourcebase被kindof的问题。

除非我用做对Java没有一个假设没有一个是(MIS)是错误的。

“与GNU管理项目制作”(GFDL购得)包含专用于使用make用java项目的完整章节。

,因为它包含使用make,而不是你可能想看看有没有其他工具的利弊长(希望公平)名单。 (见: http://oreilly.com/catalog/make3/book/

Short answer: Because make isn't good. Even on the C front you see many alternatives popping up.

Long answer: make has several flaws that make it barely suitable for compiling C, and unsuitable at all for compiling Java. You can force it to compile Java, if you want, but expect running into issues, some of which do not have a suitable solution or workaround. Here are a few:

Dependency resolution

make inherently expects files to have a tree-like dependency on each other, in which one file is the output of building several others. This already backfires in C when dealing with header files. make requires a make-specific include file to be generated to represent the dependency of a C file on its header files, so a change to the latter would cause the prior to be rebuilt. However, since the C file itself isn't recreated (merely rebuilt), make often requires specifying the target as .PHONY. Fortunately, GCC supports generating those files automatically.

In Java, dependency can be circular, and there's no tool for auto-generating class dependencies in make format. ant's Depend task can, instead, read the class file directly, determine which classes it imports, and delete the class file if any of them are out of date. Without this, any non-trivial dependency may result in you being forced to use repeated clean builds, removing any advantage of using a build tool.

Spaces in filenames

While neither Java nor C encourage using spaces in your source code filenames, in make this can be problem even if the spaces are in the file path. Consider, for example, if your source code exists in C:\My Documents\My Code\program\src. This would be enough to break make. This is because make treats filenames as strings. ant treats paths as special objects.

Scanning files for build

make requires explicitly setting which files are to be built for each target. ant allows specifying a folder which is to be auto-scanned for source files. It may seem like a minor convenience, but consider that in Java each new class requires a new file. Adding files to the project can become a big hassle fast.

And the biggest problem with make:

make is POSIX-dependent

Java's motto is "compile once run everywhere". But restricting that compilation to POSIX-based systems, in which Java support is actually the worst, is not the intention.

Build rules in make are essentially small bash scripts. Even though there is a port of make to Windows, for it to work properly, it has to be bundled with a port of bash, which includes a POSIX emulation layer for the file system.

This comes in two varieties:

  1. MSYS which tries to limit the POSIX translation to file paths, and can therefore have unpleasant gotchas when running external tools not made especially for it.

  2. cygwin which provides a complete POSIX emulation. The resulting programs, however, tend to still rely on that emulation layer.

For that reason, on Windows, the standard build tool isn't even make at all, but rather MSBuild, which is also an XML-based tool, closer in principle to ant.

By contrast, ant is built in Java, can run everywhere, and contains internal tools, called "tasks", for manipulating files and executing commands in a platform-independent way. It's sufficiently versatile that you can actually have an easier time building a C program in Windows using ant than using make.

And one last minor one:

Even C programs don't use make natively

You may not initially notice this, but C programs generally aren't shipped with a Makefile. They are shipped with a CMakeLists.txt, or a bash configuration script, which generates the actual Makefile. By contrast, the source of a Java program built using ant is shipped with an ant script pre-built. A Makefile is a product of other tools - That's how much make is unsuitable to be a build tool on its own. ant is standalone, and deals with everything you need for your Java build process, without any additional requirements or dependencies.

When you run ant on any platform, it Just Works(tm). You can't get that with make. It's incredibly platform and configuration dependent.

Ant is an XML configuration oriented improvement over Makefiles and Maven is a dependency build tool improvement over Ant. Some projects use all three. I think the JDK projects used to use a mix of makefiles and ant.

One big reason is that both Ant and Maven (and most java targeted SCM, CI and IDE tools) are written in java by/for java developers. This makes it simpler to integrate into your development environment and allows other tools such as the IDE and CI servers to integrate portions of the ant/maven libraries within the build/deployment infrastructure.

Once upon a time I worked on a Java project that used gmake. My recollection is hazy but IIRC we had a hard time dealing with the package directory structure that javac expects. I also remember that building JAR files was a hassle unless you had something trivial.

ApacheAnt isn't anything like Make. Make is about describing dependencies between files, and how to build files. Ant is about dependencies between "tasks", and is really more of a way of gluing build scripts together.

it may helps you AntVsMake

Ant and Maven approach the build dependency graph and the management of it from a more 'modern' view... But as Oscar says, they created their own problems while attempting to address the old problems with make.

I've never used GNU Make for Java projects, but I used to use jmk. Sadly it hasn't been updated since 2002.

It had some Java-specific functionality but was small enough to include in your source tarball without significantly increasing its size.

Nowadays I just assume any Java developer I share code with has Ant installed.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top