There are certain compiler dependencies that are not allowed in our (Java) environment. We have two servers, call them Application and Process. We have three root Java packages, call them Application, Process, and Shared. Application and Process are not allowed to reference each other, but they can each reference Shared. Shared can reference any class in any of the other two packages. How can I enforce these dependencies with Ant? The problem, as you might guess, is that in our Eclipse based environment everything compiles successfully, but we’ve come across runtime errors where a class is not there (since we have multiple servers).
I have attempted quite a few things but nothing has worked. See my current attempt below, where I have omitted irrelevant code for clarity. Comments are included.
<!--Compile the 'shared' directories. Since shared depends on Application and Process, we compile everything then delete Application and Process later. -->
<javac srcdir="${src.dir}" destdir="${build.dir}">
<classpath>
...
</classpath>
</javac>
<delete dir="${build.dir}/application" />
<delete dir="${build.dir}/process" />
<!--Compile the 'application' directories -->
<javac sourcepath="" srcdir="${src.dir}/application" destdir="${build.dir}">
<classpath>
<pathelement location="${build.dir}/shared" />
...
</classpath>
</javac>
<!--Compile the 'process' directories -->
<javac sourcepath="" srcdir="${src.dir}/process" destdir="${build.dir}">
<classpath>
<pathelement location="${build.dir}/shared" />
...
</classpath>
</javac>
you need to split shared into three parts, shared-standalone, shared-application and shared-process.
compile shared-standalone first,
compile shared-application together with application,
compile shared-process together with process.