开发者

System property for maven plugin nested process

开发者 https://www.devze.com 2023-02-26 05:03 出处:网络
i wanted to setup hudson job to perform release of our project from hudson. But i have a problem: our bui开发者_如何学Gold process is running tests that need connection to db, host:port of db is speci

i wanted to setup hudson job to perform release of our project from hudson. But i have a problem: our bui开发者_如何学Gold process is running tests that need connection to db, host:port of db is specified as system parameter. But when i try to to such system parameter to release:prepare it seems that is creates a nested process and doesn't pass any system parameters to it. How can i pass system parameter to nested process?

Can i do it with maven profiles?

Thx for any comments!


pom.xml can't can read system properties, see Environment variable properties. But you shouldn't write a pom tied to variables only present on a particular computer. Example: JAVA_HOME works everywhere, mydatabase.username doesn't.

The right way is to write the configuration on a properties file and read it from the pom. This way you have a documented configuration instead who-knows-what system variables. It's also less complicated than keeping a shell script with the -D parameters.


The -D properties will not be reliable propagated from the surefire-pluging to your test (I do not know why it works with eclipse). When using maven on the command line use the argLine property to wrap your property. This will pass them to your test

mvn -DargLine="-D<property>=<value>" <goal>

Use System.getProperty to read the value in your code. Have a look to this post about the difference of System.getenv and Sytem.getProperty.

(This is taken from a former answer of me.)

0

精彩评论

暂无评论...
验证码 换一张
取 消