<commit_before>package org.apache.maven.cli;

/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * 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.
 */

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.maven.Maven;
import org.apache.maven.MavenConstants;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResponse;
import org.apache.maven.execution.project.MavenProjectExecutionRequest;
import org.apache.maven.execution.project.MavenProjectExecutionRequest;
import org.apache.maven.execution.reactor.MavenReactorExecutionRequest;
import org.apache.maven.execution.reactor.MavenReactorExecutionRequest;
import org.apache.maven.repository.RepositoryUtils;
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.plexus.embed.ArtifactEnabledEmbedder;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Id$
 */
public class MavenCli
{
    public static final String POMv3 = "project.xml";

    public static final String POMv4 = "pom.xml";

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

    public static File userDir = new File( System.getProperty( "user.dir" ) );

    public static int main( String[] args, ClassWorld classWorld )
        throws Exception
    {
        // ----------------------------------------------------------------------
        // Setup the command line parser
        // ----------------------------------------------------------------------

        CLIManager cliManager = new CLIManager();

        CommandLine commandLine = cliManager.parse( args );

        // ----------------------------------------------------------------------
        //
        // 1) maven user configuration directory ( ~/.m2 )
        // 2) maven home
        // 3) local repository
        //
        // ----------------------------------------------------------------------

        File userConfigurationDirectory = getUserConfigurationDirectory();

        Properties mavenProperties = getMavenProperties( userConfigurationDirectory );

        ArtifactRepository localRepository = getLocalRepository( mavenProperties, userConfigurationDirectory );

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

        initializeSystemProperties( commandLine );

        // ----------------------------------------------------------------------
        // Process particular command line options
        // ----------------------------------------------------------------------

        if ( commandLine.hasOption( CLIManager.HELP ) )
        {
            cliManager.displayHelp();

            return 0;
        }

        if ( commandLine.hasOption( CLIManager.VERSION ) )
        {
            System.out.println( "Maven version: " );

            return 0;
        }

        // ----------------------------------------------------------------------
        // Create the execution request/response
        // ----------------------------------------------------------------------

        MavenExecutionRequest request = null;

        if ( commandLine.hasOption( CLIManager.REACTOR ) )
        {
            String includes = System.getProperty( "maven.reactor.includes", "**/" + POMv4 );

            String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );

            request = new MavenReactorExecutionRequest( localRepository,
                                                        commandLine.getArgList(),
                                                        includes,
                                                        excludes,
                                                        userDir );
        }
        else
        {
            File projectFile = new File( userDir, POMv4 );

            if ( !projectFile.exists() )
            {
                projectFile = new File( userDir, POMv3 );

                if ( !projectFile.exists() )
                {
                    System.err.println( "Could not find either a " + POMv4 + " nor a " + POMv3 + " project descriptor." );

                    return 1;
                }
            }
<commit_msg>o we'll deal with v3 -> v4 conversion somewhere else.<commit_after>package org.apache.maven.cli;

/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * 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.
 */

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.maven.Maven;
import org.apache.maven.MavenConstants;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResponse;
import org.apache.maven.execution.project.MavenProjectExecutionRequest;
import org.apache.maven.execution.reactor.MavenReactorExecutionRequest;
import org.apache.maven.repository.RepositoryUtils;
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.plexus.embed.ArtifactEnabledEmbedder;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Id$
 */
public class MavenCli
{
    public static final String POMv4 = "pom.xml";

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

    public static File userDir = new File( System.getProperty( "user.dir" ) );

    public static int main( String[] args, ClassWorld classWorld )
        throws Exception
    {
        // ----------------------------------------------------------------------
        // Setup the command line parser
        // ----------------------------------------------------------------------

        CLIManager cliManager = new CLIManager();

        CommandLine commandLine = cliManager.parse( args );

        // ----------------------------------------------------------------------
        //
        // 1) maven user configuration directory ( ~/.m2 )
        // 2) maven home
        // 3) local repository
        //
        // ----------------------------------------------------------------------

        File userConfigurationDirectory = getUserConfigurationDirectory();

        Properties mavenProperties = getMavenProperties( userConfigurationDirectory );

        ArtifactRepository localRepository = getLocalRepository( mavenProperties, userConfigurationDirectory );

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

        initializeSystemProperties( commandLine );

        // ----------------------------------------------------------------------
        // Process particular command line options
        // ----------------------------------------------------------------------

        if ( commandLine.hasOption( CLIManager.HELP ) )
        {
            cliManager.displayHelp();

            return 0;
        }

        if ( commandLine.hasOption( CLIManager.VERSION ) )
        {
            System.out.println( "Maven version: " );

            return 0;
        }

        // ----------------------------------------------------------------------
        // Create the execution request/response
        // ----------------------------------------------------------------------

        MavenExecutionRequest request = null;

        if ( commandLine.hasOption( CLIManager.REACTOR ) )
        {
            String includes = System.getProperty( "maven.reactor.includes", "**/" + POMv4 );

            String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );

            request = new MavenReactorExecutionRequest( localRepository,
                                                        commandLine.getArgList(),
                                                        includes,
                                                        excludes,
                                                        userDir );
        }
        else
        {
            File projectFile = new File( userDir, POMv4 );

            if ( !projectFile.exists() )
            {
                    System.err.println( "Could not find either a project descriptor." );

                    return 1;
            }

{'fraction_non_alphanumeric': 0.21765586034912718, 'fraction_numerical': 0.0051870324189526185, 'mean_word_length': 1.4217391304347826, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2558456', 'n_tokens_mistral': 2267, 'n_tokens_neox': 2151, 'n_words': 569}