将自定义环境变量传递给 Maven 货物
我正在寻找一种将环境变量传递到货物容器中的方法。像这样的东西:
<plugin>
<groupId>org.codehaus.cargo>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<environmentVariables>
<myCustomVariable>value</myCustomVariable>
...
I'm looking for a way to pass environment variables into a cargo container. Something like this:
<plugin>
<groupId>org.codehaus.cargo>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<environmentVariables>
<myCustomVariable>value</myCustomVariable>
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK,货物只允许传递系统属性,如 传递系统属性 中提到的Maven Tips 如下例: -
解决方法可能是链接系统属性环境变量如下例: -
通常我们只能使用操作系统的方式设置环境变量。无论如何,还有一种使用 Java 设置它的解决方法,如 How我如何从 Java 设置环境变量?。
我总是使用此技巧在单元测试期间设置环境变量,方法是使用
@BeforeClass
将它们放入 JUnit 测试套件,并使用@AfterClass
将它们设置为空字符串。请注意,正式的 Java 教程还提到了环境变量和 将环境变量传递给 New流程。
我希望这会有所帮助。
AFAIK, The cargo only allow to pass the system properties as mentioning at Passing system properties and Maven Tips as the following example: -
The workaround may be link that system properties to the environment variable as the following example:-
Normally we are only able to set the environment variable by using the OS way. Anyhow there also is a workaround for setting it by using Java as mentioning at How do I set environment variables from Java?.
I always use this tip for setting up the environment variables during unit testing by putting them to the JUnit test suit with
@BeforeClass
and set them to be empty String with@AfterClass
.Please note that the formal Java Tutorial also mentions about Environment Variables and Passing Environment Variables to New Processes.
I hope this may help.