[ 
http://jira.codehaus.org/browse/MNG-2722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_86050
 ] 

Aaron Digulla commented on MNG-2722:
------------------------------------

I've added a hack with the defaulsPopulator() to make localRepository work in 
MavenEmbedder:

         request = defaultsPopulator.populateDefaults( request );
+       request.setLocalRepository(getLocalRepository());
+       request.setLocalRepositoryPath(getLocalRepository().getBasedir());

This doesn't fix the NPE, though. After some more debugging, I've found this in 
the output after starting the embedder a second time:

[org.apache.maven:maven-plugin-tools-api:jar:2.0:runtime]
[ maven embedder DEBUG] Realm already exists for: 
org.apache.maven.plugins:maven-help-plugin. Skipping addition...

I guess this means that the embedder still has same garbage left from the last 
run so it won't load the plugin again even though it's now a different plugin 
(or, as in the test, the same plugin but from a different localRepository).

I see two solutions: Clean up the class realms when the embedder is started a 
second time (does that clear up static final variables?) or forbid to start it 
twice (as my patch does).

Just to prove my point, I've added a hack to start(MavenEmbedRequest):

classWorld = new ClassWorld( "plexus.core", classLoader );

With this code, it's possible to start the embedder twice but then, you either 
have to remove the constructors which pass in a ClassWorld or you must patch 
ClassWorld to support some kind of "reset()" method to clean up an existing 
realm.

> Create a strategy for providing sane default values in the 
> MavenExecutionRequest
> --------------------------------------------------------------------------------
>
>                 Key: MNG-2722
>                 URL: http://jira.codehaus.org/browse/MNG-2722
>             Project: Maven 2
>          Issue Type: Task
>          Components: Embedding
>            Reporter: Jason van Zyl
>         Attachments: embedder-start-twice.patch
>
>
> Ideally an Embedder user should be able to do something like:
> MavenEmbedder embedder = new MavenEmbedder();
> MavenExecutionRequestion request = new DefaultMavenExecutionRequestion()
>   .setBasedir( directory )
>   .setGoals( Arrays.asList( new String[]{ "package" } ) );
> embedder.execute( request );
> And this should work.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to