• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading a property file taking the key and searching key another property file replace the value

 
yatheesha jagadeesha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reading a property file taking the key and searching key another property file replace the value of key using maven

propertyfile1.properties

key1=someValueforkey1

propertyfile2.properties

key1=defaultvalue

while building it should replace the key1 value defaultvalue in propertyfile2.properties should be replaced with someValueforkey1 of propertyfile1.properties.

..Can any one help me out to solve this
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read up on how Maven handles properties, how you can use profiles, and how the Resources Plugin does property replacement.

My standard practice is to use property references in the properties file (or XML file), such as:



Then in the POM I provide a default value for the property (the default value I use is always hte value used in production), and I tell the Resources Plugin to filter resources:



I can supply a different default by providing a profile with this property in my settings.xml file:



On my PC the resulting properties file will have:

key1=myKey1Value

On the Jenkins build slave the properties file will have:

key1=someValueForKey1

I can even change the value dynamically on the command line:

mvn clean package -Dkey1.value=useThisInstead
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic