在 Maven antrun 插件中检查环境变量是否存在的更好方法是什么?
What is a better way for checking for the existence of an environment variable in the Maven antrun plugin?
我正在使用 Maven 3.2.3。我有这个用于我的 ant 运行 插件…
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>create-dodeploy-file</id>
<phase>package</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<property environment="env"/>
<if>
<isset property="env.JBOSS_HOME"/>
<then>
<echo file="${JBOSS_HOME}/standalone/deployments/${project.artifactId}.war.dodeploy" append="false" message="" />
</then>
</if>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
尽管我知道 $JBOSS_HOME 是在我的环境中定义的(我能够 运行
echo $JBOSS_HOME
来自我 运行 我的 Maven 构建的同一个 bash shell),“isset” 指令总是 returns 错误。有没有更好的方法来测试 Ant运行 插件中是否存在环境变量?
如果(或除非)设置了 属性,目标也有能力执行它。要使目标有意义 属性,您应该添加 if(或除非)属性,其中包含目标应响应的 属性 的名称。
<target name="build-if" if="env.JBOSS_HOME"/>
<target name="build-unless" unless="env.JBOSS_HOME"/>
我正在使用 Maven 3.2.3。我有这个用于我的 ant 运行 插件…
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>create-dodeploy-file</id>
<phase>package</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<property environment="env"/>
<if>
<isset property="env.JBOSS_HOME"/>
<then>
<echo file="${JBOSS_HOME}/standalone/deployments/${project.artifactId}.war.dodeploy" append="false" message="" />
</then>
</if>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
尽管我知道 $JBOSS_HOME 是在我的环境中定义的(我能够 运行
echo $JBOSS_HOME
来自我 运行 我的 Maven 构建的同一个 bash shell),“isset” 指令总是 returns 错误。有没有更好的方法来测试 Ant运行 插件中是否存在环境变量?
如果(或除非)设置了 属性,目标也有能力执行它。要使目标有意义 属性,您应该添加 if(或除非)属性,其中包含目标应响应的 属性 的名称。
<target name="build-if" if="env.JBOSS_HOME"/>
<target name="build-unless" unless="env.JBOSS_HOME"/>