This is a Windows issue since Windows cannot reference file paths
longer than 260 characters. If this works under JDK 1.5, it is because
JDK 1.5 is using a somewhat different way to handle file names (using
the NTFS library calls instead of the Windows library calls). I can
see a few ways of handling this:
1). Use a <condition> task to set a property depending upon the value
of ${java.version}. I don't think there's an 'atleast' condition, so
you'll have to make do with "contains". Once you manage to set this
condition, use a <fails> task if this condition isn't set.
2). Reconstruct your build to avoid extra long path names. This can be
done through the DOS Subst command which takes a path name and assigns
a drive letter to it, renaming paths, or using the short DOS name of
the path (which limits the each part of the path to just 8
characters).
3). you can look at the AntContrib tasks <for> and <foreach> and use
these to iterate over your path to see if it finds something longer
than 260 characters.
On Dec 15, 2007 11:15 AM, Davy Toch <[EMAIL PROTECTED]> wrote:
> 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\presentation\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\minfin\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$PreviousExerciseSeparatedImpl.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/impl/RequestEnrolementManuelTypeImpl$IdentificationImpl$PartnerImpl.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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
--
David Weintraub
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]