A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Ant, Maven and Other Build Tools
Reading a property file taking the key and searching key another property file replace the value
Joined: Jun 10, 2013
Jun 10, 2013 01:21:50
reading a property file taking the key and searching key another property file replace the value of key using
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
Joined: May 14, 2008
Jun 16, 2013 17:16:35
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:
<properties> <key1.value>someValueForKey1</key1.value> </properties> <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build>
I can supply a different default by providing a profile with this property in my settings.xml file:
<profiles> <profile> <id>my.settings</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <key1.value>myKey1Value</key1.value> </properties> </profile> </profiles>
On my PC the resulting properties file will have:
build slave the properties file will have:
I can even change the value dynamically on the command line:
mvn clean package -Dkey1.value=useThisInstead
JBoss In Action
subject: Reading a property file taking the key and searching key another property file replace the value
Any replacement for ResourceBundle
What is the java -D command-line option good for?
Read duplicate keys from properties file
Alternatives to java.util.Properties?
what is java's equivalent to c/c++ string table resource files
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014