Improve functionality of the classloader task when applied to the core loader #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Revisiting issue 47003. The original title was “Add to ant lib classpath from within project file” which still describes what I'm trying to accomplish here.
With these changes, the core class loader is guaranteed to always be an
AntClassLoader
, so the (still undocumented)<classloader>
task can be used to add to that without replacing it. One use case is the following: users only have ant core available, but some dependency management tool (e.g. Ivy) provides jar files for optional tasks and their dependencies. Then adding those jars to the core class loader will make those optional tasks available without having to<taskdef>
each one with the corresponding<classpath>
. There is an antunit test case demonstrating this, using<junit>
as an example. This approach can be used for third-party tasks as well, potentially simplifying things a lot. This should in particular help projects which up to now had a dedicated build script (or two, one shell script for *nix and one batch file for Windows) to build the class path resp. library path before invoking ant. Now they can drop those scripts and portably build the class path in ant itself.Of course it would be useful to also document the
<classloader>
task, and give examples where modifying a non-core loader would be useful, and add antunit tests for that as well. But since I haven't yet figured out those non-core use cases, I'd like to keep that out of this pull request. And I'd welcome input on that.