I have a maven profile and want to set a property which is later on available per System.getProperty(..) in java:
<profile>
<id>local-dev</id>
<properties>
<my.comp.my.prop>myValue</my.comp.my.prop>
</properties>
</profile>
I want System.getProperty("my.comp.my.prop")
to be "myValue"
but it's null
..
How do I set it correctly? :)
Thansk!
To provide System Properties to the tests from command line, you just need to configure maven surefire plugin and use -D{systemproperty}={propertyvalue} parameter in commandline. Run Single Test with Maven : $ mvn test -Dtest=MessageUtilTest#msg_add_test -Dmy_message="Hello, Developer!"
systemPropertyVariables. Maven Surefire plugin provides the configuration parameter systemPropertyVariables to set system properties. The properties defined here will be available in the unit tests.
In your Eclipse environment, select the java project, right-click, and select Properties. Click Run/Debug Settings. Select New... > Java Application, and click the Environment tab.
properties-maven-plugin plugin will help you to do exactly what you're looking for:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<properties>
<property>
<name>my.property.name</name>
<value>my.property.value</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
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