ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: Possible Bug? Ant task <jar> does not handle files with over 255 chars in the path name
Date Fri, 23 May 2008 14:47:00 GMT
Adrian Muscalu wrote:
> Hello,
> I am running an ANT script on my Win XP machine; one of the tasks attempts to create
a jar file where the class files are in a directory with a long name. The combined path, package
name and file name exceedes 255 characters.
> Expected result:
> The script should fail as the files exceed the Windows XP file system limitation.
> Actual result:
> The build finishes with a successfull state although the files that have the long name
in the soturce directory have not been included into the jar.
> I was hoping for ANT to report on the problem and stop the build; Ant managed to create
the long named files just fine, but any subsequent operation on them (copy, jar) fails without
notification. Any attempt to work with the files on the Windows DOS prompt (copy command)
ends with a pertinent message saying that the file name is too long and the operation fails.

> Is this a bug? I don't expect ANT to fix the XP limitation, just to report on it somehow.

This is interesting. The first thing to consider is what is MAX_PATH, 
the limit on file length. Because the answer isnt 255, or even 260, its 
32768 -but only under the unicode API, and you have to use funny \\?\ 
filename prefixes

  Assuming the Sun JVM uses this API to talk to the OS -and it is an 
assumption- then Ant should be able to work with long filenames. But if 
some of the API doesnt, we're in trouble.

Looking at the state of things, not all of java is consistent, even on java6

But, some of the API does work with long files, as you've noticed.

1. I dont think its an ant bug so much as a JVM issue. We just open and 
close files, and take whatever API we're given.
2. That doesnt mean it isnt inconvenient

The fix is for the Java API to go to full length filenames everywhere, 
even if it gives you the right to create filenames that old apps cant 

Steve Loughran        
Author: Ant in Action 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message