Welcome! Please see the About page for a little more info on how this works.

+1 vote
in tools.build by

Without a :replace parameter, b/copy-dir faithfully copies over any binary (and text) files in from the source directories.

However, if a :replace parameter is provided, then it corrupts any binary files when copying. It does the replacement properly for any text files in the directories.

Repro:

1 Answer

+2 votes
by
selected by
 
Best answer

It's not possible to know whether files are encoded character streams or not, so :replace implicitly assumes that you are copying text files. One existing solution is to use :include to specify only files of a certain type, ie "**.clj".

The Maven resource filter plugin has a binary filtering exclusion on file extension, that might also be a way we could go.

by
Makes sense. An :exclude complement to :include would be helpful in the future.
by
edited by
The :include option is about what files should be copied. In this case, you do (I presume) want the file copied, you just don't want it filtered, so this is a secondary level. I've added an option :non-replaced-exts in v0.6.1 for this that defaults to include a few common image types found in resources, including .png.
...