wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Reading a property file taking the key and searching key another property file replace the value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Reading a property file taking the key and searching key another property file replace the value " Watch "Reading a property file taking the key and searching key another property file replace the value " New topic
Author

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

yatheesha jagadeesha
Greenhorn

Joined: Jun 10, 2013
Posts: 1
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

Joined: May 14, 2008
Posts: 5838
    
    7

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

JBoss In Action
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reading a property file taking the key and searching key another property file replace the value