Michael Cepek wrote:
Hi Michael,[snip] Our team needs to be able to use the following Ant targets from within ANY of the top-level java package directories (xxx = one of these package names: admin, db, controller, and util):
[snip]
We also need these targets: build-all, test-all, javadoc-all, and clean-all. These would build everything for both Java and C++.
[snip]
Finally, we need each package to first compile and/or build any packages on which it depends.
[Doesn't everyone need to do this?]
to answer your last question first - no - it appears a lot of people compile everything at once. Which is symptomatic of lack of attention to dependencies. I can't answer all your questions but here's the structure of what I do...
I have a top level build.xml file that specifies the dependencies between project packages. It has one target for each package/folder. Each target has one element which calls a macro passing it the name of the target. Eg
<target name="com/wibblesoft/grammar/model" depends="...."> <run-test-macro package="com/wibblesoft/grammar/model"/> </target>
The target name is not available via a property hence the duplication :-(
The package name doubles as the package-folder it comes from.
build.xml <import>'s another (reusable) xml file which contains the run-test-macro target
<macrodef name="run-test-macro"> <attribute name="package"/> <sequential> <build-test-macro package="@{package}"/> ... <junit...> ... </junit> ... </sequential> </macrodef>
which relies on this
<macrodef name="build-test-macro"> <attribute name="package"/> <sequential> <depend ...> ... </depend> <build-macro package="@{package}"/> <javac ...> ... </javac> </sequential> </macrodef>
which relies on this
<macrodef name="build-macro"> <attribute name="package"/> <sequential> ... <condition...> ... </condition> <javac...> ... </javac> </sequential> </macrodef>
The <condition> uses some <and>'d <uptodate>'s to check if anything has changed or not...
Now from the top level folder you can issue standard ant commands. Eg >ant com/wibblesoft/grammar/model
Finally, ant-master-targets.xml also has these two...
<target name="build-without-dependencies"> <run-test-macro package="${package}"/> </target>
<target name="build-with-dependencies"> <antcall target="${package}"/> </target>
And each individual folder also contains a file called package-name.ant which contains just the name of the folder. Eg com/wibble/grammar/model/package-name.ant contains this
package=com/wibblesoft/grammar/model
This allows me to also build any package directly from its folder like this
>ant -find build.xml -propertyfile package-name.ant build-with-dependencies
or like this
>ant -find build.xml -propertyfile package-name.ant build-without-dependencies
and both of these can be put into batch/script files (eg jabi/jaba, JAva Build Individual/All)
Hope this is of some use. Cheers Jon
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]