private void initSettings()

in src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java [235:303]


    private void initSettings()
    {
        if ( userSettingsFile == null )
        {
            File tempSettingsFile = newFile( System.getProperty( "user.home" ), ".ant", "settings.xml" );
            if ( tempSettingsFile.exists() )
            {
                userSettingsFile = tempSettingsFile;
            }
            else
            {
                tempSettingsFile = newFile( System.getProperty( "user.home" ), ".m2", "settings.xml" );
                if ( tempSettingsFile.exists() )
                {
                    userSettingsFile = tempSettingsFile;
                }
            }
        }
        if ( globalSettingsFile == null )
        {
            File tempSettingsFile = newFile( System.getProperty( "ant.home" ), "etc", "settings.xml" );
            if ( tempSettingsFile.exists() )
            {
                globalSettingsFile = tempSettingsFile;
            }
            else
            {
                // look in ${M2_HOME}/conf
                List<String> env = Execute.getProcEnvironment();
                for ( String var: env )
                {
                    if ( var.startsWith( "M2_HOME=" ) )
                    {
                        String m2Home = var.substring( "M2_HOME=".length() );
                        tempSettingsFile = newFile( m2Home, "conf", "settings.xml" );
                        if ( tempSettingsFile.exists() )
                        {
                            globalSettingsFile = tempSettingsFile;
                        }
                        break;
                    }
                }
            }
        }

        Settings userSettings = loadSettings( userSettingsFile );
        Settings globalSettings = loadSettings( globalSettingsFile );

        SettingsUtils.merge( userSettings, globalSettings, TrackableBase.GLOBAL_LEVEL );
        settings = userSettings;

        if ( StringUtils.isEmpty( settings.getLocalRepository() ) )
        {
            String location = newFile( System.getProperty( "user.home" ), ".m2", "repository" ).getAbsolutePath();
            settings.setLocalRepository( location );
        }

        WagonManager wagonManager = (WagonManager) lookup( WagonManager.ROLE );
        wagonManager.setDownloadMonitor( new AntDownloadMonitor() );
        if ( settings.isOffline() )
        {
            log( "You are working in offline mode.", Project.MSG_INFO );
            wagonManager.setOnline( false );
        }
        else
        {
            wagonManager.setOnline( true );
        }
    }