Javatpoint Logo
Javatpoint Logo

Apache Ant Import Task

Import tasks is used to import a build file into the current project. The imported files are parsed by using ProjectHelper. The ProjectHelper is actually responsible for parsing the imported files.

The import task is a top level task so it can't be used inside target element. There are two functional aspects which are related to this task.

Target Overriding

If a target in the current file is also available into the imported file, the current file's target will get precedence.

Special Properties

Imported files are local to the current main project. To distinguish between imported and local files, Ant adds a property which contains path to the imported build file.

Note: If the imported file does not contain name attribute, it property will not set.

Apache Ant Import Task Attributes

Attribute Description Required
file The file to import. Yes
optional If true, do not stop the build if the file does not exist. No
as Specifies the prefix prepended to the target names. No
prefixSeparator A separator to be used between the prefix and the target name. No

Apache Ant Import Task Example

The below code imports targets from the common-targets.xml file located into parent directory.

It imports a project

It imports target from the targets.xml file which is inside the common directory.





Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA