如何使用gradle将.properties文件添加到我的WAR中? [英] How do I add a .properties file into my WAR using gradle?
本文介绍了如何使用gradle将.properties文件添加到我的WAR中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
WAR
- META-INF
- WEB-INF
- 类
- META-INF
- myApp。属性< - 需要添加
如何使用gradle将.properties文件添加到我的WAR中?
该文件后来引入到项目中,但没有添加
?
build.gradle
import org.apache.commons.httpclient.HttpClient
import org.apache.commons.httpclient.methods.GetMethod
group ='gradle'
version ='1.0'
apply plugin:'war'
apply plugin:'jetty'
apply plugin:'eclipse'
eclipseProject
{
projectName ='crap'
}
defaultTasks'build'
依赖项
{
//所有依赖项
}
war
{
classpath fileTree('lib')
}
jar.enabled = true
[jettyRun,jettyRunWar] *。daemon = true
stopKey ='stoppit'
stopPort = 9451
httpPort = 8080
scanIntervalSeconds = 1
<$ p解决方案$('< path-to-props-file>'){
包括'myApp.properties'
$ b如果你想指定你想要的属性的目录文件位于:war {
from('< path-to-props-file>' ){
包含'myApp.properties'
到('< targetDir>)
}
}
WAR - META-INF - WEB-INF - classes - META-INF - myApp.properties <-- Needs added
How do I add a .properties file into my WAR using gradle? The file was later introduced into the project but doesn't get added?
build.gradle
import org.apache.commons.httpclient.HttpClient import org.apache.commons.httpclient.methods.GetMethod group = 'gradle' version = '1.0' apply plugin: 'war' apply plugin: 'jetty' apply plugin: 'eclipse' eclipseProject { projectName = 'crap' } defaultTasks 'build' dependencies { //all my dependencies } war { classpath fileTree('lib') } jar.enabled = true [jettyRun, jettyRunWar]*.daemon = true stopKey = 'stoppit' stopPort = 9451 httpPort = 8080 scanIntervalSeconds = 1
解决方案Something like this should work:
war { from('<path-to-props-file>') { include 'myApp.properties' } }
If you want to specify which directory you want the properties file to be located in:
war { from('<path-to-props-file>') { include 'myApp.properties' into('<targetDir>') } }
这篇关于如何使用gradle将.properties文件添加到我的WAR中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文