Fix memory leak in component metadata rule executor
The cross-build cache for cached component metadata rules stores
instances of realized Maven/Ivy module metadata in memory. The
problem is that those instances shouldn't have any state from
the project/Gradle build attached to them (they should be good
old POJOs) but for implementation reasons, they are not. In
particular, they keep a reference to the attributes factory,
which in turn keeps a reference to the object factory, which,
itself, will leak classloaders.
As a consequence, as more builds get executed, it was _possible_
that the cache would release some entries, but for the classloaders
to be released, it would require _all_ the entries from the same
build to be released from the cache. It turns out this event is
unlikely and as a consequence, builds end up running out of
This commit fixes the problem by making sure that at the end of
a build, we clear the in-memory cache of component metadata rules.
Therefore, cross-build, we would still read the result of the
execution of rules from the binary, on disk cache, but we would
not reuse in-memory results from previous builds.
This fix has been tested and validated by a user facing this
issue. Memory usage dropped from 11GB of memory to 1GB.
Force AbstractTestDirectoryProvider to use Class (#12431)
This PR adds `className` to `AbstractTestDirectoryProvider` so there'll be no more `unknown-test-class`.