Maven 2.1.0不会将系统属性传递给Java虚拟机 [英] Maven 2.1.0 not passing on system properties to Java virtual machine

查看:79
本文介绍了Maven 2.1.0不会将系统属性传递给Java虚拟机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用命令行将系统属性传递给Java 运行我们的 Hudson 的虚拟机,它是在Linux机器上构建的.它用了 自从我们升级到2.1.0以来,它在2.0.9中工作得很好 完全停止工作.系统属性永远无法实现 Java虚拟机.

We use the command line to pass on system properties to the Java virtual machine when running our Hudson builds on a Linux box. It used to work quite well in 2.0.9 by since we upgraded to 2.1.0 it has stopped working altogether. The system properties just never make it to the Java virtual machine.

我已经创建了一个小型测试项目,实际上它根本无法正常工作.

I have created a small test project and indeed it does not work at all.

使用 Maven 2.0.9:

mvn2.0.9 -Dsystem.test.property=test test 

但这将失败:

mvn2.1 -Dsystem.test.property=test test 

Java代码简单地做到了

The Java code simply does this

assertTrue( System.getProperty("system.test.property") != null); 

推荐答案

我认为这在Maven或Surefire插件中都不是问题.否则,surefire的行为就会有所不同.现在看来,当Surefire分叉 JVM 时,将不会从父级获取所有系统属性. JVM.

I don't think this is a problem in either Maven or Surefire plug-in. Else the surefire is behaving differently. It looks like now, when Surefire forks the JVM, will not take all the system properties from the parent JVM.

这就是为什么您应该使用argLine传递测试所需的任何系统属性的原因. 因此,这两个都应该有效

That's why you should pass whatever system properties you want for the tests, using argLine. So, both these should work

mvn2.1 -Dsystem.test.property=test test -DforkMode=never 

mvn2.1 test -DargLine="-Dsystem.test.property=test"

这篇关于Maven 2.1.0不会将系统属性传递给Java虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