ant build.xml windows路径中的空白

发布于 2024-07-05 04:24:34 字数 604 浏览 6 评论 0原文

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

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

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

我将其更改为:

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

但现在我得到:

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

看来 Program Files 和 Tomcat 6.0 中的空格导致构建失败。 如何在 xml 文件中处理这些内容,而不用不带空格的路径重新创建目录?

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

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

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

I changed it to:

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

呆橘 2024-07-12 04:24:35

您的属性设置似乎不正确。

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

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

而不是

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

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

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:

<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.

抱着落日 2024-07-12 04:24:35

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

更多讨论请参见如何Windows 确定/处理任何给定文件的 DOS 短名称?

Find the Windows short name for those directories using dir /x and use thme when setting path values.

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

零度° 2024-07-12 04:24:35

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

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

神也荒唐 2024-07-12 04:24:35

在 build.xml 的顶部,尝试添加
<属性环境=“env”/>
然后使用 ${env.USER_HOME} (或您环境中的任何内容)。 这对我来说是这样的(${env.JAVA_HOME} 而不是 ${java.home})。

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}).

守不住的情 2024-07-12 04:24:35

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

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.

红颜悴 2024-07-12 04:24:34

将其更改为

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

Change it to

appserver.home="C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文