Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a .properties file into my WAR using gradle?

Tags:

gradle

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 
like image 781
stackoverflow Avatar asked Jul 13 '11 17:07

stackoverflow


People also ask

Where does Gradle store WAR file?

Project layoutsrc/main/webapp. Web application sources.


2 Answers

war {     from('<path-to-props-file>') {         include 'myApp.properties'         into('<target-path>')     } } 
like image 141
Rene Groeschke Avatar answered Oct 25 '22 17:10

Rene Groeschke


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>')      } }  
like image 21
Benjamin Muschko Avatar answered Oct 25 '22 18:10

Benjamin Muschko