java – 将自定义环境变量传递给maven货物
发布时间:2020-05-28 13:51:41 所属栏目:Java 来源:互联网
导读:我正在寻找一种将环境变量传递到货物集装箱的方法.像这样的东西: plugin groupIdorg.codehaus.cargo artifactIdcargo-maven2-plugin/artifactId configuration environmentVariables myCustomVariablevalue/myCus
|
我正在寻找一种将环境变量传递到货物集装箱的方法.像这样的东西: <plugin>
<groupId>org.codehaus.cargo>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<environmentVariables>
<myCustomVariable>value</myCustomVariable>
...
解决方法AFAIK,货物只允许通过 Passing system properties和 Maven Tips提及的系统属性,如下例所示: –<container>
[...]
<systemProperties>
<myproperty>myvalue</myproperty>
</systemProperties>
</container>
解决方法可能是将系统属性链接到环境变量,如下例所示: – <container>
[...]
<systemProperties>
<myproperty>${env.MY_ENV_VAR}</myproperty>
</systemProperties>
</container>
通常我们只能使用OS方式设置环境变量.无论如何还有一个解决方法,通过使用Java来设置它,如How do I set environment variables from Java?所述. 我总是使用这个技巧在单元测试期间设置环境变量,方法是将它们放到带有@BeforeClass的JUnit测试套件中,并使用@AfterClass将它们设置为空字符串. 请注意,正式的Java Tutorial还提到了Environment Variables和Passing Environment Variables to New Processes. 我希望这可能有所帮助. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读
