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

Ability to exchange dependencies

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Feature Request: I would like to have the explicit ability to exchange dependencies globally, such as from dependencyManagement.

      Currently, I can do <excludes> on a dependency’’s transitive dependency, then add an explicit <dependency> to the POM of my final WAR (and possibly a test-scoped one on the JAR it’s in), but that makes the maven-dependency-plugin:3.1.1:analyze-only goal complain about a declared but unused dependency.

      With the javax.* → jakarta moves (and some others, e.g. I need the com.sun.activation version of jakarta.activation instead of the Jakarta one) and multiple JAXB implementations around, this is becoming troublesome.

      Therefore, I would like for Maven to allow something like this:

      <dependencyManagement>
       <substitutions>
        <substitution>
         <exclusion>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
         </exclusion>
         <dependency>
          <groupId>jakarta.xml.bind</groupId>
          <artifactId>jakarta.xml.bind-api</artifactId>
         </dependency>
        </substitution>
        <!-- … -->
       </substitutions>
       <dependencies>
        <dependency>
         <groupId>jakarta.xml.bind</groupId>
         <artifactId>jakarta.xml.bind-api</artifactId>
         <version>${jaxb-api.version}</version>
        </dependency>
        <!-- … -->
       </dependencies>
      </dependencyManagement>
      

      This would recursively replace the old JAXB-API with the new one but not add them where unnecessary, and make the maven-dependency-plugin’s checks do the right thing.

      Thanks in advance for consideration!

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mirabilos Thorsten Glaser
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: