Hi,
I've already posted this but no one reacted. So I repost it because
I'd like to know your opinion on this.
I have problem with specifying <srcfiles> to <uptodate> element when
I don't know base directory, only file to check. For example I have
property srcfile and use this:
<uptodate property="isUptodate" targetfile="${targetfile}">
<srcfiles dir="???" includes="${srcfile}"/>
</uptodate>
I don't know how to create dir value if I know only srcfile - which may
be relative or absolute. I tried "." and "/" but "." can't work if file
is in upper directory and "/" can't work if file is relative to ".".
Because I haven't found how to do this, I created a simple patch to
org.apache.tools.ant.types.FileSet. Now it can be written as
<srcfiles file="${srcfile}"/>
Patch is very simle, it just splits filename into directory and filename
parts and calls setDir and setIncludes. It was using Ant 1.2 sources.
(May be I missed something and it can be done in different way (without
this patch))
Martin
--- FileSet.java.orig Tue Oct 24 14:50:52 2000
+++ FileSet.java Tue Nov 28 17:53:51 2000
@@ -122,7 +122,24 @@
}
return dir;
}
-
+
+ public void setFile(File file) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+
+ if (!file.exists()) {
+ setDir(new File("."));
+ setExcludes("*");
+ } else {
+ if (file.isDirectory()) {
+ throw new BuildException(file.getAbsolutePath()+" is not a
file.");
+ }
+ setDir(file.getAbsoluteFile().getParentFile());
+ setIncludes(file.getName());
+ }
+ }
+
public PatternSet createPatternSet() {
if (isReference()) {
throw noChildrenAllowed();