Maven浅析-3 Ant Vs Maven

1.什么是Ant?

Ant起源是为了取代构建工具Make。它可以跨系统,建立在Java和XML的基础上,而且非常程式化。

Ant更像一个脚本工具,我们必须在Ant内显示地声明做任何事情。在<target>内声明,而且没有统一的标准,一个application可能会包含庞大的repository。

2. Maven

Maven不仅仅是一个脚本工具,它更是一个成熟的构建工具。它有很多隐式的功能,譬如一致性,继承,transitive dependencies,版本管理。

3.优点和缺点<待完善>

Maven:

Maven can be a black box.

steeper learning curve

convertion over configuration

Better IDE integration

Less overheard through use of repos

different mindset, steepest learning curve is not making maven act like Ant

Ant:

we can trace Ant files fairly easily

quicker to learn, but very copy-paste intensive

larger project size in SCM, artifacts stored with project

e.g. Ant build.xml

<project>

  <target name="clean">

    <delete dir="build"/>

  </target>

  <target name="compile">

    <mkdir dir="build/classes"/>

    <javac srcdir="src" destdir="build/classes"/>

  </target>

  <target name="jar">

    <mkdir dir="build/jar"/>

    <jar destfile="build/jar/HelloWorld.jar" basedir="build/classes">

      <manifest>

        <attribute name="Main-Class" value="oata.HelloWorld"/>

      </manifest>

    </jar>

  </target>

 <target name="run">

   <java jar="build/jar/HelloWorld.jar" fork="true"/>

 </target>

</project>

e.g. Maven pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"

    xmlns:xsi="http://www.x.org/xx/xxy"

    xsi:schemalocation="xx">

  <modelVersion>4.0.0</modelVersion>

  <groupId>com.dahang</groupId>

  <artifactId>HelloWorld</artifactId>

  <version>0.0.1-SNAPSHOT</version>

</project>

5.Summary:

Ant is very declarative.

Maven follows a convention over configuration model

Ant may be easier to learn, but it really is only beneficial as a scripting tool.

Maven is really centered around managing your entire project's lifecycle.

上一篇:CSS3.0盒模型display:box;的使用


下一篇:git命令提交项目