Ant Java: Misleading "current file" filepath

As a user, when scanning Java files in an Ant build, I would like console output for the path in the “current file” path to be like the path listed on the SonarQube server (relative path to the project). What I see in the terminal window is “X/X files analyzed, current file: -current working directory-/-path to file-” which is an absolute path.

Having the console output be an absolute path rather than a relative path to the project is misleading. The reason why is that sonar exclusion and inclusion files need to be relative paths to the project, and not absolute paths. With Ant, one could use a fileset or dirset operation with a pathconvert to get the list of files/directories to include/exclude. However, those operations return an absolute path, unless you explicitly use a map with the pathconvert to strip the base directory prefix. Therefore, one could fall into the trap of thinking that files are being included/excluded properly because the file path matches the console output on the screen, but the file will not be included/excluded because sonar.exclusions requires the file paths to be absolute to the project.

I understand that there are workarounds, like using the UI instead of using Ant properties, and I understand that in the grand scheme of things, this is a very tiny problem, but I believe that this falls into an “ease of use” or “lessen the learning curve” category. If fixing this makes others not have to bang their head against the wall for days like I did, then I think it’s worth it.


So you know, you get this absolute path listing for all scanners, not just Ant. I appreciate your point of view, but I suspect there would be many more who would argue to change it back to absolute paths if we made this change. In fact, the data in the analysis log is supposed to help you understand and debug what’s going on in analysis.

As you acknowledge, includes and excludes need the paths shown in the UI, and setting them is far easier through the UI. Out of curiosity, what was it that initially led you to try setting them on the analysis side?