<commit_before>package com.github.dnault.xmlpatch.gradle

import com.github.dnault.xmlpatch.batch.AssembledPatch
import com.github.dnault.xmlpatch.batch.BatchXmlPatchFilter
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.CopySpec
import org.gradle.api.internal.AbstractTask

class XmlPatchPlugin implements Plugin<Project> {
    void apply(Project project) {
        project.getConvention().add("augmentWithXmlPatch", { CopySpec copySpec,
                                                             File patchFile,
                                                             XmlPatchOptions options = new XmlPatchOptions() ->
            if (!patchFile.exists()) {
                def message = "Patch file does not exist: ${patchFile.absolutePath}"
                if (options.failOnMissingPatch) {
                    throw new FileNotFoundException(message)
                }
                project.logger.info message
            }

            project.configure(copySpec) {
                def assembledPatch = new AssembledPatch(patchFile);

                eachFile {
                    filter(BatchXmlPatchFilter, patch: assembledPatch, sourcePath: it.sourcePath)
                }

                if (copySpec instanceof AbstractTask) {
                    def seenSourcePaths = [] as Set
                    def missingSourcePaths = [] as Set

                    eachFile {
                        seenSourcePaths += [it.sourcePath]
                    }<commit_msg>fix login for allowing missing patch file<commit_after>package com.github.dnault.xmlpatch.gradle

import com.github.dnault.xmlpatch.batch.AssembledPatch
import com.github.dnault.xmlpatch.batch.BatchXmlPatchFilter
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.CopySpec
import org.gradle.api.internal.AbstractTask

class XmlPatchPlugin implements Plugin<Project> {
    void apply(Project project) {
        project.getConvention().add("augmentWithXmlPatch", { CopySpec copySpec,
                                                             File patchFile,
                                                             XmlPatchOptions options = new XmlPatchOptions() ->
            if (!patchFile.exists()) {
                def message = "Patch file does not exist: ${patchFile.absolutePath}"
                if (options.failOnMissingPatch) {
                    throw new FileNotFoundException(message)
                }
                project.logger.info message
                return;
            }

            project.configure(copySpec) {
                def assembledPatch = new AssembledPatch(patchFile);

                eachFile {
                    filter(BatchXmlPatchFilter, patch: assembledPatch, sourcePath: it.sourcePath)
                }

                if (copySpec instanceof AbstractTask) {
                    def seenSourcePaths = [] as Set
                    def missingSourcePaths = [] as Set

                    eachFile {
                        seenSourcePaths += [it.sourcePath]
                    }
{'fraction_non_alphanumeric': 0.0721216041397154, 'fraction_numerical': 0.0, 'mean_word_length': 1.6079258010118045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4628578', 'n_tokens_mistral': 724, 'n_tokens_neox': 665, 'n_words': 153}