在Ant脚本环境变量不工作 [英] Environmental variables in ant script not working

查看:891
本文介绍了在Ant脚本环境变量不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个Spring框架的项目与机器无关的编译环境,我的蚂蚁的配置似乎不工作。我已经搜查了不少,但大家似乎认为ENV。*引用工作开箱。可能有人可能会找到我的方式错误?

I'm trying to set up a machine-independent build environment for a Spring framework project, and my ant configuration appears to be not working. I've searched quite a bit but everyone seems to think that env.* references work out of the box. Could someone perhaps find the error of my ways?

错误:

bash-3.1$ ant build
Buildfile: c:\Users\mkumpan\Projects\Spring testing\build.xml

BUILD FAILED
c:\Users\mkumpan\Projects\Spring testing\build.xml:85: c:\Users\mkumpan\Projects\Spring testing\${env.CATALINA_HOME}\lib does not exist.

的build.xml:85:

build.xml:85:

<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
    <classpath refid="catalina-ant-classpath"/>
</taskdef>

卡塔利娜-ANT-classpath中引用:

catalina-ant-classpath reference:

<path id="catalina-ant-classpath">
    <fileset dir="${appserver.lib}">
        <include name="catalina-ant.jar"/>
    </fileset>
</path>

$ {} appserver.lib build.properties中宣称:

${appserver.lib} declared in build.properties:

appserver.home=${env.CATALINA_HOME}
appserver.lib=${appserver.home}/lib

deploy.path=${appserver.home}/webapps

呼应ENVVAR作品:

Echoing the envvar works:

bash-3.1$ echo $CATALINA_HOME
C:\Program Files\Tomcat

两个大问题:


  • 凭啥它不能解析出ENVVAR?

  • 凭啥做它prePEND的绝对路径ENVVAR?

推荐答案

以下行添加到的build.xml 文件:

<property environment="env"/>

引用环境变量时,定义preFIX。从对环境物业参考页的属性:

to define the prefix when referencing environment variables. From the Property reference page for the environment attribute:

获取环境变量时preFIX使用。因此,如果您指定的环境=myenv,您将可以通过属性名访问特定操作系统的环境变量myenv.PATH或myenv.TERM。的注意,如果你提供一个属性名称以最终。它不会被加倍;即环境=myenv。将仍然允许通过myenv.PATH和myenv.TERM环境变量的访问。此功能目前仅在某些平台上实现。随时发送补丁以增加在其上支持这一功能的平台的数目)。
  另请注意,性能是区分大小写的,即使你的操作系统的环境变量都没有;例如Windows 2000中的系统路径变量设置为名为env.Path而不是env.PATH一个Ant属性。

the prefix to use when retrieving environment variables. Thus if you specify environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM". Note that if you supply a property name with a final "." it will not be doubled; i.e. environment="myenv." will still allow access of environment variables through "myenv.PATH" and "myenv.TERM". This functionality is currently only implemented on select platforms. Feel free to send patches to increase the number of platforms on which this functionality is supported ;). Note also that properties are case-sensitive, even if the environment variables on your operating system are not; e.g. Windows 2000's system path variable is set to an Ant property named "env.Path" rather than "env.PATH".

这篇关于在Ant脚本环境变量不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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