rename

abstract fun rename(closure: Closure): CopyProcessingSpec(source)

Renames a source file. The closure will be called with a single parameter, the name of the file. The closure should return a String object with a new target name. The closure may return null, in which case the original name will be used.

Files are renamed as they are about to be copied, together with the actions added with eachFile. The actions of a parent spec run first, then the actions of this spec in the order they were added, so an eachFile action added to this spec before the rename sees the name before renaming.

Return

this

Since

0.9

Parameters

closure

rename closure


abstract fun rename(renamer: Transformer<@Nullable String, String>): CopyProcessingSpec(source)

Renames a source file. The function will be called with a single parameter, the name of the file. The function should return a new target name. The function may return null, in which case the original name will be used.

Files are renamed as they are about to be copied, together with the actions added with eachFile. The actions of a parent spec run first, then the actions of this spec in the order they were added, so an eachFile action added to this spec before the rename sees the name before renaming.

Return

this

Since

3.0

Parameters

renamer

rename function


abstract fun rename(sourceRegEx: String, replaceWith: String): CopyProcessingSpec(source)

Renames files based on a regular expression. Uses java.util.regex type of regular expressions. Note that the replace string should use the '$1' syntax to refer to capture groups in the source regular expression. Files that do not match the source regular expression will be copied with the original name.

Example:

rename '(.*)_OEM_BLUE_(.*)', '$1$2'
would map the file 'style_OEM_BLUE_.css' to 'style.css'

Files are renamed as they are about to be copied, together with the actions added with eachFile. The actions of a parent spec run first, then the actions of this spec in the order they were added, so an eachFile action added to this spec before the rename sees the name before renaming.

Return

this

Since

0.8

Parameters

sourceRegEx

Source regular expression

replaceWith

Replacement string (use $ syntax for capture groups)


abstract fun rename(sourceRegEx: Pattern, replaceWith: String): CopyProcessingSpec(source)

Renames files based on a regular expression. See rename.

Return

this

Since

0.9

Parameters

sourceRegEx

Source regular expression

replaceWith

Replacement string (use $ syntax for capture groups)