<commit_before>/*
 *  Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you 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.wso2.carbon.uuf.maven;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.wso2.carbon.uuf.maven.util.ConfigFileCreator;

import java.nio.file.Paths;
import java.util.Map;

/**
 * UUF Component creation Mojo that generates the osgi-imports when this component uses any OSGi imports
 * and creates the component zip archive for the given component project.
 *
 * @since 1.0.0
 */
@Mojo(name = "create-component", inheritByDefault = false, requiresDependencyResolution = ResolutionScope.COMPILE,
      threadSafe = true, defaultPhase = LifecyclePhase.PACKAGE)
public class ComponentMojo extends AbstractZipMojo {

    /**
     * OSGi {@code <Import-Package>} instructions for this UUF Component.
     */
    @Parameter(readonly = true, required = false)
    private Map<String, String> instructions;

    @Override
    public String getZipBaseDirectory() {
        int lastIndex = artifactId.lastIndexOf(".");
        if (lastIndex > -1) {
            return artifactId.substring(lastIndex + 1);
        }
        return artifactId;
    }

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        // create OSGi imports file
        if ((instructions != null) && !instructions.isEmpty()) {
            ConfigFileCreator.createOsgiImports(instructions.get(CONFIGURATION_IMPORT_PACKAGE),
                                                Paths.get(outputDirectoryPath));
        }
        super.execute();
    }
}
<commit_msg>added a validation for packaging type in ComponentMojo class<commit_after>/*
 *  Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you 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.wso2.carbon.uuf.maven;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.wso2.carbon.uuf.maven.util.ConfigFileCreator;

import java.nio.file.Paths;
import java.util.Map;

/**
 * UUF Component creation Mojo that generates the osgi-imports when this component uses any OSGi imports and creates the
 * component zip archive for the given component project.
 *
 * @since 1.0.0
 */
@Mojo(name = "create-component", inheritByDefault = false, requiresDependencyResolution = ResolutionScope.COMPILE,
      threadSafe = true, defaultPhase = LifecyclePhase.PACKAGE)
public class ComponentMojo extends AbstractZipMojo {

    /**
     * OSGi {@code <Import-Package>} instructions for this UUF Component.
     */
    @Parameter(readonly = true, required = false)
    private Map<String, String> instructions;

    @Override
    public String getZipBaseDirectory() {
        int lastIndex = artifactId.lastIndexOf(".");
        if (lastIndex > -1) {
            return artifactId.substring(lastIndex + 1);
        }
        return artifactId;
    }

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        if (!ARTIFACT_TYPE_UUF_COMPONENT.equals(packaging)) {
            throw new MojoExecutionException(
                    "Packaging type of an UUF Component should be '" + ARTIFACT_TYPE_UUF_COMPONENT +
                            "'. Instead found '" + packaging + "'.");
        }

        // create OSGi imports file
        if ((instructions != null) && !instructions.isEmpty()) {
            ConfigFileCreator.createOsgiImports(instructions.get(CONFIGURATION_IMPORT_PACKAGE),
                                                Paths.get(outputDirectoryPath));
        }
        super.execute();
    }
}

{'fraction_non_alphanumeric': 0.09228728444191775, 'fraction_numerical': 0.006822057987492893, 'mean_word_length': 3.1955484896661366, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4939845', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1433, 'n_words': 437}