<commit_before>/*
 * Copyright 2007 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.api.tasks.util

import org.gradle.api.internal.file.FileResolver

/**
 * @author <NAME>
 */
class ZipFileSet extends FileSet {
    String prefix
    String fullPath
    String fileMode
    String dirMode

    ZipFileSet(File dir, FileResolver resolver) {
        super(dir, resolver)
    }

    ZipFileSet(Map args, FileResolver resolver) {
        super(args, resolver)
    }

    protected doAddFileSet(Object builder, File dir, String nodeName) {
        Map args = [prefix: prefix, fullpath: fullPath, filemode: fileMode, dirmode: dirMode]
        if (dir.isDirectory()) {
            args.dir = dir.absolutePath
        } else {
            args.src = dir.absolutePath
        }
        removeEmptyArgs(args)
        builder.zipfileset(args) {
            patternSet.addToAntBuilder(builder)
        }
    }

    def removeEmptyArgs(Map args) {
        Set emptyKeys = args.keySet().findAll { !args[it] }
        emptyKeys.each { args.remove(it) }
    }

}<commit_msg>GRADLE-668 ZipFileSet attributes should be lazily evaluated at execution time.<commit_after>/*
 * Copyright 2007 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.api.tasks.util

import org.gradle.api.internal.file.FileResolver

/**
 * @author <NAME>
 */
class ZipFileSet extends FileSet {
    Object prefix
    Object fullPath
    Object fileMode
    Object dirMode

    ZipFileSet(File dir, FileResolver resolver) {
        super(dir, resolver)
    }

    ZipFileSet(Map args, FileResolver resolver) {
        super(args, resolver)
    }

    protected doAddFileSet(Object builder, File dir, String nodeName) {
        Map args = [:]
        addToArgsIfNotNull(args, 'prefix', prefix)
        addToArgsIfNotNull(args, 'fullpath', fullPath)
        addToArgsIfNotNull(args, 'filemode', fileMode)
        addToArgsIfNotNull(args, 'dirmode', dirMode)
        if (dir.isDirectory()) {
            args.dir = dir.absolutePath
        } else {
            args.src = dir.absolutePath
        }
        removeEmptyArgs(args)
        builder.zipfileset(args) {
            patternSet.addToAntBuilder(builder)
        }
    }

    def removeEmptyArgs(Map args) {
        Set emptyKeys = args.keySet().findAll { !args[it] }
        emptyKeys.each { args.remove(it) }
    }


    void addToArgsIfNotNull(Map args, String key, Object value) {
        if (value) args[key] = value.toString()
    }
}
{'fraction_non_alphanumeric': 0.08890131395023763, 'fraction_numerical': 0.005311713726586525, 'mean_word_length': 2.802337938363443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2565571', 'n_tokens_mistral': 1027, 'n_tokens_neox': 991, 'n_words': 328}