- Idioms for supporing parent build using Ant 1.8 extension points
- <?xml version="1.0" encoding="utf-8"?>
- <project name="common-targets">
- <extension-point name="compile" />
- <extension-point name="test" depends="compile" />
- <extension-point name="package" depends="test" />
- <extension-point name="deploy" depends="package" />
- </project>
- <?xml version="1.0" encoding="utf-8"?>
- <project name="compile">
- <import file="common-targets.xml" />
- <target name="compile:compile" extensionOf="compile">
- <echo message="Compiling..." />
- </target>
- </project>
- <?xml version="1.0" encoding="utf-8"?>
- <project name="test">
- <import file="common-targets.xml" />
- <target name="test:test" extensionOf="test">
- <echo message="Testing..." />
- </target>
- </project>
- <?xml version="1.0" encoding="utf-8"?>
- <project name="default-lifecycle">
- <import file="compile.xml" />
- <import file="test.xml" />
- <import file="package.xml" />
- <import file="deploy.xml" />
- </project>
- <?xml version="1.0" encoding="utf-8"?>
- <project name="child1">
- <import file="../scripts/default-lifecycle.xml" />
- </project>
- <?xml version="1.0" encoding="utf-8"?>
- <project name="child2">
- <import file="../scripts/default-lifecycle.xml" />
- </project>
- .-+
- |
- +-build.xml
- +-child1
- |
- +-build.xml
- +-child2
- |
- +-build.xml
- +-scripts
- <?xml version="1.0" encoding="utf-8"?>
- <project name="parent">
- <import file="common-targets.xml" />
- <target name="parent:compile" depends="parent:init-build-path" extensionOf="compile">
- <subant target="compile" buildpathref="parent..build-path" />
- </target>
- <target name="parent:test" depends="parent:init-build-path" extensionOf="test">
- <subant target="test" buildpathref="parent..build-path" />
- </target>
- <target name="parent:package" depends="parent:init-build-path" extensionOf="package">
- <subant target="package" buildpathref="parent..build-path" />
- </target>
- <target name="parent:deploy" depends="parent:init-build-path" extensionOf="deploy">
- <subant target="deploy" buildpathref="parent..build-path" />
- </target>
- <target name="parent:init-build-path">
- <path id="parent..build-path">
- <fileset dir="." includes="**/build.xml" excludes="build.xml" />
- </path>
- <echo message="Build order is ${toString:parent..build-path}" />
- </target>
- </project>
- <?xml version="1.0" encoding="utf-8"?>
- <project name="parent">
- <target name="compile" depends="parent:init-build-path">
- <subant target="compile" buildpathref="parent..build-path" />
- </target>
- <target name="test" depends="parent:init-build-path">
- <subant target="test" buildpathref="parent..build-path" />
- </target>
- <target name="package" depends="parent:init-build-path">
- <subant target="package" buildpathref="parent..build-path" />
- </target>
- <target name="deploy" depends="parent:init-build-path">
- <subant target="deploy" buildpathref="parent..build-path" />
- </target>
- <target name="parent:init-build-path">
- <path id="parent..build-path">
- <fileset dir="." includes="**/build.xml" excludes="build.xml" />
- </path>
- <echo message="Build order is ${toString:parent..build-path}" />
- </target>
- </project>