Home » Java » Check for file with backslash in the name

Check for file with backslash in the name

Posted by: admin April 25, 2018 Leave a comment


We are in the process of moving our CI build from a windows server to a linux one. The developer local builds will still be running on windows.

Part of our build we have a third party product which compiles a work flow into some XML files and assemble them in a jar. We have no control about how that third party compiler works.

Part of the compilation process the third party compiler created a out/jar folder in which it puts all the XMLs with a view to assamle them in the final jar.

When building on linux it seems there is a bug in the third party compiler which for some part of the work flow rather then creating a file called namespaceMapping.xml in the jar folder it actually creates a file called jar\namespaceMapping.xml and puts it in the out folder. Not having the namespaceMapping.xml in the final jar causes our system to fail starting.

Now we pay support for this third party and assuming they support linux builds (questionable) they will change their compiler to work properly on both linux and windows. However this seems to be the only one issue and we’d like to move on rather than waiting for a fix so here is my question:

The ant script are ours and I was thinking to check if a file called namespaceMapping.xml exists in the out/jar folder and if it does take no further action. However if it does not then check for a file called jar\namespaceMapping.xml and if it does do further manipulation of this file to include it in the final jar with the right name. Any attempt to do this with available task failed because of the nature of ant doing the file path conversion to adapt to the operating system path separator.

I would prefer to do this with the out of the box ant tasks rather than creating a custom task for this. Any suggestion?

Thank you in advance.