Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-2154

Cannot add two dependencies that differ only in the 'type' attribute to a new Maven project's POM.

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.12.3.Final
    • 2.12.2.Final
    • Addon Development
    • None

      The method "areEquivalent(Dependency, Dependency)" of org.jboss.forge.addon.dependencies.util.Dependencies does not check to see if the two dependencies have different packaging types or scopes.

      For example, I cannot add both of the following dependencies:
      <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-cdi-client</artifactId>
      <type>jar</type>
      <scope>provided</scope>
      </dependency>

      <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-cdi-client</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
      </dependency>

            [FORGE-2154] Cannot add two dependencies that differ only in the 'type' attribute to a new Maven project's POM.

            Fixed

            George Gastaldi added a comment - Fixed

            George Gastaldi added a comment - - edited

            George Gastaldi added a comment - - edited I believe the code you're referring to is https://github.com/forge/core/blob/master/maven/impl-projects/src/main/java/org/jboss/forge/addon/maven/projects/facets/MavenDependencyFacet.java#L76 ?

            Hi ddadlani,
            Can you create a test case with the expected behavior? A Pull-request would be even better

            George Gastaldi added a comment - Hi ddadlani , Can you create a test case with the expected behavior? A Pull-request would be even better

            Divya Dadlani (Inactive) added a comment - - edited

            I still cannot add two dependencies that differ only in the 'scope' and 'type' attributes.

            This is because the method addDirectDependency() in org.jboss.forge.addon.maven.projects.facets.MavenDependencyArtifact also compares only the groupId and artifactId of the new dependency against the ones already in the pom. Hence the second dependency does not get added.

            From the previous fix, Dependencies.areEquivalent() already checks for this, so shouldn't addDirectDependency() call areEquivalent() instead of directly comparing strings?

            Divya Dadlani (Inactive) added a comment - - edited I still cannot add two dependencies that differ only in the 'scope' and 'type' attributes. This is because the method addDirectDependency() in org.jboss.forge.addon.maven.projects.facets.MavenDependencyArtifact also compares only the groupId and artifactId of the new dependency against the ones already in the pom. Hence the second dependency does not get added. From the previous fix, Dependencies.areEquivalent() already checks for this, so shouldn't addDirectDependency() call areEquivalent() instead of directly comparing strings?

              rhn-support-ggastald George Gastaldi
              ddadlani Divya Dadlani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: