<commit_before>package kr.motd.gradle.sphinx.gradle

import kr.motd.maven.sphinx.SphinxException
import kr.motd.maven.sphinx.SphinxRunner
import kr.motd.maven.sphinx.SphinxUtil
import org.gradle.api.DefaultTask
import org.gradle.api.InvalidUserDataException
import org.gradle.api.tasks.*

import java.util.concurrent.Callable

class SphinxTask extends DefaultTask {

    private def binaryUrl = { SphinxRunner.DEFAULT_BINARY_URL }
    private def binaryCacheDir = { "${project.gradle.gradleUserHomeDir}/caches/sphinx-binary" }
    private def environments = { Collections.emptyMap() }
    private final def additionalEnvironments = new HashMap<String, String>()
    private def dotBinary = null
    private def sourceDirectory = {
        "${project.projectDir}${File.separator}src${File.separator}site${File.separator}sphinx"
    }
    private def outputDirectory = { "${project.buildDir}${File.separator}site" }
    private def doctreeCacheDirectory = { "${project.buildDir}${File.separator}site${File.separator}.doctrees" }
    private def builder = { "html" }
    private def tags = { Collections.emptyList() }
    private final def additionalTags = new ArrayList<String>()
    private def verbose = { true }
    private def traceback = { true }
    private def force = { false }
    private def warningsAsErrors = { false }
    private def skip = { false }
    private def useDoctreeCache = { false }

    private static def unwrap(Object o) {
        if (o instanceof Callable) {
            return o.call()
        } else {
            return o
        }
    }

    @Input
    String getBinaryUrl() {
        return String.valueOf(unwrap(binaryUrl))
    }

    void setBinaryUrl(Object binaryUrl) {
        this.binaryUrl = binaryUrl
    }

    @InputDirectory
    @PathSensitive(PathSensitivity.RELATIVE)
    File getBinaryCacheDir() {
        return project.file(binaryCacheDir).getCanonicalFile()
    }

    void setBinaryCacheDir(Object binaryCacheDir) {
        this.binaryCacheDir = binaryCacheDir;
    }

    @Input
    Map<String, String> getEnvironments() {
        def unwrapped = unwrap(environments)
        if (!(unwrapped instanceof Map)) {
            throw new InvalidUserDataException(
                    "environments must yield a Map<String, String>: ${unwrapped.getClass().name}")
        }

        Map<String, String> env = new HashMap<>()
        env.putAll(unwrapped)
        env.putAll(additionalEnvironments)
        return env
    }

    void setEnvironments(Object environments) {
        this.environments = environments
    }

    void env(String name, String value) {
        additionalEnvironments.put(name, value)
    }

    @Input
    @Optional
    String getDotBinary() {
        def unwrapped = unwrap(dotBinary)
        if (unwrapped == null) {
            return null
        } else {
            return String.valueOf(unwrapped)
        }
    }

    void setDotBinary(Object dotBinary) {
        this.dotBinary = dotBinary
    }

    @SkipWhenEmpty
    @InputDirectory
    @PathSensitive(PathSensitivity.RELATIVE)
    File getSourceDirectory() {
        project.file(sourceDirectory).getCanonicalFile()
    }

    void setSourceDirectory(Object sourceDirectory) {
        this.sourceDirectory = sourceDirectory
    }

    @OutputDirectory
    File getOutputDirectory() {
        project.file(outputDirectory).getCanonicalFile()
    }

    void setOutputDirectory(Object outputDirectory) {
        this.outputDirectory = outputDirectory
    }

    @Input
    @Optional
    File getDoctreeCacheDirectory() {
        project.file(doctreeCacheDirectory).getCanonicalFile()
    }

    void setDoctreeCacheDirectory(Object doctreeCacheDirectory) {
        this.doctreeCacheDirectory = doctreeCacheDirectory
    }

    @Input
    String getBuilder() {
        return String.valueOf(unwrap(builder))
    }

    void setBuilder(Object builder) {
        this.builder = builder
    }

