ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: ANT 1.6.5 : problem <jar> task to include files with path lengths exceeding 260 characters.
Date Mon, 17 Dec 2007 06:22:19 GMT
I havent looked into the sources, so just my thoughts on that.
I think Ant is silently ignoring the long files because the JVM is not passing them to Ant.
And therefore Ant has not the opportunity to log something ...

Having said that it would be difficult to check for long paths ...
An idea would be comparing windows "dir" output (with "/S /B") with the filesets content.
Maybe you have to write a task/condition for that: (see later)

Java version is stored in as System property "java.version" and therefore it is available
as Ant property "java.version".


Jan



pseudo code for the condition
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<----
   CheckLongPaths extends Condition {
       FileSet fs;
       public void addFileSet(FileSet fs) ...
       public boolean eval() {
           fsFile  = writeFSToFile(fs);
           dirFile = writeDirToFile(fs.getBasedir());
           return compareFiles(fsFile, dirFile);
       }
       private File writeFSToFile(FileSet fs) {
          Pathconvert formatter = getProject().createTask("pathconvert");
          formatter.setProperty("_fs.value");
          formatter.addFileset(fs);
          formatter.execute();
          Echo outputHelper = getProject().createTask("echo");
          File outFile = FileUtils.getTempFile();
          outputHelper.setFile(outFile);
          outputHelper.setMessage(getProject().getProperty("_fs.value"));
          outputHelper.execute();
          return outFile;
       }
       private File writeDirToFile(File dir) {
          File outFile = FileUtils.getTempFile();
          Exec helper = getProject().createTask("exec");
          helper.setDir(dir);
          helper.setExecutable("cmd.exe");
          helper.addArg("dir /S/B");
          helper.setOutputfile(outFile);
          helper.execute();
          return outFile;
       }
       private boolean compareFiles(fsFile, dirFile) {
          // happy comparing ...
       }
   }
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<----



> -----Urspr√ľngliche Nachricht-----
> Von: Davy Toch [mailto:davy.toch@gmail.com] 
> Gesendet: Samstag, 15. Dezember 2007 17:16
> An: Ant Users List
> Betreff: ANT 1.6.5 : problem <jar> task to include files with 
> path lengths exceeding 260 characters.
> 
> Hi,
> 
> There is a known issue in the JDK 1.4 and older versions on Windows 
> platforms to read/write files with paths exceeding 260 
> characters. As a 
> consequence this causes a problem in the ANT <jar> task, e.g.:
> 
> $echo %JAVA_HOME%
> d:\devtools\j2sdk1.4.2_15
> 
> $cd
> D:\projects\spffin\IPP_EX2006-3_VIEW\XX_Implementation\modules
> \CalculationWebService
> 
> $dir
>  Volume in drive D is DATA
>  Volume Serial Number is 0046-7936
> 
>  Directory of 
> D:\projects\spffin\IPP_EX2006-3_VIEW\XX_Implementation\modules
> \CalculationWebService
> 
> 15/12/2007  16:46    <DIR>          .
> 15/12/2007  16:46    <DIR>          ..
> 15/12/2007  16:41               159 build.xml
>                1 File(s)            159 bytes
> 
> $dir 
> target\generated\main\classes\be\fgov\minfin\calculipp\present
ation\calculationwebservice\impl
>  Volume in drive D is DATA
>  Volume Serial Number is 0046-7936
> 
>  Directory of 
> D:\projects\spffin\IPP_EX2006-3_VIEW\XX_Implementation\modules
> \CalculationWebService\target\generated\main\classes\be\fgov\m
infin\calculipp\presentation\calculationwebservice\impl
> 
> 15/12/2007  16:46    <DIR>          .
> 15/12/2007  16:46    <DIR>          ..
> 15/12/2007  16:41             6,271 
> RequestEnrolementManuelTypeImpl$IdentificationImpl$PartnerImpl.class
> 15/12/2007  16:41             4,782 
> RequestEnrolementManuelTypeImpl$IdentificationImpl$PreviousExe
rciseSeparatedImpl.class
>                2 File(s)         11,053 bytes
>                2 Dir(s)  35,246,559,232 bytes free
> 
> The total path of the second file in the previous listing exceeds 260 
> positions.
> 
> The ANT buildfile build.xml contains :
> 
>     <project default="test" basedir=".">
>           <target name="test">
>                 <jar destfile="test.jar" 
> basedir="target/generated/main/classes"/>
>           </target>
>     </project>
> 
> Now if I execute this target I get:
> 
> Apache Ant version 1.6.5 compiled on June 2 2005
> Buildfile: build.xml
> Detected Java version: 1.4 in: d:\devtools\j2sdk1.4.2_15\jre
> Detected OS: Windows XP
> parsing buildfile 
> D:\projects\spffin\IPP_EX2006-3_VIEW\XX_Implementation\modules
> \CalculationWebService\build.xml 
> with URI = 
> file:///D:/projects/spffin/IPP_EX2006-3_VIEW/XX_Implementation
/modules/CalculationWebService/build.xml
> Project base dir set to: 
> D:\projects\spffin\IPP_EX2006-3_VIEW\XX_Implementation\modules
> \CalculationWebService
> Build sequence for target(s) `test' is [test]
> Complete build sequence is [test, ]
> 
> test:
>       [jar] Building jar: 
> D:\projects\spffin\IPP_EX2006-3_VIEW\XX_Implementation\modules
> \CalculationWebService\test.jar
>       [jar] adding directory META-INF/
>       [jar] adding entry META-INF/MANIFEST.MF
>       [jar] adding directory be/
>       [jar] adding directory be/fgov/
>       [jar] adding directory be/fgov/minfin/
>       [jar] adding directory be/fgov/minfin/calculipp/
>       [jar] adding directory be/fgov/minfin/calculipp/presentation/
>       [jar] adding directory 
> be/fgov/minfin/calculipp/presentation/calculationwebservice/
>       [jar] adding directory 
> be/fgov/minfin/calculipp/presentation/calculationwebservice/impl/
>       [jar] adding entry 
> be/fgov/minfin/calculipp/presentation/calculationwebservice/im
> pl/RequestEnrolementManuelTypeImpl$IdentificationImpl$PartnerI
mpl.class
> 
> BUILD SUCCESSFUL
> Total time: 0 seconds
> 
> 
> 
> So the second .class file isn't included! If I were to redo the 
> procedure with JAVA_HOME set to point to a JDK 1.5, it would work, so 
> the problem is clearly caused by the used JDK.
> 
> QUESTION
> 
> Is there a way in ANT to make the target execution fail if long files 
> are detected or when the JDK version is <= 1.4? I know the 
> actual bug is 
> in the JDK, not in ANT, but now ANT silently ignores the problem and 
> continues. E.g. is there a way in the ANT script build.xml to 
> define a 
> prerequirement for the JDK version on which ANT will run?
> 
> Best regards,
> Davy Toch
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message