美文网首页
About Java build: Ant & Maven

About Java build: Ant & Maven

作者: Luna_Lu | 来源:发表于2016-12-22 23:23 被阅读0次

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

相关文章

网友评论

      本文标题:About Java build: Ant & Maven

      本文链接:https://www.haomeiwen.com/subject/weihvttx.html