You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Kronus David <kr...@atlas.cz> on 2009/02/25 16:33:08 UTC

Ignoring missing targets which are not needed for current build

I have implemented for myself the below described command-line argument and related task, do you think it could be useful and hence submitted to ant?
---
I was looking for a way in which ant could perform a build on an antfile where some tasks (which are not needed for the desired build) have dependencies on tasks which are not present in the antfile. The motivation was that I have an <import file="..." optional="true"/> in the antfile and the antfile to import is being downloaded by invoking a task in the main antfile (containing the import). So during the first invocation to download the antfile to import there may be some tasks in the main antfile which depend on tasks in the imported antfile which is not available at the beginning of the invocation, only as a result of it. 

I didn't find anything related in documentation and I received no response from the user mailing list, so I concluded that this is currently not possible and looked into the source code of ant (1.7.1) to find out that this is very easy since the (redundant) control of dependencies of tasks not involved in the current build is clearly divided from the rest of the dependency checking (there is a detailed comment on that in Project.java in one of the toposort methods). So I added a commandline switch (-ignore-missing) to overcome this. So this is first step, do you think this could be useful to submit?

Second step is that I don't want to say "ant -ignore-missing" each time this is needed, so I thought about "declaring" somehow in an antfile that when performing build using the antfile, this option should be turned on. This is actually easy, I just wrote a simple anttask <config ignoreMissing="true"/> which can be used outside of targets and gets executed before the actual checking of missing targets. This task just sets a flag on Project instance according to its attribute. It could even be extended so that you can declare options for Project, which are now only controlled by commandline options, in antfiles that need them.  What do you think about that? Is it useful (for me it is essential) and is it worth submitting to ant?

David