<commit_before>/*
 * Copyright 2014 the original author or authors.
 *
 * 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.
 */

package org.gradle.jvm.internal;

import org.gradle.api.artifacts.component.LibraryBinaryIdentifier;
import org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier;
import org.gradle.jvm.JvmBinaryTasks;
import org.gradle.jvm.internal.toolchain.JavaToolChainInternal;
import org.gradle.jvm.platform.JavaPlatform;
import org.gradle.jvm.toolchain.JavaToolChain;
import org.gradle.platform.base.ComponentSpec;
import org.gradle.platform.base.DependencySpec;
import org.gradle.platform.base.binary.BaseBinarySpec;
import org.gradle.platform.base.internal.BinaryBuildAbility;
import org.gradle.platform.base.internal.ToolSearchBuildAbility;

import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;

public class DefaultJarBinarySpec extends BaseBinarySpec implements JarBinarySpecInternal {
    private final JvmBinaryTasks tasks = new DefaultJvmBinaryTasks(super.getTasks());
    private JavaToolChain toolChain;
    private JavaPlatform platform;
    private File classesDir;
    private File resourcesDir;
    private File jarFile;
    private File apiJarFile;
    private Set<String> exportedPackages = Collections.emptySet();
    private Collection<DependencySpec> apiDependencies = Collections.emptySet();
    private Collection<DependencySpec> componentLevelDependencies = Collections.emptySet();

    @Override
    protected String getTypeName() {
        return "Jar";
    }

    @Override
    public LibraryBinaryIdentifier getId() {
        ComponentSpec component = getComponent();
        return new DefaultLibraryBinaryIdentifier(component.getProjectPath(), component.getName(), getName());
    }

    @Override
    public JvmBinaryTasks getTasks() {
        return tasks;
    }

    @Override
    public JavaToolChain getToolChain() {
        return toolChain;
    }

    @Override
    public void setToolChain(JavaToolChain toolChain) {
        this.toolChain = toolChain;
    }

    @Override
    public JavaPlatform getTargetPlatform() {
        return platform;
    }

    @Override
    public void setTargetPlatform(JavaPlatform platform) {
        this.platform = platform;
    }

    @Override
    public File getJarFile() {
        return jarFile;
    }

    @Override
    public void setJarFile(File jarFile) {
        this.jarFile = jarFile;
    }

    @Override
    public File getApiJarFile() {
        return apiJarFile;
    }

    @Override
    public void setApiJarFile(File apiJarFile) {
        this.apiJarFile = apiJarFile;
    }

    @Override
    public File getClassesDir() {
        return classesDir;
    }

    @Override
    public void setClassesDir(File classesDir) {
        this.classesDir = classesDir;
    }

    @Override
    public File getResourcesDir() {
        return resourcesDir;
    }

    @Override
    public void setResourcesDir(File resourcesDir) {
        this.resourcesDir = resourcesDir;
    }

    @Override
    public void setExportedPackages(Set<String> exportedPackages) {
        this.exportedPackages = exportedPackages;
    }

    @Override
    public Set<String> getExportedPackages() {
        return exportedPackages;
    }

    @Override
    public void setApiDependencies(Collection<DependencySpec> apiDependencies) {
       this.apiDependencies = apiDependencies;
    }

    @Override
    public Collection<DependencySpec> getApiDependencies() {
        return apiDependencies;
    }

    @Override
    public void setDependencies(Collection<DependencySpec> dependencies) {
        componentLevelDependencies = dependencies;
    }

    @Override
    public Collection<DependencySpec> getDependencies() {
        return componentLevelDependencies;
    }

    @Override
    protected BinaryBuildAbility getBinaryBuildAbility() {
        return new ToolSearchBuildAbility(((JavaToolChainInternal) getToolChain()).select(getTargetPlatform()));
    }
}<commit_msg>Defensively copy possibly mutable collection<commit_after>/*
 * Copyright 2014 the original author or authors.
 *
 * 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.
 */

package org.gradle.jvm.internal;

