maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Casey (JIRA)" <j...@codehaus.org>
Subject [jira] Updated: (MNG-2200) [m2.0.3] Embedder - no way to override the "localRepository", .start() and alignWithUserInstallation broken
Date Thu, 22 Jun 2006 18:56:41 GMT
     [ http://jira.codehaus.org/browse/MNG-2200?page=all ]

John Casey updated MNG-2200:
----------------------------

    Fix Version: 2.1

> [m2.0.3] Embedder - no way to override the "localRepository", .start() and alignWithUserInstallation
broken
> -----------------------------------------------------------------------------------------------------------
>
>          Key: MNG-2200
>          URL: http://jira.codehaus.org/browse/MNG-2200
>      Project: Maven 2
>         Type: Bug

>   Components: Embedding
>     Versions: 2.0.3
>  Environment: All
>     Reporter: Dan Rollo
>      Fix For: 2.1

>
>
> There is no way to override the "localRepository" used by MavenEmbedder.
> Some code from MavenEmbedder.java:
>     public void setLocalRepositoryDirectory( File localRepositoryDirectory )
>     {
>         this.localRepositoryDirectory = localRepositoryDirectory;
>     }
> ...
>     public void start()
>         throws MavenEmbedderException
>     {
>         detectUserInstallation();
> ...
>     private void detectUserInstallation()
>     {
>         if ( new File( userHome, ".m2" ).exists() )
>         {
>             alignWithUserInstallation = true;
>         }
>     }
>     /**
>      * Create the Settings that will be used with the embedder. If we are aligning with
the user
>      * installation then we lookup the standard settings builder and use that to create
our
>      * settings. Otherwise we constructs a settings object and populate the information
>      * ourselves.
>      *
>      * @throws MavenEmbedderException
>      * @throws ComponentLookupException
>      */
>     private void createMavenSettings()
>         throws MavenEmbedderException, ComponentLookupException
>     {
>         if ( alignWithUserInstallation )
>         {
>             // ----------------------------------------------------------------------
>             // We will use the standard method for creating the settings. This
>             // method reproduces the method of building the settings from the CLI
>             // mode of operation. 
>             // ----------------------------------------------------------------------
>             settingsBuilder = (MavenSettingsBuilder) embedder.lookup( MavenSettingsBuilder.ROLE
);
> ...
>         }
>         else
>         {
>             if ( localRepository == null )
>             {
>                 throw new IllegalArgumentException( "When not aligning with a user install
you must specify a local repository  location using the setLocalRepositoryDirectory( File
) method." );
>             }
>             settings = new Settings();
>             settings.setLocalRepository( localRepositoryDirectory.getAbsolutePath() );
> ...
> The detectUserInstallation() method will never allow me to override the localRepository
if an ".m2" user
> directory exists (even if I call setAlignWithUserInstallation(false) and/or call setLocalRepositoryDirectory()
before calling start() ). The current logic in the start() method always sets the field "alignWithUserInstallation"
to true
> if ".m2" exists.
> Jason has confirmed this is a bug (on the maven user list), which he is working on, but
on a major branch due to be merged at some point in the future. That said, I think this issue
can easily be fixed quickly with the code change below applied to the method detectUserInstallation():
>     private void detectUserInstallation()
>     {
>         if ( new File( userHome, ".m2" ).exists() )
>         {
>             alignWithUserInstallation = true;
>         }
>     }
> changed to (added another condition in the if):
>     private void detectUserInstallation()
>     {
>         if ( new File( userHome, ".m2" ).exists() && localRepositoryDirectory
== null )
>         {
>             alignWithUserInstallation = true;
>         }
>     }
> If the next Embedder release will occur very soon and will include Jason's fixes, this
bug is likely already fixed. However, if the merging of Jason's branch is a long way off,
please consider fixing this bug for the next release.
> thanks
> Dan

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


Mime
View raw message