Rewrite files in jar during copy


(Alexey Plotnikov) #1

I want rewrite some files in jar archive during copy(using from), but DuplicatesStrategy not has appropriate property(EXCLUDE only leave first copied/created file). How i can do this?


(René Groeschke) #2

Well you could create that rewrite those files in a doFirst{} block of the jar task. But this is not considered to be a good design. Can you elaborate a bit more what changes you want to on those changes? Maybe you can apply a ReplaceToken Filter or expand method to modify the files on the fly when creating the jar.

For more details on how to use ants ReplaceToken Filter or the expand method have a look at the copy section in the Gradle userguide and look for the “Filtering files” example snippet. The chapter is available at http://www.gradle.org/docs/current/userguide/working_with_files.html#sec:copying_files

cheers, René


(Alexey Plotnikov) #3

I want build different war files. They are differs only by css and img files. So i want create task, that replaces css and all images :slight_smile: