Sonar-maven-plugin: error: 'other' has different root"

When building a Maven project on a Jenkins Windows node, the following error is reported:

INFO | maven : [INFO] --- sonar-maven-plugin: (default-cli) @ XXXXX ---
INFO | maven : [INFO] User cache: C:\Users\XXXX\.sonar\cache
INFO | maven : [INFO] SonarQube version: 8.4.1
INFO | maven : [INFO] ------------------------------------------------------------------------
INFO | maven : [INFO] Reactor Summary:
INFO | maven : [INFO].--------------------------
INFO | maven : [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project XXXXX: 'other' has different root -> [Help 1]

The stack trace is:

Caused by: java.lang.IllegalArgumentException: 'other' has different root
    at sun.nio.fs.WindowsPath.relativize(
    at sun.nio.fs.WindowsPath.relativize(
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.lambda$removeTarget$2(
    at java.util.Collection.removeIf(
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.removeTarget(
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.sourcePaths(
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.mainSources(
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.synchronizeFileSystemAndOtherProps(
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.computeSonarQubeProperties(
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.configureModules(
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.configure(
    at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.collectProperties(
    at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(
    ... 23 more

Coming from ( )

  private static void removeTarget(MavenProject pom, Collection<String> relativeOrAbsolutePaths) {
    final Path baseDir = pom.getBasedir().toPath().toAbsolutePath().normalize();
    final Path target = Paths.get(pom.getBuild().getDirectory()).toAbsolutePath().normalize();
    final Path targetRelativePath = baseDir.relativize(target);

    relativeOrAbsolutePaths.removeIf(pathStr -> {
      Path path = Paths.get(pathStr).toAbsolutePath().normalize();
      Path relativePath = baseDir.relativize(path);
      return relativePath.startsWith(targetRelativePath);

And Java relativize fct ( ) :

 368     public WindowsPath relativize(Path obj) {
 369         WindowsPath other = checkPath(obj);
 370         if (this.equals(other))
 371             return null;
 373         // can only relativize paths of the same type
 374         if (this.type != other.type)
 375             throw new IllegalArgumentException("'other' is different type of Path");
 377         // can only relativize paths if root component matches
 378         if (!this.root.equalsIgnoreCase(other.root))
 379             throw new IllegalArgumentException("'other' has different root");

The Jenkins workspace is in the D:\ drive. This is most probably the cause of the problem.

When the same project,saved on the c:\ drive, is built on a local windows machine, no error is reported

Hi @Laurent_Peters,

First off; Happy new year!

Can you confirm if you are using symlinks or something similar?


Hi Mark,

Happy new year!

No, we are not using symlinks or something similar.


Hi @Laurent_Peters

Even though you are not using symlinks, or something similar, it does seem that you are effected by a limitation that also shows its face when using symlinks. For this we have an open ticket I would like to suggest that you watch that ticket to get updates as soon as we have found a solution for this and start development.

To be sure to set the appropriate expectations, this is a complex problem to solve that may need more time to find a proper solution. So please bare with us.


Hi @Laurent_Peters,

I have discussed this issue internally and I would like to request some more specific information on your build environment setup. This in an effort to reproduce the issue on our end.
Can you share as much detail of your build setup as possible? Especially your workspace setup in Jenkins. Are there any differences between where Jenkins executes the scan, the location of the maven src and target directories. The more details you can provide the higher the likelihood we can successfully attempt to reproduce the issue.



Here are the locations of our tools, settings, workspace:

JAVA_HOME = C:\Program Files\Java\jdk1.8.0_221
MVN_CMD = d:\jenkins\tools\hudson.tasks.Maven_MavenInstallation\maven/bin/mvn.cmd)
WORKSPACE = d:\jenkins\workspace\xxxxx

The problem seems to be that some of these folders are in the c:\drive and others in the d:\drive.