I have created an automation framework where I am reading values from a property file say "config.properties".
My config.propertioes file contains following :
BrowserName=${browser}
Environment=${env}
I am reading browser value from the property file and passing it to my selenium script to run it.
Now I wants to replace "${browser}"
&& "${env}"
with value "ie
" && "IT"
using pom.xml. Is there any way/plugin using which I can edit a property file using pom.xml.
Please suggest.
@Keshava I am putting whole example below as suggested below : 1.Have 2 property files: ◦project.properties: This is the file that we commit in the repository. It consists data as follows: ◾project.connection.username=@@DB_USERNAME@@ project.connection.password=@@DB_PASSWORD@@
◦build.properties: This is the file that we do not commit in the repository and is maintained at each of the deployment environments, be it the developers env., UAT env or Production env. The contents of this file are as follows: ◾db.username=mydbuser db.password=mydbpassword
2.In the project’s pom.xml add the following plugin and a execution:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.5</version>
<executions>
<execution>
<id>replaceTokens</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/classes/project.properties</file>
<replacements>
<replacement>
<token>@@DB_USERNAME@@</token>
<value>${db.username}</value>
</replacement>
<replacement>
<token>@@DB_PASSWORD@@</token>
<value>${db.password}</value>
</replacement>
</replacements>
</configuration>
</plugin>
from above, I understand that "@@DB_USERNAME@@"
is from "project.properties"
. But, from which properties file this "${db.username}"
value will be taken?. how my pom will understand from where to take "${db.username}"
.
Do I need to pass this value in maven goal like below :
mvn clean install -Ddb.username=myuserid