开发者

What default targets do you have in your typical ant buildfile?

开发者 https://www.devze.com 2022-12-26 00:29 出处:网络
Do you have some predefined set of targets which all build.xml files you create contain? For example, a lot of ant manuals suggest the following list of targets:

Do you have some predefined set of targets which all build.xml files you create contain? For example, a lot of ant manuals suggest the following list of targets:

  • init
  • clean
  • compile
  • build
  • jar
  • test
  • javadoc
  • dist
  • deploy
  • webapp

What is the most large build file you met in your life? How many targets did it have and what are they? How often do you need more than predefined set of targets?

The goal is to develop some conventions to have standard buildfile template for any project having the notion of the maven-like approach in m开发者_开发百科ind (when a lot of work happens under the cover, convention over configuration). Also it would be great if you know the place where one can find collection of different buildfiles to choose or to get inspired from.


I also use these targets in all ant files

  • init
  • clean
  • compile
  • build
  • test
  • javadoc

The build targets always creates the artefact, no matter whether it is a jar or war or whateveer.

You should also include structural things in your conventions like a shared repository for all libraries (versioned by some VCS). Another thing would be to define properties for your jar versions i.g.:

lib.commons-collections=commons-collections-2.1.jar
lib.commons-io=commons-io-1.4.jar

which are referenced in all ant files, common.jar is a place where artifacts are placed in case other projects depend on them.

<path id="local-cp">
    <pathelement path="${dir.common.jar}/${lib.shared}" />
    <pathelement path="${dir.lib}/${lib.commons-logging}" />
    <pathelement path="${dir.lib}/${lib.commons-io}" />
...

For deployment I use another set of ant files deploy_component-name.xml After years with ant I would recommend to keep the number of targets limited, sometimes you may have a few more steps for code generation etc.

To see how others handle bigger projects you could download the source distribution of an application server to examine how they do this job.


  • int
  • build
  • jar
  • deploy
  • package
  • clean
  • test
0

精彩评论

暂无评论...
验证码 换一张
取 消