maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rollo, Dan" <DRo...@ETS.ORG>
Subject RE: [m2.0.3] Embedder - setAlignWithUser ignored
Date Thu, 30 Mar 2006 21:54:41 GMT
Cool. Just to verify if I'm thinking correctly: Would the "correct"
usage be:

1. setLocalRepositoryDirectory(<myLocalRepoDirectory>);
2. alignWithUserInstallation(false);
3. mavenEmbedder.start();

Thanks,
Dan

PS: Any chance this fix could make it into 2.0.4? 


-----Original Message-----
From: Jason van Zyl [mailto:jason@maven.org] 
Sent: Thursday, March 30, 2006 4:29 PM
To: Maven Users List
Subject: Re: [m2.0.3] Embedder - setAlignWithUser ignored

Rollo, Dan wrote:
> It appears there is no way to override the "localRepository" used by 
> MavenEmbedder.

There is on a branch I'm working on which will most likely be merged
into the trunk after the 2.0.4 release.

> 
> 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() ); ...
> 
> 
>>>From the behavior and code, the detectUserInstallation() method will
> never allow me to override the localRepository if an ".m2" user 
> directory exists (even if I call setAlignWithUserInstallation(false)
> before calling start() ). This don't seem right. 
> 
> I believe the purpose of the setLocalRepositoryDirectory() is to allow

> overriding the default local repo location, but the current logic in 
> the
> start() method always sets the field "alignWithUserInstallation" to 
> true if ".m2" exists.
> 
> Is the local repo dir supposed to be overridable, and if so, is there 
> some other way to do it?
> 
> Thanks,
> Dan
> 
> --------------------------------------------------
> This e-mail and any files transmitted with it may contain privileged
or confidential information.
> It is solely for use by the individual for whom it is intended, even
if addressed incorrectly.
> If you received this e-mail in error, please notify the sender; do not

> disclose, copy, distribute, or take any action in reliance on the 
> contents of this information; and delete it from your system. Any
other use of this e-mail is prohibited.
> 
> Thank you for your compliance.
> --------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 


--
jvz.

Jason van Zyl
jason at maven.org
http://maven.apache.org

Simplex sigillum veri. (Simplicity is the seal of truth.)

--------------------------------------------------
This e-mail and any files transmitted with it may contain privileged or confidential information.
It is solely for use by the individual for whom it is intended, even if addressed incorrectly.
If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute,
or take any action in reliance on the contents of this information; and delete it from
your system. Any other use of this e-mail is prohibited.

Thank you for your compliance.
--------------------------------------------------

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


Mime
View raw message