检查使用Maven的AntRun插件的环境变量 [英] Checking an environment variable using the Maven AntRun plugin

查看:343
本文介绍了检查使用Maven的AntRun插件的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查,看看是否MULE_HOME环境变量设置都没有成功的Maven的antrun-插件中。这是我到目前为止有:

I'm trying to check and see if the MULE_HOME environment variable is set within the maven-antrun-plugin without success. Here's what I have so far:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>mule-deploy</id>
                    <phase>install</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target>
                            <taskdef resource="net/sf/antcontrib/antcontrib.properties"
                                     classpath="${settings.localRepository}/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
                            <echo message="MULE_HOME is ${env.MULE_HOME}"/>
                            <if>
                                <isset property="env.MULE_HOME"/>
                                <then>
                                    <echo message="MULE_HOME is set"/>
                                </then>
                                <else>
                                    <echo message="MULE_HOME is not set"/>
                                </else>
                            </if>
                        </target>
                    </configuration>
                </execution>
            </executions>
</plugin>

输出是:

 [echo] MULE_HOME is /<my development path>/mule
 [echo] MULE_HOME is not set

我想什么来检查环境变量?

What am I missing to check an environment variable?

推荐答案

从系统属性的Java存储环境变量的不同; System.getenv()与System.getProperties()。我的猜测是,Maven是不映射环境变量到这是什么蚂蚁与使用isset期望的系统属性。尝试建立在你的POM属性:

Java stores environment variables differently from system properties; System.getenv() vs. System.getProperties(). My guess is that maven isn't mapping environment variables into system properties which is what Ant is expecting with isset. Try creating a property in your POM:

<properties>
    <mulehome>${env.MULE_HOME}</mulehome>
<properties>

然后用

<isset property="mulehome"/>

这篇关于检查使用Maven的AntRun插件的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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