About Java build: Ant & Maven

Ant

Ant's hierarchical build script structure is like the following picture.

Ant has a lot of predefined tasks for file system and archiving operations. You can also write your own tasks in java.


Document 1.png
<project name="my-app" default="dist" basedir="."
>
<!--Define properties-->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/> 
<property name="version" value="1.0"/>

<!--Define targets-->

<!-- create build directory used by compile target-->
<target name="init">
  <mkdir dir="${build}"/>
</target>

<!-- compile java code from directory src to directory build-->
<target name="compile" depends="init" description="...">
  <javac srcdir="${src}" destdir="${build}" classpath="lib/commons-lang3-3.1.jar" includeantruntime="false" />
</target>

......
</project>
structures of the above script

some shortcomings

  • XML definition is very limited
  • need Ivy for dependency management
    ...

Maven

Based on the standard project layout and unified build lifecycle.

Standard Layout

eg. all source code sits in the directory src/main/java


maven default layout

Lifecycle

  • compile
  • unit test and integration test
  • assemble (eg. JAR file)
  • deploy to the local repository
  • release to remote

Dependency Management

No need to explain.

Shortcoming

  • too restrictive
  • not stable
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 最近在做的小项目出现了一个问题。当presentViewController时内存上升(在debug naviga...
    Jerry在种草阅读 512评论 0 0
  • 本书作者的知识非常渊博,他用宗教、哲学以及心理学理论来探讨人类的内心世界,并试图找到让我们幸福的方式。 关于自我 ...
    哇620阅读 207评论 0 0
  • 昨天,是7月15日,我们一家人在北戴河旅游了三天,每天都有大海每天的早饭很难吃,旅游完了之后我们到了,哥哥那儿住了...
    21小石头小雨阅读 388评论 0 0