I am using maven as my build tool. Below is a snippet from my POM.
<properties>
<geb.version>2.2</geb.version>
<selenium.version>3.14.0</selenium.version>
<groovy.version>2.4.14</groovy.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spock.version>1.1-groovy-2.4</spock.version>
<surefire.plugin.version>2.20</surefire.plugin.version>
<surefire.plugin.parallel>methods</surefire.plugin.parallel>
<selenium.host>XXXXX</selenium.host>
</properties>
I am writing an linux executable and I want to access <selenium.host>
property in my bash script. How do I do this?
DEFAULT_ADDRESS=$(get address from POM here)
Please note that my script and POM file are in the same directory.
Cheers!
The best and reliable solution would be to use maven-help-plugin like this:
ADDRESS=$(mvn help:evaluate -Dexpression=selenium.host -q -DforceStdout)
If you don't have specified the version of maven-help-plugin in your pom file you should use the following:
ADDRESS=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=selenium.host -q -DforceStdout)
The result is that the given property is read from pom file and then the value is assigned to ADDRESS
You can do it like that:
DEFAULT_ADDRESS=`cat pom.xml | grep "selenium.host" | cut -d'>' -f2 | cut -d'<' -f1`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With