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

add support for module name != artifactId in every calculated URLs (project, SCM, site): special project.directory property

    Details

      Description

      Say you have this project structure:

      /
        |-- module1
        |-- module2
      

      and artifactIds are named:

      my-parent
        |-- my-module1
        |-- my-module2
      

      Prefix my- is omitted for brevity in module names. For instance, Jersey does that.

      When the SCM report is built, the artifactId is always used for path composition which leads to incorrect URLs. You can of course set the parameter checkoutDirectoryName but this would be extremely tedious for all modules down the tree.

      The code should obtain the module name and use it for URL composition.

        Issue Links

          Activity

          Hide
          hboutemy Hervé Boutemy added a comment -

          the problem is not in the report: look at effective pom, and you'll see that it is in the effective model

          see http://maven.apache.org/ref/3.3.1/maven-model-builder/xref/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.html#L60
          that is the code to fix (I don't see how) to have a better result when directory is not artifactId

          (and the problem does not happen when building from source, with SCM checkout available: the problem is when the model is calculated from repository, then there is no SCM checkout available)

          for such cases, where the "module directory = artifactId" convention is not used, you'll have to configure: yes, that's a result of "convention over configuration" mantra unless we find an algorithm to avoid requiring this convention

          Show
          hboutemy Hervé Boutemy added a comment - the problem is not in the report: look at effective pom, and you'll see that it is in the effective model see http://maven.apache.org/ref/3.3.1/maven-model-builder/xref/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.html#L60 that is the code to fix (I don't see how) to have a better result when directory is not artifactId (and the problem does not happen when building from source, with SCM checkout available: the problem is when the model is calculated from repository, then there is no SCM checkout available) for such cases, where the "module directory = artifactId" convention is not used, you'll have to configure: yes, that's a result of "convention over configuration" mantra unless we find an algorithm to avoid requiring this convention
          Hide
          hboutemy Hervé Boutemy added a comment - - edited

          a new idea: during build, there is already the algorithm to use local path, then values in effective pom are ok even if module directory != artifactId

          for artifacts from repo, perhaps we could use flatten-maven-plugin to detect that the "module directory == artifactId" convention is not used, then expand local path-calculated info flattened pom.xml?

          Show
          hboutemy Hervé Boutemy added a comment - - edited a new idea: during build, there is already the algorithm to use local path, then values in effective pom are ok even if module directory != artifactId for artifacts from repo, perhaps we could use flatten-maven-plugin to detect that the "module directory == artifactId" convention is not used, then expand local path-calculated info flattened pom.xml?
          Hide
          hboutemy Hervé Boutemy added a comment -

          feature added in branch 812e1e9d

          principe is to define project.directory property in child pom.xml that will be used instead of artifactId when defined
          (and this property in not inherited to further childs of child)

          Show
          hboutemy Hervé Boutemy added a comment - feature added in branch 812e1e9d principe is to define project.directory property in child pom.xml that will be used instead of artifactId when defined (and this property in not inherited to further childs of child)
          Hide
          jvanzyl Jason van Zyl added a comment -

          Seems perfectly reasonable.

          Show
          jvanzyl Jason van Zyl added a comment - Seems perfectly reasonable.
          Hide
          michael-o Michael Osipov added a comment -

          Hervé, I am somewhat confused by this solution. It looks like duplicate information. Might there be anycase when module name != artifactId but project.directory != module name?

          Show
          michael-o Michael Osipov added a comment - Hervé, I am somewhat confused by this solution. It looks like duplicate information. Might there be anycase when module name != artifactId but project.directory != module name?
          Hide
          hboutemy Hervé Boutemy added a comment -

          the case where we need this information is when the poms are in a repository: child pom does not know its module name, and can't know if it's a module of its parent pom

          Show
          hboutemy Hervé Boutemy added a comment - the case where we need this information is when the poms are in a repository: child pom does not know its module name, and can't know if it's a module of its parent pom
          Hide
          michael-o Michael Osipov added a comment -

          So you are saying that when the child POM is interpolated, it is not done down from the parent but directly int he child module? Therefore you need to duplicate that information?

          Show
          michael-o Michael Osipov added a comment - So you are saying that when the child POM is interpolated, it is not done down from the parent but directly int he child module? Therefore you need to duplicate that information?
          Hide
          hboutemy Hervé Boutemy added a comment -

          that's not so easy to imagine: that's why I wrote unit tests regarding url interpolation

          imagine: parent pom has 4 modules: module-a, module-b, module-c and module-d
          and module-a has "artifact-a" artifactId

          When bluiding, with module-a module in module-a directory, yes, this project.directory is a duplication of information

          But once everything is deployed to repository, and you try to calculate effective artifact-a, you can't know which of the 4 modules it represents if it doesn't contain a hint to tell "I'm module-a: that's the relative path to add to parent url"

          Show
          hboutemy Hervé Boutemy added a comment - that's not so easy to imagine: that's why I wrote unit tests regarding url interpolation imagine: parent pom has 4 modules: module-a, module-b, module-c and module-d and module-a has "artifact-a" artifactId When bluiding, with module-a module in module-a directory, yes, this project.directory is a duplication of information But once everything is deployed to repository, and you try to calculate effective artifact-a, you can't know which of the 4 modules it represents if it doesn't contain a hint to tell "I'm module-a: that's the relative path to add to parent url"
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in maven-3.x #1158 (See https://builds.apache.org/job/maven-3.x/1158/)
          MNG-5878 added project.directory property to support module name != (hboutemy: rev b19e8c78d4a802ecce0e386295960a4fcd7586d6)

          • maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml
          • maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-parent.xml
          • maven-model-builder/src/site/apt/index.apt
          • maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
          • maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml
          • maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in maven-3.x #1158 (See https://builds.apache.org/job/maven-3.x/1158/ ) MNG-5878 added project.directory property to support module name != (hboutemy: rev b19e8c78d4a802ecce0e386295960a4fcd7586d6) maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-parent.xml maven-model-builder/src/site/apt/index.apt maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in maven-3.x #1337 (See https://builds.apache.org/job/maven-3.x/1337/)
          MNG-5878 project.directory property can override artifactId in url (hboutemy: rev 14182b82fc63ec61ff771f5ba3b8c0a0babeadfd)

          • maven-model/src/main/mdo/maven.mdo
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in maven-3.x #1337 (See https://builds.apache.org/job/maven-3.x/1337/ ) MNG-5878 project.directory property can override artifactId in url (hboutemy: rev 14182b82fc63ec61ff771f5ba3b8c0a0babeadfd) maven-model/src/main/mdo/maven.mdo
          Hide
          hudson Hudson added a comment -

          FAILURE: Integrated in Jenkins build maven-3.x #1368 (See https://builds.apache.org/job/maven-3.x/1368/)
          MNG-5878 improved explanations (hboutemy: rev 7846f081a696baa6c88b0420b684829fb97e1d4d)

          • (edit) maven-model-builder/src/site/apt/index.apt
          Show
          hudson Hudson added a comment - FAILURE: Integrated in Jenkins build maven-3.x #1368 (See https://builds.apache.org/job/maven-3.x/1368/ ) MNG-5878 improved explanations (hboutemy: rev 7846f081a696baa6c88b0420b684829fb97e1d4d) (edit) maven-model-builder/src/site/apt/index.apt
          Hide
          stephenc Stephen Connolly added a comment -

          Maven 3.4.0 has been dropped. See this thread for more details.

          This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.

          Show
          stephenc Stephen Connolly added a comment - Maven 3.4.0 has been dropped. See this thread for more details. This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.
          Hide
          hudson Hudson added a comment -

          FAILURE: Integrated in Jenkins build maven-3.x #1535 (See https://builds.apache.org/job/maven-3.x/1535/)
          MNG-5878 added project.directory property to support module name != (hboutemy: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=9b763cc002e9a4e247baf7538727da5a29a6ce0b)

          • (add) maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-parent.xml
          • (add) maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml
          • (edit) maven-model/src/main/mdo/maven.mdo
          • (edit) maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
          • (edit) maven-model-builder/src/site/apt/index.apt
          • (edit) maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
          • (add) maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml
          Show
          hudson Hudson added a comment - FAILURE: Integrated in Jenkins build maven-3.x #1535 (See https://builds.apache.org/job/maven-3.x/1535/ ) MNG-5878 added project.directory property to support module name != (hboutemy: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=9b763cc002e9a4e247baf7538727da5a29a6ce0b ) (add) maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-parent.xml (add) maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-child.xml (edit) maven-model/src/main/mdo/maven.mdo (edit) maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java (edit) maven-model-builder/src/site/apt/index.apt (edit) maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java (add) maven-model-builder/src/test/resources/poms/inheritance/module-path-not-artifactId-expected.xml

            People

            • Assignee:
              hboutemy Hervé Boutemy
              Reporter:
              michael-o Michael Osipov
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development