Posts Tagged ‘ant exception message’

some ant pitfalls.

August 22nd, 2009

Hi.

Even though weird, at least for me to use, there is a small character in java that needs to be used in it’s constant form and not explicitly and that’s the file separator char, why ? platform compatibility.

About two month ago i had a small project, making our new moblin code that was ported in an outsource company compile using our build process and integrate it into our CVS, So I’ll leave the Boring details out, but i will mention that the hardest past was to adapt the in company Ant tasks to work under Linux, why you would say, ant is multi platform building system ? true, but since it’s also expandable than the tasks you write yourself in java are your responsibility.

Some people did not use theĀ 

1
File.separatorChar

instead he used ‘\’ directly, what does he care ? it worked on windows… damn! so i had to fix that in several places. One more thing that i had to take into account eventually , but didn’t consider is the case of letters in UNIX! we had properties files that contained some data to be converted to binary and a name of an image to be associated with that binary data. I must admit i would not consider the case of those files as well, but in Linux i got null pointers because java could not find the files on Linux, the case wasn’t the same… Fullish but a serious pitfall when you consider the fact that you need to move from windows to Linux.

So to avoid it:

  1. preferably, develop in Linux, it’s easier to port it ton windows, less restrictions!
  2. Never use in your tasks special JNI libraries that are based on a library that exists only for a certain platform, unless you care not about the porting.
  3. be ware of the case in other platforms, in case you do not develop on Linux\Unix\mac systems.
  4. Make sure to use the java platform consts and services so you are fully OS dependant (like the case o file seperator i’m sure there might be more!

Enjoy!

Theme Tweaker by Unreal