<commit_before>/*
 * Copyright 2015 <NAME>
 *
 * 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
 *
 *     https://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 com.github.rodm.teamcity;

import com.github.rodm.teamcity.internal.ClassCollectorAction;
import com.github.rodm.teamcity.internal.PluginDefinition;
import com.github.rodm.teamcity.internal.PluginDefinitionCollectorAction;
import com.github.rodm.teamcity.internal.PluginDefinitionValidationAction;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.api.tasks.bundling.Zip;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

public class TeamCityPlugin implements Plugin<Project> {

    public static final String PLUGIN_DESCRIPTOR_FILENAME = "teamcity-plugin.xml";

    public static final String PLUGIN_DESCRIPTOR_DIR = "descriptor";

    public static final String TEAMCITY_GROUP = "TeamCity";

    public static final String JAVA_PLUGIN_ID = "org.gradle.java";
    public static final String SERVER_PLUGIN_ID = "com.github.rodm.teamcity-server";
    public static final String AGENT_PLUGIN_ID = "com.github.rodm.teamcity-agent";

    public static final String AGENT_CONFIGURATION_NAME = "agent";
    public static final String SERVER_CONFIGURATION_NAME = "server";
    public static final String PLUGIN_CONFIGURATION_NAME = "plugin";
    public static final String PROVIDED_CONFIGURATION_NAME = "provided";

    public static final String GRADLE_OFFLINE = "gradle-offline";

    private static final String JETBRAINS_MAVEN_REPOSITORY = "https://download.jetbrains.com/teamcity-repository";

    private static final String CLASSES_PATTERN = "**/*.class";

    public void apply(Project project) {
        project.getPluginManager().apply(TeamCityBasePlugin.class);

        TeamCityPluginExtension extension = project.getExtensions().getByType(TeamCityPluginExtension.class);
        configureRepositories(project, extension);
        configureConfigurations(project);
    }

    private static void configureRepositories(Project project, TeamCityPluginExtension extension) {
        project.afterEvaluate(p ->
            project.getPluginManager().withPlugin(JAVA_PLUGIN_ID, plugin -> {
                if (extension.getDefaultRepositories()) {
                    project.getRepositories().mavenCentral();
                    project.getRepositories().maven(repository -> repository.setUrl(JETBRAINS_MAVEN_REPOSITORY));<commit_msg>Exclude teamcity groups from Maven Central configuration<commit_after>/*
 * Copyright 2015 <NAME>
 *
 * 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
 *
 *     https://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 com.github.rodm.teamcity;

import com.github.rodm.teamcity.internal.ClassCollectorAction;
import com.github.rodm.teamcity.internal.PluginDefinition;
import com.github.rodm.teamcity.internal.PluginDefinitionCollectorAction;
import com.github.rodm.teamcity.internal.PluginDefinitionValidationAction;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.api.tasks.bundling.Zip;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

public class TeamCityPlugin implements Plugin<Project> {

    public static final String PLUGIN_DESCRIPTOR_FILENAME = "teamcity-plugin.xml";

    public static final String PLUGIN_DESCRIPTOR_DIR = "descriptor";

    public static final String TEAMCITY_GROUP = "TeamCity";

    public static final String JAVA_PLUGIN_ID = "org.gradle.java";
    public static final String SERVER_PLUGIN_ID = "com.github.rodm.teamcity-server";
    public static final String AGENT_PLUGIN_ID = "com.github.rodm.teamcity-agent";

    public static final String AGENT_CONFIGURATION_NAME = "agent";
    public static final String SERVER_CONFIGURATION_NAME = "server";
    public static final String PLUGIN_CONFIGURATION_NAME = "plugin";
    public static final String PROVIDED_CONFIGURATION_NAME = "provided";

    public static final String GRADLE_OFFLINE = "gradle-offline";

    private static final String JETBRAINS_MAVEN_REPOSITORY = "https://download.jetbrains.com/teamcity-repository";

    private static final String CLASSES_PATTERN = "**/*.class";

    public void apply(Project project) {
        project.getPluginManager().apply(TeamCityBasePlugin.class);

        TeamCityPluginExtension extension = project.getExtensions().getByType(TeamCityPluginExtension.class);
        configureRepositories(project, extension);
        configureConfigurations(project);
    }

    private static void configureRepositories(Project project, TeamCityPluginExtension extension) {
        project.afterEvaluate(p ->
            project.getPluginManager().withPlugin(JAVA_PLUGIN_ID, plugin -> {
                if (extension.getDefaultRepositories()) {
                    project.getRepositories().mavenCentral(
                        repository -> repository.content(
                            descriptor -> {
                                descriptor.excludeGroup("org.jetbrains.teamcity");
                                descriptor.excludeGroup("org.jetbrains.teamcity.internal");
                            })
                    );
                    project.getRepositories().maven(repository -> repository.setUrl(JETBRAINS_MAVEN_REPOSITORY));
{'fraction_non_alphanumeric': 0.08582653369598066, 'fraction_numerical': 0.0024176488365064974, 'mean_word_length': 3.935868754660701, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6437542', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1746, 'n_words': 456}