gradle - Gradle - War task: how include into the .war file a specific file from a specific path
问题描述
I am working with a multi module project.
The following is mandatory
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
}
}
The value for webAppDirName
with src/main/resources
is totally mandatory, it is not the expected working about with the WEB-INF
location, because I am working with Thymeleaf
, otherwise many @Test
methods fail, it about Testing @Controller
about Spring
.
Now I have the mandatory case that I need for the web app the web.xml
file to configure the <error-page>
. It is located as usual within the src/main/webapp/WEB-INF/
location, but when I create the .war
file and it is deployed the web.xml
never was taken in consideration and thus is not included.
I have tried the following addition:
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")
}
}
But nothing. For the moment I must copy/paste manually the web.xml
file into the deployed .war
file.
Thus what is the correct configuration?
解决方案
尝试在你的块中使用from()
调用:war
war {
from('src/main/webapp/WEB-INF/web.xml') {
into('WEB-INF')
}
}
推荐阅读
- php - 由于密码字段而导致注册失败错误?
- string - 打字稿类型'字符串| string[]' 不能分配给类型'string',什么是'string | 字符串[]' 类型?如何将它们转换为字符串?
- apache - 为什么我的 mod_proxy 标志在 htaccess 中停止工作?
- c# - 如何为引用的 nuget 包指定输出文件夹?
- javascript - 如何在背景图像中启用视频或照片?
- reactjs - 如何修复编辑记录中的 redux 表单验证错误
- c - 如果块的大小不是 4 的倍数,为什么 efence 无法检测到越界
- bash - 使用管道执行命令并将 stdout 和 stderr 重定向到变量的 Shell 脚本函数
- swift - 从 iOS 创建与仪表板链接显示相同值的分支链接
- aws-sam - AWS SAM 模板中的 Auth 部分出错