有时候发布war需要指定和开发环境不同的文件,这时候需要自己定义war包文件接口,但是gradle自带的war插件打包不够灵活,可以使用jar任务来自定义。
在本实例中我使用release/resources/log4j.properties 文件来替换 main/resources/log4j.properties 文件
改写自己的build.gralde 使用 gradlew.bat releaseWar 命令来生产自定义
group 'com.bestcover.demo'
version '1.0.1.180111'
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = 1.8
compileJava{
options.compilerArgs += ['-Xlint:unchecked']
options.encoding = "UTF-8"
}
compileGroovy{
options.compilerArgs += ['-Xlint:unchecked']
options.encoding = "UTF-8"
}
compileTestGroovy{
options.compilerArgs += ['-Xlint:unchecked']
options.encoding = "UTF-8"
}
compileTestJava{
options.compilerArgs += ['-Xlint:unchecked']
options.encoding = "UT