Simple usage of ant build file build.xml


Build.xml

All build files require the project element and at least one target element.

Project

This is root element.


<project name="JavaCCProject" default="compile" basedir=".">


</project>


  • name: the name of the project. (Optional)
  • default: the default target for the build script. A project may contain any number of targets. This attribute specifies which target should be considered as the default. (Mandatory)
  • basedir: the base directory (or) the root folder for the project. (Optional)


property

Sets a property (by name and value)

target

A target is a collection of tasks that you want to run as one unit.

Targets can have dependencies on other targets.


  • name The name of the target (Required)
  • depends Comma separated list of all targets that this target depends on. (Optional)
  • description A short description of the target. (optional)
  • if Allows the execution of a target based on the trueness of a conditional attribute. (optional)
  • unless Adds the target to the dependency list of the specified Extension Point. An Extension Point is similar to a target, but it does not have any tasks. (Optional)



Task reference

http://ant.apache.org/manual/

https://ant.apache.org/manual/tasksoverview.html


Command Line

ant [options] [target...]


The commonly used options are:


  • -projecthelp displays the names and descriptions of targets in the build file.
  • -buildfile <build filename> uses the specified build file instead of build.xml.
  • -Dkey=value sets a Java property for Ant to use.
  • -propertyfile <filename> sets properties for every line in the specified file.


To define a property

Use property task in build.xml

<property name="attribute" value="value"/>


Use environment variable

$ export attribute=value


Use following line in build.xml to retrieve.

<property environment="env"/>

<property name="attribute"  value="${env.attribute}"/>


Use command line definition

ant -Dattribute=value task


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值