如何让 Apache 中的 Ant 在每次构建时复制文件

发布于 2024-09-12 05:13:37 字数 718 浏览 3 评论 0原文

我在我的开发环境中使用 Eclipse 和 Ant。

我遇到了一个问题

,这是我的 build.xml 的一部分

<target name="deploy" depends="dist" description="deploy jar files">
    <!-- Deploy jar files on local Tomcat -->
    <echo>Deploying in ${tomcat_home}/webapps</echo>

  <echo>Copying JSP files from ${build_dir} to ${tomcat_home}/${ant.project.name}/$</echo>
  <copy todir="${tomcat_home}/webapps/">
   <fileset dir="${resources_dir}/" includes="**/*.jsp"/>
  </copy> 

,我更改了一个文件,然后运行 ​​ant 构建 - 所有文件和 jar 都被复制到我的服务器上的正确位置。

但我遇到的问题是,如果我快速进行另一个更改然后再次运行 Ant,我的文件不会被复制。显然 Any 正在查看时间戳以查看我上次更新文件的时间。如果它匹配同一分钟,则不会更新。

如何强制每次都复制文件?

谢谢

I'm using Eclipse and Ant in my development environment.

I've come across a problem

Here's part of my build.xml

<target name="deploy" depends="dist" description="deploy jar files">
    <!-- Deploy jar files on local Tomcat -->
    <echo>Deploying in ${tomcat_home}/webapps</echo>

  <echo>Copying JSP files from ${build_dir} to ${tomcat_home}/${ant.project.name}/
lt;/echo>
  <copy todir="${tomcat_home}/webapps/">
   <fileset dir="${resources_dir}/" includes="**/*.jsp"/>
  </copy> 

I change a file, then run an ant build - all the files and jars are copied to the right place on my server.

But the problem I have is, if I make another change quickly and then run Ant again, my files aren't copied. Obviously Any is looking at the timestamp to see when I last updated the file. If it matches the same minute, it doesn't update.

How can I force the file copying every time?

Thanks

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

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

发布评论

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

评论(1

别在捏我脸啦 2024-09-19 05:13:37

您可以使用 overwrite="true" 强制 Ant 始终覆盖文件。但是查看手册,我还发现了关于粒度属性:

在确定文件过期之前留出的毫秒数。这是必需的,因为并非每个文件系统都支持跟踪上次修改时间到毫秒级别。默认值为 1 秒,在 DOS 系统上为 2 秒。如果源文件和目标文件位于时钟不同步的不同计算机上,这也很有用。 自 Ant 1.6.2 起。

您可以尝试对此进行试验,看看是否有帮助。

You can use overwrite="true" to force Ant to always overwrite files. But looking at the manual, I also found this interesting tidbit regarding the granularity attribute:

The number of milliseconds leeway to give before deciding a file is out of date. This is needed because not every file system supports tracking the last modified time to the millisecond level. Default is 1 second, or 2 seconds on DOS systems. This can also be useful if source and target files live on separate machines with clocks being out of sync. since Ant 1.6.2.

You could try experimenting with this to see if it helps.

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