import com.google.common.collect.ImmutableSet;
import org.gradle.api.artifacts.component.LibraryBinaryIdentifier;
import org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier;
import org.gradle.jvm.JvmBinaryTasks;
import org.gradle.jvm.internal.toolchain.JavaToolChainInternal;
import org.gradle.jvm.platform.JavaPlatform;
import org.gradle.jvm.toolchain.JavaToolChain;
import org.gradle.platform.base.ComponentSpec;
import org.gradle.platform.base.DependencySpec;
import org.gradle.platform.base.binary.BaseBinarySpec;
import org.gradle.platform.base.internal.BinaryBuildAbility;
import org.gradle.platform.base.internal.ToolSearchBuildAbility;

import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;

public class DefaultJarBinarySpec extends BaseBinarySpec implements JarBinarySpecInternal {
    private final JvmBinaryTasks tasks = new DefaultJvmBinaryTasks(super.getTasks());
    private JavaToolChain toolChain;
    private JavaPlatform platform;
    private File classesDir;
    private File resourcesDir;
    private File jarFile;
    private File apiJarFile;
    private Set<String> exportedPackages = Collections.emptySet();
    private Collection<DependencySpec> apiDependencies = Collections.emptySet();
    private Collection<DependencySpec> componentLevelDependencies = Collections.emptySet();

    @Override
    protected String getTypeName() {
        return "Jar";
    }

    @Override
    public LibraryBinaryIdentifier getId() {
        ComponentSpec component = getComponent();
        return new DefaultLibraryBinaryIdentifier(component.getProjectPath(), component.getName(), getName());
    }

    @Override
    public JvmBinaryTasks getTasks() {
        return tasks;
    }

    @Override
    public JavaToolChain getToolChain() {
        return toolChain;
    }

    @Override
    public void setToolChain(JavaToolChain toolChain) {
        this.toolChain = toolChain;
    }

    @Override
    public JavaPlatform getTargetPlatform() {
        return platform;
    }

    @Override
    public void setTargetPlatform(JavaPlatform platform) {
        this.platform = platform;
    }

    @Override
    public File getJarFile() {
        return jarFile;
    }

    @Override
    public void setJarFile(File jarFile) {
        this.jarFile = jarFile;
    }

    @Override
    public File getApiJarFile() {
        return apiJarFile;
    }

    @Override
    public void setApiJarFile(File apiJarFile) {
        this.apiJarFile = apiJarFile;
    }

    @Override
    public File getClassesDir() {
        return classesDir;
    }

    @Override
    public void setClassesDir(File classesDir) {
        this.classesDir = classesDir;
    }

    @Override
    public File getResourcesDir() {
        return resourcesDir;
    }

    @Override
    public void setResourcesDir(File resourcesDir) {
        this.resourcesDir = resourcesDir;
    }

    @Override
    public void setExportedPackages(Set<String> exportedPackages) {
        this.exportedPackages = exportedPackages;
    }

    @Override
    public Set<String> getExportedPackages() {
        return exportedPackages;
    }

    @Override
    public void setApiDependencies(Collection<DependencySpec> apiDependencies) {
       this.apiDependencies = apiDependencies;
    }

    @Override
    public Collection<DependencySpec> getApiDependencies() {
        return apiDependencies;
    }

    @Override
    public void setDependencies(Collection<DependencySpec> dependencies) {
        componentLevelDependencies = ImmutableSet.copyOf(dependencies);
    }

    @Override
    public Collection<DependencySpec> getDependencies() {
        return componentLevelDependencies;
    }

    @Override
    protected BinaryBuildAbility getBinaryBuildAbility() {
        return new ToolSearchBuildAbility(((JavaToolChainInternal) getToolChain()).select(getTargetPlatform()));
    }
}
{'fraction_non_alphanumeric': 0.07743629005796784, 'fraction_numerical': 0.0017499726566772395, 'mean_word_length': 3.5177865612648223, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1699213', 'n_tokens_mistral': 2468, 'n_tokens_neox': 2352, 'n_words': 626}