CopySpec rename usage

I have a jar task that includes a file as such:

jarTask.from project.l10nConvention.localizationOutputPath, { CopySpec copy ->

copy.include(“feature.xml”)

}

How would I make it rename my “feature.xml” file to “feature_en.xml” inside the produced jar? It seems CopySpec has rename functionality, but I’m not sure how to implement.

Hi Phil,

For future reference, if you wrap your code snippets in html code blocks…

e.g.

<code> jarTask.from project.l10nConvention.localizationOutputPath, { CopySpec copy ->

copy.include(“feature.xml”)

} </code>

You’ll get

jarTask.from project.l10nConvention.localizationOutputPath, { CopySpec copy ->
     copy.include("feature.xml")
 }

The answer is:

jarTask.from project.l10nConvention.localizationOutputPath, { CopySpec copy ->
    copy.include("feature.xml")
    rename { String fileName ->
        fileName.replace("feature_en.xml", 'feature.xml')
    }
}