路径中的 ant build.xml windows 空白

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/55386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:15:04  来源:igfitidea点击:

ant build.xml windows white space in path

windowsantwhitespacebuild.xml

提问by

I'm using Windows and I'm trying to get ANT to work.

我正在使用 Windows 并且我正在尝试让 ANT 工作。

When I do an ant build from the command line, I get: C:\dev\Projects\springapp\${%ANT_HOME%}\lib not found.

当我从命令行进行 ant 构建时,我得到: C:\dev\Projects\springapp\${%ANT_HOME%}\lib not found.

I look into the build.xmlfile and I find: appserver.home=${user.home}/apache-tomcat-6.0.14(which I just copied and pasted straight from a tutorial)

我查看了该build.xml文件,发现:(appserver.home=${user.home}/apache-tomcat-6.0.14我刚刚从教程中直接复制并粘贴了该文件 )

I changed it to:

我把它改成:

appserver.home="C:\Program Files\Apache Software Foundation\Tomcat 6.0"

appserver.home="C:\Program Files\Apache Software Foundation\Tomcat 6.0"

but now I get:

但现在我得到:

C:\dev\Projects\springapp\"C:Program FilesApache Software FoundationTomcat 6.0"\lib not found.

C:\dev\Projects\springapp\"C:Program FilesApache Software FoundationTomcat 6.0"\lib not found.

It seems like the white space in Program Files and Tomcat 6.0 are causing the build to fail. How do you deal with these in xml files without re-creating the directory with a path with no white space?

Program Files 和 Tomcat 6.0 中的空白似乎导致构建失败。你如何在 xml 文件中处理这些而不用没有空格的路径重新创建目录?

回答by Vinko Vrsalovic

Change it to

将其更改为

appserver.home="C:\Program Files\Apache Software Foundation\Tomcat 6.0"

回答by Eugene

Variant with "/" instead "\" works on my system. Just need to delete " symbols before and after path structure.

用“/”代替“\”的变体适用于我的系统。只需要删除路径结构前后的"符号。

回答by gliptak

Find the Windows short name for those directories using dir /xand use thme when setting pathvalues.

dir /x在设置path值时使用和使用 thme查找这些目录的 Windows 短名称。

Some more discussion at How does Windows determine/handle the DOS short name of any given file?

在一些更多的讨论如何确定的Windows /处理任何给定文件的DOS短名称?

回答by Rob Spieldenner

It looks like you have your properties setup incorrectly.

看起来您的属性设置不正确。

I'm guessing your basedir property is pointing at C:\dev\Projects\springapp and your properties are using value like:

我猜你的 basedir 属性指向 C:\dev\Projects\springapp 并且你的属性使用如下值:

<property name="property.1" value="directory" />

instead of

代替

<property name="property.1" location="directory" />

Using the location property then resolves links as relative to your basedir if the location is a relative path and to the absolute path if you enter one of those. If you could post parts of your Ant file specifically how you define appserver.home and how you use it in the task that's throwing the error I could be more specific.

如果位置是相对路径,则使用 location 属性将链接解析为相对于您的 basedir,如果您输入其中之一,则解析为绝对路径。如果您可以具体发布 Ant 文件的部分内容,具体说明您如何定义 appserver.home 以及如何在引发错误的任务中使用它,我可能会更具体。

回答by caseyboardman

In the top of your build.xml, try adding <property environment="env"/>and then using ${env.USER_HOME}(or whatever you have in your environment). That did it for me (${env.JAVA_HOME} rather than ${java.home}).

在 build.xml 的顶部,尝试添加 <property environment="env"/>然后使用${env.USER_HOME}(或您环境中的任何内容)。那是为我做的(${env.JAVA_HOME} 而不是${java.home})。

回答by Daemin

In addition to escaping the windows directory separator also make sure that all paths that you type in should be with correct capitalisation, Windows is not case sensitive but case presrving, while Ant is case sensitive.

除了转义 windows 目录分隔符之外,还要确保您输入的所有路径都应使用正确的大小写,Windows 不区分大小写,但区分大小写,而 Ant 区分大小写。