<commit_before>
import compile.CompilerConfiguration;
import compile.JavacCompiler;
import download.ArtifactDownloader;
import jar.JarMojo;
import model.Dependency;
import model.ModelReader;
import model.Repository;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import test.SurefirePlugin;
import util.AbstractReader;
import util.Commandline;
import util.FileUtils;
import util.IOUtil;
import util.IsolatedClassLoader;
import util.Os;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class MBoot
{
    String[] builds = new String[]{"maven-model", "maven-settings", "maven-monitor", "maven-plugin-api",
                                   "maven-plugin-descriptor", "maven-artifact", "maven-script/maven-script-marmalade",
                                   "maven-project", "maven-core", "maven-archiver",
                                   "maven-reporting/maven-reporting-api", "maven-plugin-tools/maven-plugin-tools-api",
                                   "maven-plugin-tools/maven-plugin-tools-java",
                                   "maven-plugin-tools/maven-plugin-tools-pluggy",
                                   "maven-plugin-tools/maven-plugin-tools-marmalade", "maven-core-it-verifier"};

    String[] pluginBuilds = new String[]{"maven-plugins/maven-clean-plugin", "maven-plugins/maven-compiler-plugin",
                                         "maven-plugins/maven-install-plugin", "maven-plugins/maven-jar-plugin",
                                         "maven-plugins/maven-plugin-plugin", "maven-plugins/maven-resources-plugin",
                                         "maven-plugins/maven-surefire-plugin"};

    private static final Map MODELLO_TARGET_VERSIONS;

    private static final Map MODELLO_MODEL_FILES;

    static
    {
        Map targetVersions = new TreeMap();
        targetVersions.put( "maven-model", "4.0.0" );
        targetVersions.put( "maven-settings", "1.0.0" );

        MODELLO_TARGET_VERSIONS = Collections.unmodifiableMap( targetVersions );

        Map modelFiles = new TreeMap();
        modelFiles.put( "maven-model", "maven.mdo" );
        modelFiles.put( "maven-settings", "settings.mdo" );

        MODELLO_MODEL_FILES = Collections.unmodifiableMap( modelFiles );
    }

    // ----------------------------------------------------------------------
    // Standard locations for resources in Maven projects.
    // ----------------------------------------------------------------------

    private static final String SOURCES = "src/main/java";

    private static final String TEST_SOURCES = "src/test/java";

    private static final String RESOURCES = "src/main/resources";

    private static final String TEST_RESOURCES = "src/test/resources";

    private static final String BUILD_DIR = "target";

    private static final String CLASSES = BUILD_DIR + "/classes";

    private static final String TEST_CLASSES = BUILD_DIR + "/test-classes";

    private static final String GENERATED_SOURCES = BUILD_DIR + "/generated-sources";

    private static final String GENERATED_DOCS = BUILD_DIR + "/generated-docs";

    // ----------------------------------------------------------------------
    // Per-session entities which we can reuse while building many projects.
    // ----------------------------------------------------------------------

    private ArtifactDownloader downloader;

    private boolean online = true;

    private static final String SCOPE_TEST = "test";

    private static final String SCOPE_COMPILE = "compile";

    private static final String SCOPE_RUNTIME = "runtime";

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    public static void main( String[] args )
        throws Exception
    {
        try
        {
            MBoot mboot = new MBoot();

            mboot.run( args );
        }
        catch ( InvocationTargetException e )
        {
            Throwable target = e.getTargetException();

            if ( target instanceof RuntimeException )
            {
                throw (RuntimeException) target;
            }
            else if ( target instanceof Exception )
            {
                throw (Exception) target;
            }
            else
            {
                throw new RuntimeException( target );
            }
        }
    }

    public void run( String[] args )
        throws Exception
    {
        String mavenRepoLocal = System.getProperty( "maven.repo.local" );

        SettingsReader userModelReader = new SettingsReader();

        if ( mavenRepoLocal == null )
        {
            try
            {
                String userHome = System.getProperty( "user.home" );

                File settingsXml = new File( userHome, ".m2/settings.xml" );

                if ( settingsXml.exists() )
                {
                    userModelReader.parse( settingsXml );

                    Profile activeProfile = userModelReader.getActiveProfile();

                    mavenRepoLocal = new File( activeProfile.getLocalRepo() ).getAbsolutePath();
                }
            }
            catch ( Exception e )
            {
                e.printStackTrace();
            }
        }

        if ( mavenRepoLocal == null )
        {
            String userHome = System.getProperty( "user.home" );
            String m2LocalRepoPath = "/.m2/repository";

            File repoDir = new File( userHome, m2LocalRepoPath );
            if ( !repoDir.exists() )
            {
                repoDir.mkdirs();
            }

            mavenRepoLocal = repoDir.getAbsolutePath();

            System.out.println(
                "You SHOULD have a ~/.m2/settings.xml file and must contain at least the following information:" );
            System.out.println();
<commit_msg>always read settings.xml, even if maven.repo.local is given<commit_after>
import compile.CompilerConfiguration;
import compile.JavacCompiler;
import download.ArtifactDownloader;
import jar.JarMojo;
import model.Dependency;
import model.ModelReader;
import model.Repository;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import test.SurefirePlugin;
import util.AbstractReader;
import util.Commandline;
import util.FileUtils;
import util.IOUtil;
import util.IsolatedClassLoader;
import util.Os;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class MBoot
{
    String[] builds = new String[]{"maven-model", "maven-settings", "maven-monitor", "maven-plugin-api",
                                   "maven-plugin-descriptor", "maven-artifact", "maven-script/maven-script-marmalade",
                                   "maven-project", "maven-core", "maven-archiver",
                                   "maven-reporting/maven-reporting-api", "maven-plugin-tools/maven-plugin-tools-api",
                                   "maven-plugin-tools/maven-plugin-tools-java",
                                   "maven-plugin-tools/maven-plugin-tools-pluggy",
                                   "maven-plugin-tools/maven-plugin-tools-marmalade", "maven-core-it-verifier"};

    String[] pluginBuilds = new String[]{"maven-plugins/maven-clean-plugin", "maven-plugins/maven-compiler-plugin",
                                         "maven-plugins/maven-install-plugin", "maven-plugins/maven-jar-plugin",
                                         "maven-plugins/maven-plugin-plugin", "maven-plugins/maven-resources-plugin",
                                         "maven-plugins/maven-surefire-plugin"};

    private static final Map MODELLO_TARGET_VERSIONS;

    private static final Map MODELLO_MODEL_FILES;

    static
    {
        Map targetVersions = new TreeMap();
        targetVersions.put( "maven-model", "4.0.0" );
        targetVersions.put( "maven-settings", "1.0.0" );

        MODELLO_TARGET_VERSIONS = Collections.unmodifiableMap( targetVersions );

        Map modelFiles = new TreeMap();
        modelFiles.put( "maven-model", "maven.mdo" );
        modelFiles.put( "maven-settings", "settings.mdo" );

        MODELLO_MODEL_FILES = Collections.unmodifiableMap( modelFiles );
    }

    // ----------------------------------------------------------------------
    // Standard locations for resources in Maven projects.
    // ----------------------------------------------------------------------

    private static final String SOURCES = "src/main/java";

    private static final String TEST_SOURCES = "src/test/java";

    private static final String RESOURCES = "src/main/resources";

    private static final String TEST_RESOURCES = "src/test/resources";

    private static final String BUILD_DIR = "target";

    private static final String CLASSES = BUILD_DIR + "/classes";

    private static final String TEST_CLASSES = BUILD_DIR + "/test-classes";

    private static final String GENERATED_SOURCES = BUILD_DIR + "/generated-sources";

    private static final String GENERATED_DOCS = BUILD_DIR + "/generated-docs";

    // ----------------------------------------------------------------------
    // Per-session entities which we can reuse while building many projects.
    // ----------------------------------------------------------------------

    private ArtifactDownloader downloader;

    private boolean online = true;

    private static final String SCOPE_TEST = "test";

    private static final String SCOPE_COMPILE = "compile";

    private static final String SCOPE_RUNTIME = "runtime";

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    public static void main( String[] args )
        throws Exception
    {
        try
        {
            MBoot mboot = new MBoot();

            mboot.run( args );
        }
        catch ( InvocationTargetException e )
        {
            Throwable target = e.getTargetException();

            if ( target instanceof RuntimeException )
            {
                throw (RuntimeException) target;
            }
            else if ( target instanceof Exception )
            {
                throw (Exception) target;
            }
            else
            {
                throw new RuntimeException( target );
            }
        }
    }

    public void run( String[] args )
        throws Exception
    {
        String mavenRepoLocal = System.getProperty( "maven.repo.local" );

        SettingsReader userModelReader = new SettingsReader();

        String userHome = System.getProperty( "user.home" );

        File settingsXml = new File( userHome, ".m2/settings.xml" );

        if ( settingsXml.exists() )
        {
            userModelReader.parse( settingsXml );

            Profile activeProfile = userModelReader.getActiveProfile();

            if ( mavenRepoLocal == null )
            {
                mavenRepoLocal = new File( activeProfile.getLocalRepo() ).getAbsolutePath();
            }
        }

        if ( mavenRepoLocal == null )
        {
            String m2LocalRepoPath = "/.m2/repository";

            File repoDir = new File( userHome, m2LocalRepoPath );
            if ( !repoDir.exists() )
            {
                repoDir.mkdirs();
            }

            mavenRepoLocal = repoDir.getAbsolutePath();

            System.out.println(
                "You SHOULD have a ~/.m2/settings.xml file and must contain at least the following information:" );
            System.out.println();

{'fraction_non_alphanumeric': 0.1619217081850534, 'fraction_numerical': 0.0017793594306049821, 'mean_word_length': 1.7122175915771003, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 9}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '958951', 'n_tokens_mistral': 3240, 'n_tokens_neox': 2996, 'n_words': 712}