<commit_before>package org.alfresco.maven.plugin;

import java.io.File;
import java.io.IOException;

import org.alfresco.repo.module.tool.ModuleManagementTool;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * Performs a AMP to WAR overlay invoking the Alfresco Repository ModuleManagementTool.
 * It therefore wraps and emulates the same WAR overlay performed by Alfresco MMT.
 * <p/>
 * This goal will install the AMP file(s) found in ${ampLocation} onto the WAR (or exploded WAR) found in ${warLocation}
 * 
 * @version $Id:$
 * @requiresDependencyResolution
 * @since 1.0
 * @goal install
 * @description Installs one or more AMPs onto an Alfresco / Share WAR (or
 *              exploded WAR folder)
 */
public class InstallMojo extends AbstractMojo {

    private static final String WEBAPP_MANIFEST_PATH = "META-INF" + File.separator + "MANIFEST.MF";
    private static final String WEBAPP_DESCRIPTOR_PATH = "WEB-INF" + File.separator + "web.xml";

    /**
     * The location of the AMP file(s) to be installed. If this location is a
     * folder all AMPs contained in the folder are installed, if it's a file it
     * get direclty installed on the ${warLocation}
     * 
     * @parameter property="maven.alfresco.ampLocation" default-value="${project.build.directory}/${project.build.finalName}.amp"
     */
    private File ampLocation;
    
    /**
     * The WAR file or exploded dir to install the AMPs in. If specified
     * Defaults to <code>"${project.build.directory}/${project.build.finalName}-war</code>
     * 
     * @parameter property="maven.alfresco.warLocation" default-value="${project.build.directory}/${project.build.finalName}-war"
     */
    private File warLocation;
    
    /**
     * Whether Alfresco MMT should be executed in verbose mode
     * 
     * @parameter property="maven.alfresco.verbose" default-value="false"
     */
    private boolean verbose;
    
    /**
     * Whether Alfresco MMT should be force installation of AMPs
     * 
     * @parameter property="maven.alfresco.force" default-value="true"
     */
    private boolean force;
    
    /**
     * Whether Alfresco MMT should produce backups while installing. Defaults to false to speed up development, set to true for Production AMP installations
     * 
     * @parameter property="maven.alfresco.backup" default-value="false"
     */
    private boolean backup;
    
    /**
     * Whether or not to skip the check for a manifest file in the warLocation
     * 
     * @parameter property="maven.alfresco.skipWarManifestCheck" default-value="false"
     */
    private boolean skipWarManifestCheck;

    public InstallMojo() {
    }

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        // Checks appropriate input params are in place
        checkParams();
        ModuleManagementTool mmt = new ModuleManagementTool();
        mmt.setVerbose(verbose);
        /**
         * Invoke the ModuleManagementTool to install AMP modules on the WAR
         * file; if ampLocation is a folder all contained AMPs are installed otherwise 
         * a single AMP install is attempted with the ampLocation
         */
        if(ampLocation.isDirectory())
        {
            try {
                mmt.installModules(ampLocation.getAbsolutePath(),<commit_msg>Added skipAmpInstallation parameter which exits the InstallMojo execution before validation<commit_after>package org.alfresco.maven.plugin;

import java.io.File;
import java.io.IOException;

import org.alfresco.repo.module.tool.ModuleManagementTool;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * Performs a AMP to WAR overlay invoking the Alfresco Repository ModuleManagementTool.
 * It therefore wraps and emulates the same WAR overlay performed by Alfresco MMT.
 * <p/>
 * This goal will install the AMP file(s) found in ${ampLocation} onto the WAR (or exploded WAR) found in ${warLocation}
 * 
 * @version $Id:$
 * @requiresDependencyResolution
 * @since 1.0
 * @goal install
 * @description Installs one or more AMPs onto an Alfresco / Share WAR (or
 *              exploded WAR folder)
 */
public class InstallMojo extends AbstractMojo {

    private static final String WEBAPP_MANIFEST_PATH = "META-INF" + File.separator + "MANIFEST.MF";
    private static final String WEBAPP_DESCRIPTOR_PATH = "WEB-INF" + File.separator + "web.xml";

    /**
     * The location of the AMP file(s) to be installed. If this location is a
     * folder all AMPs contained in the folder are installed, if it's a file it
     * get direclty installed on the ${warLocation}
     * 
     * @parameter property="maven.alfresco.ampLocation" default-value="${project.build.directory}/${project.build.finalName}.amp"
     */
    private File ampLocation;
    
    /**
     * The WAR file or exploded dir to install the AMPs in. If specified
     * Defaults to <code>"${project.build.directory}/${project.build.finalName}-war</code>
     * 
     * @parameter property="maven.alfresco.warLocation" default-value="${project.build.directory}/${project.build.finalName}-war"
     */
    private File warLocation;
    
    /**
     * Whether Alfresco MMT should be executed in verbose mode
     * 
     * @parameter property="maven.alfresco.verbose" default-value="false"
     */
    private boolean verbose;
    
    /**
     * Whether Alfresco MMT should be force installation of AMPs
     * 
     * @parameter property="maven.alfresco.force" default-value="true"
     */
    private boolean force;
    
    /**
     * Whether Alfresco MMT should produce backups while installing. Defaults to false to speed up development, set to true for Production AMP installations
     * 
     * @parameter property="maven.alfresco.backup" default-value="false"
     */
    private boolean backup;
    
    /**
     * Whether or not to skip the check for a manifest file in the warLocation
     * 
     * @parameter property="maven.alfresco.skipWarManifestCheck" default-value="false"
     */
    private boolean skipWarManifestCheck;
    
    /**
     * Whether or not to skip the attempt to install the AMP in the warLocation altogether
     * 
     * @parameter property="maven.alfresco.skipAmpInstallation" default-value="false"
     */
    private boolean skipAmpInstallation;

    public InstallMojo() {
    }

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        if (skipAmpInstallation) {
            return;
        }
        // Checks appropriate input params are in place
        checkParams();
        ModuleManagementTool mmt = new ModuleManagementTool();
        mmt.setVerbose(verbose);
        /**
         * Invoke the ModuleManagementTool to install AMP modules on the WAR
         * file; if ampLocation is a folder all contained AMPs are installed otherwise 
         * a single AMP install is attempted with the ampLocation
         */
        if(ampLocation.isDirectory())
        {
            try {
                mmt.installModules(ampLocation.getAbsolutePath(),
{'fraction_non_alphanumeric': 0.09000552181115405, 'fraction_numerical': 0.0005521811154058532, 'mean_word_length': 3.0027624309392267, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2409138', 'n_tokens_mistral': 2053, 'n_tokens_neox': 1970, 'n_words': 626}