Gradle war task corrupts all images!

I noticed today that gradle corrupts all images in the project when running “gradle war” task. My system is: ------------------------------------------------------------ Gradle 1.10 ------------------------------------------------------------

Build time:

2013-12-17 09:28:15 UTC Build number: none Revision:



1.8.6 Ant:

Apache Ant™ version 1.9.2 compiled on July 8 2013 Ivy:

2.2.0 JVM:

1.7.0_45 (Oracle Corporation 24.45-b08) OS:

Mac OS X 10.9.1 x86_64

All the files in src/main/webapp are ok. When I run ‘gradle war’ I get the appropriate war file in build/libs directory. When I unzip that file and inspect images all of them have weird sizes (image that should have 84KB in the war file it has ~150KB, and cannot be opened in any editor).

What’s the configuration of your war task?

This is my war task configuration

war {

filter(ReplaceTokens, tokens:[‘oauth.clientId’: oauthClientId,

‘oauth.secret’: oauthSecret,

‘oauth.grantType’: grantType,

‘oauth.responseType’: responseType,

‘oauth.scope’: scope,

‘oauth.redirectUri’: redirectUri,

‘cookieDomain’: cookieDomain,

‘allowedOrigin’: allowedOrigin ]) }

That filter is what’s doing it. You need to scope it to the files you want.


war {
  filesMatching("**/*.properties") {
    filter(ReplaceTokens, …)

Obviously using whatever pattern matches the files you need to filter.

1 Like

I just tried using:

war {
    filesMatching( '**/*.xml' ) {
        filter(ReplaceTokens, tokens:['redirectUrl': redirectUrl ])

And the result is the same… all my images are still corrupted…

I managed to work around this issue. If I use specific enough filter in filesMathing (i.e. src/main/webapp/WEB-INF/*.xml than I don’t see the issue. With the filer specified in my previous post I still see the issue.

Sorry to revive this, but I’m trying to do something along those line and failing. I have a SO for it.