<commit_before>package org.jenkins.tools.test;

import hudson.model.UpdateSite;
import hudson.model.UpdateSite.Plugin;
import net.sf.json.JSONObject;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.repository.ScmRepository;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.jenkins.tools.test.exception.PluginSourcesUnavailableException;
import org.jenkins.tools.test.exception.PomExecutionException;
import org.jenkins.tools.test.exception.PomTransformationException;
import org.jenkins.tools.test.model.*;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.URL;
import java.util.Arrays;
import java.util.Map.Entry;

public class PluginCompatTester {

	private PluginCompatTesterConfig config;
	
	public PluginCompatTester(PluginCompatTesterConfig config){
        this.config = config;
	}

	public PluginCompatReport testPlugins() throws PlexusContainerException, IOException {
        UpdateSite.Data data = extractUpdateCenterData();

        // If coreVersion is not provided in PluginCompatTesterConfig, let's use latest core
        // version used in update center
        String coreVersion = config.getParentVersion()==null?data.core.version:config.getParentVersion();
        
		SCMManagerFactory.getInstance().start();

        MavenCoordinates coreArtifact = new MavenCoordinates(config.parentGroupId, config.parentArtifactId, coreVersion);

        PluginCompatReport report = PluginCompatReport.fromXml(config.reportFile);

        for(Entry<String, Plugin> pluginEntry : data.plugins.entrySet()){
            if(config.getPluginsList()==null || config.getPluginsList().contains(pluginEntry.getValue().name)){
                boolean compilationOk = false;
                boolean testsOk = false;
                String errorMessage = null;

                Plugin plugin = pluginEntry.getValue();
                try {
                    MavenExecutionResult result = testPluginAgainst(coreVersion, plugin);
                    // If no PomExecutionException, everything went well...
                    compilationOk = true;
                    testsOk = true;
                } catch (PomExecutionException e) {
                    compilationOk = e.succeededPluginArtifactIds.contains("maven-compiler-plugin");
                    testsOk = e.succeededPluginArtifactIds.contains("maven-surefire-plugin");
                    errorMessage = e.getErrorMessage();
                } catch (Throwable t){
                    errorMessage = t.getMessage();<commit_msg>lowercasing plugin name when comparing it to pluginsList<commit_after>package org.jenkins.tools.test;

import hudson.model.UpdateSite;
import hudson.model.UpdateSite.Plugin;
import net.sf.json.JSONObject;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.repository.ScmRepository;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.jenkins.tools.test.exception.PluginSourcesUnavailableException;
import org.jenkins.tools.test.exception.PomExecutionException;
import org.jenkins.tools.test.exception.PomTransformationException;
import org.jenkins.tools.test.model.*;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.URL;
import java.util.Arrays;
import java.util.Map.Entry;

public class PluginCompatTester {

	private PluginCompatTesterConfig config;
	
	public PluginCompatTester(PluginCompatTesterConfig config){
        this.config = config;
	}

	public PluginCompatReport testPlugins() throws PlexusContainerException, IOException {
        UpdateSite.Data data = extractUpdateCenterData();

        // If coreVersion is not provided in PluginCompatTesterConfig, let's use latest core
        // version used in update center
        String coreVersion = config.getParentVersion()==null?data.core.version:config.getParentVersion();
        
		SCMManagerFactory.getInstance().start();

        MavenCoordinates coreArtifact = new MavenCoordinates(config.parentGroupId, config.parentArtifactId, coreVersion);

        PluginCompatReport report = PluginCompatReport.fromXml(config.reportFile);

        for(Entry<String, Plugin> pluginEntry : data.plugins.entrySet()){
            if(config.getPluginsList()==null || config.getPluginsList().contains(pluginEntry.getValue().name.toLowerCase())){
                boolean compilationOk = false;
                boolean testsOk = false;
                String errorMessage = null;

                Plugin plugin = pluginEntry.getValue();
                try {
                    MavenExecutionResult result = testPluginAgainst(coreVersion, plugin);
                    // If no PomExecutionException, everything went well...
                    compilationOk = true;
                    testsOk = true;
                } catch (PomExecutionException e) {
                    compilationOk = e.succeededPluginArtifactIds.contains("maven-compiler-plugin");
                    testsOk = e.succeededPluginArtifactIds.contains("maven-surefire-plugin");
                    errorMessage = e.getErrorMessage();
                } catch (Throwable t){
                    errorMessage = t.getMessage();
{'fraction_non_alphanumeric': 0.09296524197571927, 'fraction_numerical': 0.0, 'mean_word_length': 3.386579139314369, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1377177', 'n_tokens_mistral': 1658, 'n_tokens_neox': 1567, 'n_words': 298}