It appears 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() );
...


>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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to