About Java build: Ant & Maven

2016-12-22  本文已影响0人  Luna_Lu

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

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

Dependency Management

No need to explain.

Shortcoming

上一篇 下一篇

猜你喜欢

热点阅读