ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gagern <>
Subject [GitHub] ant pull request: Improve functionality of the classloader task wh...
Date Thu, 27 Nov 2014 12:02:49 GMT
GitHub user gagern opened a pull request:

    Improve functionality of the classloader task when applied to the core loader

    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
    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.

You can merge this pull request into a Git repository by running:

    $ git pull 47003-improve-classloader

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4
commit 6d4eff75fcdcfbe0cf6b92ff05de1f321dd42bbf
Author: Martin von Gagern <>
Date:   2014-11-27T08:52:52Z

    Improve <classloader> task, always provide core loader.
    Changes Main.runBuild to always provide an AntClassLoader as the core
    loader, so there will always be a loader to which additional path elements
    can be added.
    Also changes the behaviour of the classloader task when name is omitted or
    specified as "ant.coreLoader".  In that case, the loader is not looked up by
    reference, but instead the core loader of the project is used.  This avoids
    having to register a reference to this loader anywhere else.
    This patch was taken from PR #47003 and dates back to April 2009.

commit 8b5639ca04f840488ba5e3bb8dd098fac6b6d054
Author: Martin von Gagern <>
Date:   2014-11-27T09:11:06Z

    Avoid relying on Main.
    Instead of introducing an AntClassLoader in Main, we now have the Project
    class itself ensure that the core class loader is always an AntClassLoader.
    This should cater for the embedded mode, where Main isn't even used.
    We also use the factory method to make sure we get the right subclass of the
    class loader class.  And there is some API documentation about all of this.

commit f6517218534ab6467f1c74b3d7cdca9625597a0d
Author: Martin von Gagern <>
Date:   2014-11-27T09:23:22Z

    Document the (assumed) version for classloader changes.
    The documentation now specifies the version when the behavior changed. The
    private variable is adjusted to reflect the fact that we always want an
    AntClassLoader there.  The public interface is left as is, though, to avoid
    trouble in case someone subclasses Project and overrides that method.
    Although I can't imagine why someone would do that.

commit f870b562a95ad2cfd72b28302584be8b920dd5a3
Author: Martin von Gagern <>
Date:   2014-11-27T11:21:50Z

    Added antunit test for classloader modifying the core loader.

commit 7df45757dfa727aed3624d62851c167110b15ea4
Author: Martin von Gagern <>
Date:   2014-11-27T11:28:05Z

    Merge sysclasspath=only subcase into existing core loader case.


If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message