All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gradle.api.file.ContentFilterable Maven / Gradle / Ivy

/*
 * Copyright 2009 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.file;

import groovy.lang.Closure;
import org.gradle.api.Transformer;

import java.io.FilterReader;
import java.util.Map;

/**
 * Represents some binary resource whose content can be filtered.
 */
public interface ContentFilterable {
    /**
     * 

Adds a content filter to be used during the copy. Multiple calls to filter, add additional filters to the * filter chain. Each filter should implement {@code java.io.FilterReader}. Include {@code * org.apache.tools.ant.filters.*} for access to all the standard Ant filters.

* *

Filter properties may be specified using groovy map syntax.

* *

Examples: *

     *    filter(HeadFilter, lines:25, skip:2)
     *    filter(ReplaceTokens, tokens:[copyright:'2009', version:'2.3.1'])
     * 
* * @param properties map of filter properties * @param filterType Class of filter to add * @return this */ ContentFilterable filter(Map properties, Class filterType); /** *

Adds a content filter to be used during the copy. Multiple calls to filter, add additional filters to the * filter chain. Each filter should implement {@code java.io.FilterReader}. Include {@code * org.apache.tools.ant.filters.*} for access to all the standard Ant filters.

* *

Examples: *

     *    filter(StripJavaComments)
     *    filter(com.mycompany.project.CustomFilter)
     * 
* * @param filterType Class of filter to add * @return this */ ContentFilterable filter(Class filterType); /** * Adds a content filter based on the provided closure. The Closure will be called with each line (stripped of line * endings) and should return a String to replace the line or {@code null} to remove the line. If every line is * removed, the result will be an empty file, not an absent one. * * @param closure to implement line based filtering * @return this */ ContentFilterable filter(Closure closure); //TODO:rbo Change the parameter type to `Transformer` once we migrate to Java 8 /** * Adds a content filter based on the provided transformer. The Closure will be called with each line (stripped of line * endings) and should return a String to replace the line or {@code null} to remove the line. If every line is * removed, the result will be an empty file, not an absent one. * * @param transformer to implement line based filtering * @return this */ ContentFilterable filter(Transformer transformer); /** *

Expands property references in each file as it is copied. More specifically, each file is transformed using * Groovy's {@link groovy.text.SimpleTemplateEngine}. This means you can use simple property references, such as * $property or ${property} in the file. You can also include arbitrary Groovy code in the * file, such as ${version ?: 'unknown'} or ${classpath*.name.join(' ')} * * @param properties to implement line based filtering * @return this */ ContentFilterable expand(Map properties); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy