Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-3331

Normalize paths to sub modules

    XMLWordPrintableJSON

Details

    • Patch

    Description

      When collecting the sub modules during a reactor build, the path to the module POMs should always be normalized. Currently, this happens only on a Windows platform via File.getCanonicalFile(). The attached patch adds normalization (but not canonicalization) for other platforms, too.

      The motivation: Consider a multi module project with the following directory structure:
      project/
      project-parent/
      project-module/
      such that the parent POM in project-parent will contain
      <module>../project-module</module>
      to reference the sub module. Simple string/path concatenation will therefore deliver a path like

      {SNIP}/project-parent/../project-module
      for the sub module. Having
      {SNIP}

      /project-module
      instead is surely better, and may it be just for nice log output.

      However, certain plugins/tools try to detect symlinks by comparing the canonicalized path with the absolute path of a file. While users of DirectoryScanner are usually fine because this class always canonicalizes the base directory before the check, code that does not know about a base directory but simply gets a single file will erroneously detect a symlink because ".." gets removed during canonicalization.

      This actually happens with the CpdReport of the maven-pmd-plugin. See CPD.addFile(int, File) for the cause, i.e. the code near line 97 where it prints "Skipping

      {file}

      since it appears to be a symlink".

      Attachments

        1. normalized-module-file.patch
          0.8 kB
          Benjamin Bentmann

        Activity

          People

            jdcasey John Dennis Casey
            bentmann Benjamin Bentmann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: