gradle - How do I copy a file into my WAR based on profile? -


i’m using gradle 2.7 on mac yosemite. have following files:

src/main/environment/dev/context.xml src/main/environment/qa/context.xml src/main/environment/prod/context.xml 

what if run build gradle -pqa build, appropriate context.xml file above copied war (into web-inf/classes directory fine). how set gradle?

there're many ways of solving problem. can configure sourcesets, or include or exclude particular resources when building war file. can have single context.xml , perform resource filtering replacetokens filter.

i've chosen sourcesets:

apply plugin: 'war'  ext.env = project.hasproperty('env') ? project.env : 'dev'  sourcesets {    main {       resources {          srcdir "src/main/environment/$env"       }    } } 

the trick include/process env being passed. if no env passed dev picked further processing. have demo.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -