English 中文(简体)
ANT Tasks - Import
  • 时间:2024-11-03

Apache Ant Tasks - Import


Previous Page Next Page  

Description

Import task imports another build file into the project.

Properties

Sr.No Attributes & Description
1

File

The file to import. If this is a relative file name, the file name will be resolved relative to the importing file. Note: this is unpke most other Ant file attributes, where relative files are resolved relative to basedir.

2

Optional

If true, do not stop the build if the file does not exist.

3

As

Specifies the prefix prepended to the target names.

4

prefixSeparator

Specifies the separator to be used between the prefix and the target name.

Example

Usage

Create build.xml with the following content −


<?xml version="1.0"?>
<project name="TutorialPoint" default="info">
   <import file="nested.xml" as="nested"/>
   <target name="info" depends="nested.echo">      
   </target>
</project>

And a nested.xml with the following content −


<project>
   <target name="setUp">
      <property name="build.dir" value="build"/>
   </target>
   <target name="echo" depends="setUp">
      <echo>build.dir is set as build</echo>
   </target>
</project>

Above script will create an ear file in the current directory as myapp.ear.

Output

Running Ant on the above build file produces the following output −


F:	utorialspointant>ant
Buildfile: F:	utorialspointantuild.xml

setUp:

nested.echo:
   [echo] build.dir is set as build

info:

BUILD SUCCESSFUL
Total time: 0 seconds
Advertisements