Ant覆盖compile目标时,如何调整依赖执行顺序?
Got it, let's break this down. The issue here comes down to how Ant processes target dependencies—it executes dependencies in the exact order they’re listed in the depends attribute, and for each dependency, it first runs all of that target’s own dependencies before executing the target itself.
Your original setup had depends="compile-generated, shared.compile", which meant Ant would run compile-generated first, then go through all of shared.compile's dependencies and finally shared.compile itself. That’s the opposite of what you wanted.
To get the order you need (run all of shared.compile's dependencies → run shared.compile → run compile-generated), you just need to reverse the order in the depends list:
<target name="compile" depends="shared.compile, compile-generated"> <!-- Any additional tasks for your custom compile target go here (if needed) --> </target>
Here’s why this works:
- Ant will first resolve and execute all dependencies of
shared.compilein their correct order, then executeshared.compileitself. - Once
shared.compileand all its dependencies are fully done, Ant will move on to executecompile-generated.
This way, you’re ensuring the shared compile pipeline completes entirely before your custom compile-generated step runs.
内容的提问来源于stack exchange,提问作者Mark Aquino

