English 中文(简体)
Copying only non-existent files in ant
原标题:

I m deploying my project to a web-server to be deployed with java Web Start. However, Web Start uses modification date to figure out whether to download the resources again (by default).

What I want is a way to only deploy those (jar) files that do not already exist. This is made possible by having build-version numbers on all my jars, so 2 jars with the same name have the same contents.

Notes:

  • The jar modification dates will always be newer in the build (which is why I m getting this problem), due to downloading from svn or ivy
  • There s a way to do this using sun s download servlet, more files etc, but I m lazy, don t need it, and this (simpler) solution will be more robust in the long term
问题回答

If you are using ants copy task (you don t explicitly say you are), you could try the present selector: http://ant.apache.org/manual/Types/selectors.html#presentselect.

<copy todir="target">
  <fileset dir="src">
    <present targetdir="target" present="srconly" />
  </fileset>
</copy>

You could attempt to set the granularity attribute very, very high, to basically disable the "copy files with the same name if the source file is newer than the destination" feature.

We had a similar problem, and I wound up implementing my own jar task to do what I needed. The Ant source code is a good place to start; if you re lucky you might be able to just subclass Ant s jar task. It s not nearly as difficult as it might sound, and was much more straightforward than the half dozen workarounds I tried or considered.

We solved this issue with maven and JavaFX and WebStart Plugin that keeps maven layout and version in the JNLP, and using "non-unique" SNAPSHOT will keep the same jar (ignoring the timestamp).

I know it s maven so not good for you, but someone may give it a try?





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签