将环境变量传递给ant任务,没有ANT_OPTS [英] Passing environment variable to ant task, without ANT_OPTS
问题描述
org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING
环境变量。我可以将ANT_OPTS设置为 -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING = false
,它的工作正常。但是,我想要一个可以放入build.xml的设置,所以我不需要告诉我的队友他们需要设置ANT_OPTS。 我尝试过
< property name =env .org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING
value =false/>
但似乎不起作用。
如何将环境变量传递给蚂蚁任务?
编辑:不工作,我的意思是我得到一个错误, code>被引用在值
中使用时必须转义。如果我通过ANT_OPTS设置,我不会收到此错误。
使用< property>
任务定义环境前缀:
< property environment =env/>
现在,您可以简单地将 env。
添加到您的环境变量中,并将其视为已定义的Ant属性:
< property environment =env/>
< echo message =我的路径是&$ {env.PATH }& quot;/>
I'm calling the Jasper ant task, and I want to set the org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING
environment variable. I can set ANT_OPTS to be -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false
and it works correctly. However, I want a setting I can put into the build.xml, so I don't need to tell my teammates that they need to set ANT_OPTS.
I've tried
<property name="env.org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING"
value="false"/>
but that doesn't seem to work.
How can I pass an environment variable to an ant task?
EDIT: By "doesn't work", I mean I get an error saying an attribute is quoted with " which must be escaped when used within the value
If I set it via ANT_OPTS, I do not get this error.
Use the <property>
task to define an environmental prefix:
<property environment="env"/>
Now, you can simply prepend env.
to your environment variable and treat it like an already defined Ant property:
<property environment="env"/>
<echo message="My path is "${env.PATH}""/>
这篇关于将环境变量传递给ant任务,没有ANT_OPTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!