Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Apache Ant/Depends

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

The depends attribute can be included in the target tag to specify that this target requires another target to be executed prior to being executed itself. Multiple targets can be specified and separated with commas. <target name="one" depends="two, three"> Here, target "one" will not be executed until the targets named "two" and "three" are, first. Example of using the depends attribute Here is an example of a build file that executes three targets in order, first, middle and last. Note that the order the targets appear in the build file is unimportant: <?xml version="1.0" encoding="UTF-8"?> Running One Running Two Running Three Sample Output: Buildfile: build.xml one: [echo] Running One two: [echo] Running Two three: [echo] Running Three BUILD SUCCESSFUL Total time: 0 seconds Redundant dependency Ant keeps track of what targets have already run and will skip over targets that have not changed since they were run elsewhere in the file, for example: <?xml version="1.0" encoding="UTF-8"?> Running One Running Two Running Three will produce the same output as above - the target "one" will not be executed twice, even though both "two" and "three" targets are run and each specifies a dependency on one. Circular dependency Similarly, ant guards against circular dependencies - one target depending on another which, directly or indirectly, depends on the first. So the build file: <?xml version="1.0" encoding="UTF-8"?> Running One Running Two Will yield an error: Buildfile: build.xml BUILD FAILED Circular dependency: one <- two <- one Total time: 1 second Next Chapter, Next Cookbook Chapter