/*
 * Copyright 2011 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.api.internal.artifacts.mvnsettings;

import org.gradle.api.Nullable;
import org.gradle.internal.SystemProperties;

import java.io.File;

/**
* @author Szczepan Faber, created at: 3/30/11
*/
public class DefaultMavenFileLocations implements MavenFileLocations {
    public File getUserMavenDir() {
        return new File(SystemProperties.getUserHome(), ".m2");
    }

    @Nullable
    public File getGlobalMavenDir() {
        String m2Home = System.getenv("M2_HOME");
        if (m2Home == null) {
            return null;
        }
        return new File(m2Home);
    }

    public File getUserSettingsFile() {
        return new File(getUserMavenDir(), "settings.xml");
    }

    @Nullable
    public File getGlobalSettingsFile() {
        File dir = getGlobalMavenDir();
        if (dir == null) {
            return null;
        }
        return new File(dir, "conf/settings.xml");
    }
}
@@ -742,16 +742,58 @@
 perties;
+%0Aimport org.gradle.util.DeprecationLogger;
 %0A%0Aimport
@@ -1179,35 +1179,379 @@
             
-return null
+m2Home = System.getProperty(%22M2_HOME%22);%0A            if(m2Home==null)%7B%0A                return null;%0A            %7D%0A            DeprecationLogger.nagUserWith(%22Found defined M2_HOME system property. Handling M2_HOME system property is deprecated in Gradle and will be removed in the next version of Gradle. Please use a M2_HOME environment variable instead.%22)
 ;%0A        %7D%0A

Handle M2_HOME system property as in the past, but add deprecation warning.