    @Input<commit_msg>Fix another deprecation warning<commit_after>package kr.motd.gradle.sphinx.gradle

import kr.motd.maven.sphinx.SphinxException
import kr.motd.maven.sphinx.SphinxRunner
import kr.motd.maven.sphinx.SphinxUtil
import org.gradle.api.DefaultTask
import org.gradle.api.InvalidUserDataException
import org.gradle.api.tasks.*

import java.util.concurrent.Callable

class SphinxTask extends DefaultTask {

    private def binaryUrl = { SphinxRunner.DEFAULT_BINARY_URL }
    private def binaryCacheDir = { "${project.gradle.gradleUserHomeDir}/caches/sphinx-binary" }
    private def environments = { Collections.emptyMap() }
    private final def additionalEnvironments = new HashMap<String, String>()
    private def dotBinary = null
    private def sourceDirectory = {
        "${project.projectDir}${File.separator}src${File.separator}site${File.separator}sphinx"
    }
    private def outputDirectory = { "${project.buildDir}${File.separator}site" }
    private def doctreeCacheDirectory = { "${project.buildDir}${File.separator}site${File.separator}.doctrees" }
    private def builder = { "html" }
    private def tags = { Collections.emptyList() }
    private final def additionalTags = new ArrayList<String>()
    private def verbose = { true }
    private def traceback = { true }
    private def force = { false }
    private def warningsAsErrors = { false }
    private def skip = { false }
    private def useDoctreeCache = { false }

    private static def unwrap(Object o) {
        if (o instanceof Callable) {
            return o.call()
        } else {
            return o
        }
    }

    @Input
    String getBinaryUrl() {
        return String.valueOf(unwrap(binaryUrl))
    }

    void setBinaryUrl(Object binaryUrl) {
        this.binaryUrl = binaryUrl
    }

    @InputFile
    @PathSensitive(PathSensitivity.RELATIVE)
    File getBinaryCacheDir() {
        return project.file(binaryCacheDir).getCanonicalFile()
    }

    void setBinaryCacheDir(Object binaryCacheDir) {
        this.binaryCacheDir = binaryCacheDir;
    }

    @Input
    Map<String, String> getEnvironments() {
        def unwrapped = unwrap(environments)
        if (!(unwrapped instanceof Map)) {
            throw new InvalidUserDataException(
                    "environments must yield a Map<String, String>: ${unwrapped.getClass().name}")
        }

        Map<String, String> env = new HashMap<>()
        env.putAll(unwrapped)
        env.putAll(additionalEnvironments)
        return env
    }

    void setEnvironments(Object environments) {
        this.environments = environments
    }

    void env(String name, String value) {
        additionalEnvironments.put(name, value)
    }

    @Input
    @Optional
    String getDotBinary() {
        def unwrapped = unwrap(dotBinary)
        if (unwrapped == null) {
            return null
        } else {
            return String.valueOf(unwrapped)
        }
    }

    void setDotBinary(Object dotBinary) {
        this.dotBinary = dotBinary
    }

    @SkipWhenEmpty
    @InputDirectory
    @PathSensitive(PathSensitivity.RELATIVE)
    File getSourceDirectory() {
        project.file(sourceDirectory).getCanonicalFile()
    }

    void setSourceDirectory(Object sourceDirectory) {
        this.sourceDirectory = sourceDirectory
    }

    @OutputDirectory
    File getOutputDirectory() {
        project.file(outputDirectory).getCanonicalFile()
    }

    void setOutputDirectory(Object outputDirectory) {
        this.outputDirectory = outputDirectory
    }

    @InputFile
    @PathSensitive(PathSensitivity.RELATIVE)
    File getDoctreeCacheDirectory() {
        project.file(doctreeCacheDirectory).getCanonicalFile()
    }

    void setDoctreeCacheDirectory(Object doctreeCacheDirectory) {
        this.doctreeCacheDirectory = doctreeCacheDirectory
    }

    @Input
    String getBuilder() {
        return String.valueOf(unwrap(builder))
    }

    void setBuilder(Object builder) {
        this.builder = builder
    }

    @Input
{'fraction_non_alphanumeric': 0.09185987903225806, 'fraction_numerical': 0.0, 'mean_word_length': 2.8660496833901608, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '1692576', 'n_tokens_mistral': 2291, 'n_tokens_neox': 2194, 'n_words': 464}