You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by amaresh mourya <am...@gmail.com> on 2010/08/03 08:55:07 UTC

How to clear cache used in DefaultMavenProjectBuilder

Hi All,

In DefaultMavenProjectBuilder.java, there is one private hash map called
rawProjectCache, which stores the last discovered projects.
But i want each time it to read the pom file and return me the current model
of pom.xml

My Use case is:
I have a pom.xml (say Child), this has parent pom.xml (say Parent)
Now I want to build the Child and want the list of repositories (I want to
have all repositories referred by this Child, its own and of its ancestors)
First time it gives me the correct list of repositories(its and Parent's),
after this if I made some change in Parent(add <reposiotry> in pom.xml), and
try to again get the list of repositories, I am not getting the latest list,
but the last one from the Parent, reason being before reading the Parent's
pom.xml it searches it in rawProjectCache(as mentioned above) and return
from there.

So How can I clear this cache. I am using plexuscontainer to get the
instances of DefaultMavenProjectBuilder.

Any Idea would be helpful.
Thanks,
Amaresh

Re: How to clear cache used in DefaultMavenProjectBuilder

Posted by Brett Porter <br...@apache.org>.
If you're doing this in a mojo, you're stuck with the version Maven gives you. In that case, you can clear it like the following:
http://archiva.apache.org/ref/1.1.2/xref/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.html#249

You'll want to ignore the exception in case it is running in Maven 3 where the field won't be present.

If you're doing this outside of Maven, I recommend using the Maven 3 beta libraries. You can see an example here:
http://archiva.apache.org/ref/1.4-SNAPSHOT/xref/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.html#166

Cheers,
Brett

On 03/08/2010, at 4:55 PM, amaresh mourya wrote:

> Hi All,
> 
> In DefaultMavenProjectBuilder.java, there is one private hash map called
> rawProjectCache, which stores the last discovered projects.
> But i want each time it to read the pom file and return me the current model
> of pom.xml
> 
> My Use case is:
> I have a pom.xml (say Child), this has parent pom.xml (say Parent)
> Now I want to build the Child and want the list of repositories (I want to
> have all repositories referred by this Child, its own and of its ancestors)
> First time it gives me the correct list of repositories(its and Parent's),
> after this if I made some change in Parent(add <reposiotry> in pom.xml), and
> try to again get the list of repositories, I am not getting the latest list,
> but the last one from the Parent, reason being before reading the Parent's
> pom.xml it searches it in rawProjectCache(as mentioned above) and return
> from there.
> 
> So How can I clear this cache. I am using plexuscontainer to get the
> instances of DefaultMavenProjectBuilder.
> 
> Any Idea would be helpful.
> Thanks,
> Amaresh

--
Brett Porter
brett@apache.org
http://brettporter.wordpress.com/





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org