<commit_before>package de.undercouch.gradle.tasks.download.internal;

import org.gradle.api.Project;
import org.gradle.api.file.ProjectLayout;
import org.gradle.util.GradleVersion;

import javax.inject.Inject;
import java.io.File;

public abstract class ProjectApiHelper {

    public static ProjectApiHelper newInstance(Project project) {
        if (GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("6.6")) >= 0) {
            return project.getObjects().newInstance(DefaultProjectApiHelper.class);
        }
        return new LegacyProjectApiHelper(project);
    }

    public abstract File getBuildDirectory();

    public abstract File file(String path);
}

class DefaultProjectApiHelper extends ProjectApiHelper {

    private final ProjectLayout layout;

    @Inject
    public DefaultProjectApiHelper(ProjectLayout layout) {
        this.layout = layout;
    }

    @Override
    public File getBuildDirectory() {
        return layout.getBuildDirectory().getAsFile().get();
    }

    @Override
    public File file(String path) {
        return layout.getProjectDirectory().file(path).getAsFile();
    }
}<commit_msg>Let ProjectApiHelper use injected services with Gradle >= 4.3<commit_after>package de.undercouch.gradle.tasks.download.internal;

import org.gradle.api.Project;
import org.gradle.api.file.ProjectLayout;
import org.gradle.util.GradleVersion;

import javax.inject.Inject;
import java.io.File;

public abstract class ProjectApiHelper {

    public static ProjectApiHelper newInstance(Project project) {
        if (GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("4.3")) >= 0) {
            return project.getObjects().newInstance(DefaultProjectApiHelper.class);
        }
        return new LegacyProjectApiHelper(project);
    }

    public abstract File getBuildDirectory();

    public abstract File file(String path);
}

class DefaultProjectApiHelper extends ProjectApiHelper {

    private final ProjectLayout layout;

    @Inject
    public DefaultProjectApiHelper(ProjectLayout layout) {
        this.layout = layout;
    }

    @Override
    public File getBuildDirectory() {
        return layout.getBuildDirectory().get().getAsFile();
    }

    @Override
    public File file(String path) {
        return layout.getProjectDirectory().file(path).getAsFile();
    }
}
{'fraction_non_alphanumeric': 0.09736394557823129, 'fraction_numerical': 0.003401360544217687, 'mean_word_length': 3.782520325203252, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '537055', 'n_tokens_mistral': 644, 'n_tokens_neox': 618, 'n_words': 137}