Gradle replace resource file with WAR plugin -


i'm trying replace resource file in war plugin task gradle.

basically have 2 resource files:

database.properties database.properties.production 

what want achieve replace 'database.properties' 'database.properties.production' in final war file under web-inf/classes.

i tried lot of things logical me following not work:

    war {         webinf {             ('src/main/resources') {                 exclude 'database.properties'                 rename('database.properties.production', 'database.properties')                 'classes'             }         }     } 

but causes other resource files duplicate, including duplicate database.properties (two different files same name) , still database.properties.production in war.

i need clean solution without duplicates , without database.properties.production in war.

if can't make decision @ runtime (which recommended best practice dealing environment-specific configuration), eachfile may best bet:

war {     rootspec.eachfile { details ->          if (details.name == "database.properties") {             details.exclude()         } else if (details.name == "database.properties.production") {             details.name = "database.properties"         }     } } 

ps: gradle 1.7 adds filesmatching(pattern) { ... }, may perform better eachfile.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -