mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
105 stars 76 forks source link

Plugin execution fails on linux if xsd path contains whitespace characters #158

Open Omega1001 opened 4 years ago

Omega1001 commented 4 years ago

If the path to the xsd file contains any whitespaces, the attached exception.txt is generated. Please note that it tries to read the schema from

/home/<username>/git/Shared_FS/Shared FS/home/<username>/git/Shared_FS/Shared FS/sharedfs.client/sharedfs.client.connector/target/xsds/requests.xsd

while the files actual location is /home/<username>/git/Shared_FS/Shared FS/sharedfs.client/sharedfs.client.connector/target/xsds/requests.xsd

Omega1001 commented 4 years ago

I did a little debuging on this and found out, that the problem is being caused in the class org.codehaus.mojo.jaxb2.shared.FileSystemUtilities#relativize. The problem is, that under linux the "path" is for some reason URL encoded, meaning that whitespaces are encoded as %20 while the canonicalPath encodes it as " ". I created a make-shift patch for this in order to keep working by changing String toReturn = path; to String toReturn = path.replaceAll("%20", " ");. (Line #539)