<commit_before>package frege.gradle

import org.gradle.api.DefaultTask
import org.gradle.api.internal.file.FileResolver
import org.gradle.api.tasks.*
import org.gradle.process.internal.DefaultJavaExecAction
import org.gradle.process.internal.JavaExecAction

class FregeReplTask extends DefaultTask {

    static String DEFAULT_SRC_DIR        = "src/main/frege"     // TODO: should this come from a source set?
    static String DEFAULT_CLASSES_SUBDIR = "classes/main"       // TODO: should this come from a convention?

    @Optional @InputDirectory
    File sourceDir = new File(project.projectDir, DEFAULT_SRC_DIR).exists() ?  new File(project.projectDir, DEFAULT_SRC_DIR) : null

    @Optional @InputDirectory
    File targetDir = new File(project.buildDir, DEFAULT_CLASSES_SUBDIR)

    @TaskAction
    void openFregeRepl() {

        if (sourceDir != null && !sourceDir.exists() ) {
            def currentDir = new File('.')
            logger.info "Intended source dir '${sourceDir.absolutePath}' doesn't exist. Using current dir '${currentDir.absolutePath}' ."
            sourceDir = currentDir
        }

        FileResolver fileResolver = getServices().get(FileResolver.class)
        JavaExecAction action = new DefaultJavaExecAction(fileResolver)
        action.setMain("frege.repl.FregeRepl")
        action.workingDir = sourceDir
        action.standardInput = System.in
        action.setClasspath(project.files(project.configurations.runtime ) + project.files(targetDir.absolutePath))

        action.execute()<commit_msg>Fixed workingDir to not be null when source dir does not exist<commit_after>package frege.gradle

import org.gradle.api.DefaultTask
import org.gradle.api.internal.file.FileResolver
import org.gradle.api.tasks.*
import org.gradle.process.internal.DefaultJavaExecAction
import org.gradle.process.internal.JavaExecAction

class FregeReplTask extends DefaultTask {

    static String DEFAULT_SRC_DIR        = "src/main/frege"     // TODO: should this come from a source set?
    static String DEFAULT_CLASSES_SUBDIR = "classes/main"       // TODO: should this come from a convention?

    @Optional @InputDirectory
    File sourceDir = new File(project.projectDir, DEFAULT_SRC_DIR).exists() ?  new File(project.projectDir, DEFAULT_SRC_DIR) : null

    @Optional @InputDirectory
    File targetDir = new File(project.buildDir, DEFAULT_CLASSES_SUBDIR)

    @TaskAction
    void openFregeRepl() {

        if (sourceDir != null && !sourceDir.exists() ) {
            def currentDir = new File('.')
            logger.info "Intended source dir '${sourceDir.absolutePath}' doesn't exist. Using current dir '${currentDir.absolutePath}' ."
            sourceDir = currentDir
        }

        FileResolver fileResolver = getServices().get(FileResolver.class)
        JavaExecAction action = new DefaultJavaExecAction(fileResolver)
        action.setMain("frege.repl.FregeRepl")
        action.workingDir = sourceDir ?: project.projectDir
        action.standardInput = System.in
        action.setClasspath(project.files(project.configurations.runtime ) + project.files(targetDir.absolutePath))

        action.execute()
{'fraction_non_alphanumeric': 0.09304541124166402, 'fraction_numerical': 0.0, 'mean_word_length': 3.5323741007194243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7314239', 'n_tokens_mistral': 887, 'n_tokens_neox': 852, 'n_words': 203}