Gradle-War任务:如何将特定路径中的特定文件包含到.War文件中

Gradle-War任务:如何将特定路径中的特定文件包含到.War文件中,gradle,Gradle,我正在从事一个多模块项目 以下是强制性的 apply plugin: 'war' project(':thymeleaf-02-web') { description 'Web (HTML, JS, CSS)' dependencies { exportedProjects.each{ if("$it"!=":thymeleaf-02-web") compile project("$it")

我正在从事一个多模块项目

以下是强制性的

apply plugin: 'war'

project(':thymeleaf-02-web') {

    description 'Web (HTML, JS, CSS)'

    dependencies {

        exportedProjects.each{
            if("$it"!=":thymeleaf-02-web")
                compile project("$it")
        }

    }

    webAppDirName = 'src/main/resources'

    war {
        version=''
        baseName = warBaseName
    }

}
使用
src/main/resources
webAppDirName
的值是完全强制的,它不是使用
WEB-INF
位置的预期值,因为我正在使用
Thymeleaf
,否则许多
@Test
方法失败,它是关于测试
@控制器的
关于
弹簧的

现在我有了一个强制案例,我需要web应用程序的
web.xml
文件来配置
。它像往常一样位于
src/main/webapp/WEB-INF/
位置,但是当我创建
.war
文件并部署它时,
WEB.xml
从未被考虑,因此没有被包括在内

我尝试了以下添加内容:

dependencies {

    compile fileTree(dir: "src/main/webapp/WEB-INF/", include: 'web.xml')
    runtime fileTree(dir: "src/main/webapp/WEB-INF/", include: 'web.xml')


    exportedProjects.each{
        if("$it"!=":thymeleaf-02-web")
            compile project("$it")
    }

}
但什么都没有。目前,我必须手动将
web.xml
文件复制/粘贴到已部署的
.war
文件中

因此,正确的配置是什么?

尝试在
war
块中使用
from()
调用:

war {
    from('src/main/webapp/WEB-INF/web.xml') {
        into('WEB-INF')
    }
}
尝试在
war
块中使用
from()
调用:

war {
    from('src/main/webapp/WEB-INF/web.xml') {
        into('WEB-INF')
    }
}