Which Version of maven supports exclusion from dependency Management










0














I have a dependency inherited from one external project dependency, which we don't have control and we want to exclude a specific dependency from that project. Tried several exclusion attempts but still not able to exclude the same.



<dependency>
<groupId>..</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>...</groupId>
<artifactId>...</artifactId>
</exclusion>
</exclusions>
</dependency>


Could anyone let me know is it possible to exclude the dpendency. I am using 3.5.2 maven version.










share|improve this question





















  • Using Maven 3.5.4 the exclusions are working fine. Usually, I set them in dependencyManagement section as you mentioned.
    – Kérdezösködő Indián
    Nov 9 at 5:51











  • Your dependency seems strange because you have type pom and scope import. Why?
    – JF Meier
    Nov 9 at 7:42










  • @KérdezösködőIndián tried the latest version 3.6.0 but did not solve my issue.
    – Sam
    Nov 9 at 9:27










  • Exclusions work in all newer Maven versions ... there must be some error in your pom. Could you add more details, and especially answer my question on why you want an exclusion on an import scoped dependency?
    – JF Meier
    Nov 9 at 9:55










  • @JFMeier this project from where i want to exclude a dependency is managed by some other team and we cannot ask them to update the dependency of a specific jar that is coming as a part of existing imports which is done few years back. So i want to exclude that dependency and add my version of dependency .But the problem is as it is managed through <scope>import</scope> , even if we add exclusions, and add our dependency with a correct version ,it overrides the version.Hope i answered your question.this a case of transitive dependency Refer this issues.apache.org/jira/browse/MNG-5600
    – Sam
    Nov 9 at 10:11















0














I have a dependency inherited from one external project dependency, which we don't have control and we want to exclude a specific dependency from that project. Tried several exclusion attempts but still not able to exclude the same.



<dependency>
<groupId>..</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>...</groupId>
<artifactId>...</artifactId>
</exclusion>
</exclusions>
</dependency>


Could anyone let me know is it possible to exclude the dpendency. I am using 3.5.2 maven version.










share|improve this question





















  • Using Maven 3.5.4 the exclusions are working fine. Usually, I set them in dependencyManagement section as you mentioned.
    – Kérdezösködő Indián
    Nov 9 at 5:51











  • Your dependency seems strange because you have type pom and scope import. Why?
    – JF Meier
    Nov 9 at 7:42










  • @KérdezösködőIndián tried the latest version 3.6.0 but did not solve my issue.
    – Sam
    Nov 9 at 9:27










  • Exclusions work in all newer Maven versions ... there must be some error in your pom. Could you add more details, and especially answer my question on why you want an exclusion on an import scoped dependency?
    – JF Meier
    Nov 9 at 9:55










  • @JFMeier this project from where i want to exclude a dependency is managed by some other team and we cannot ask them to update the dependency of a specific jar that is coming as a part of existing imports which is done few years back. So i want to exclude that dependency and add my version of dependency .But the problem is as it is managed through <scope>import</scope> , even if we add exclusions, and add our dependency with a correct version ,it overrides the version.Hope i answered your question.this a case of transitive dependency Refer this issues.apache.org/jira/browse/MNG-5600
    – Sam
    Nov 9 at 10:11













0












0








0







I have a dependency inherited from one external project dependency, which we don't have control and we want to exclude a specific dependency from that project. Tried several exclusion attempts but still not able to exclude the same.



<dependency>
<groupId>..</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>...</groupId>
<artifactId>...</artifactId>
</exclusion>
</exclusions>
</dependency>


Could anyone let me know is it possible to exclude the dpendency. I am using 3.5.2 maven version.










share|improve this question













I have a dependency inherited from one external project dependency, which we don't have control and we want to exclude a specific dependency from that project. Tried several exclusion attempts but still not able to exclude the same.



<dependency>
<groupId>..</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>...</groupId>
<artifactId>...</artifactId>
</exclusion>
</exclusions>
</dependency>


Could anyone let me know is it possible to exclude the dpendency. I am using 3.5.2 maven version.







maven maven-3 dependency-management






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 5:27









Sam

1981311




1981311











  • Using Maven 3.5.4 the exclusions are working fine. Usually, I set them in dependencyManagement section as you mentioned.
    – Kérdezösködő Indián
    Nov 9 at 5:51











  • Your dependency seems strange because you have type pom and scope import. Why?
    – JF Meier
    Nov 9 at 7:42










  • @KérdezösködőIndián tried the latest version 3.6.0 but did not solve my issue.
    – Sam
    Nov 9 at 9:27










  • Exclusions work in all newer Maven versions ... there must be some error in your pom. Could you add more details, and especially answer my question on why you want an exclusion on an import scoped dependency?
    – JF Meier
    Nov 9 at 9:55










  • @JFMeier this project from where i want to exclude a dependency is managed by some other team and we cannot ask them to update the dependency of a specific jar that is coming as a part of existing imports which is done few years back. So i want to exclude that dependency and add my version of dependency .But the problem is as it is managed through <scope>import</scope> , even if we add exclusions, and add our dependency with a correct version ,it overrides the version.Hope i answered your question.this a case of transitive dependency Refer this issues.apache.org/jira/browse/MNG-5600
    – Sam
    Nov 9 at 10:11
















  • Using Maven 3.5.4 the exclusions are working fine. Usually, I set them in dependencyManagement section as you mentioned.
    – Kérdezösködő Indián
    Nov 9 at 5:51











  • Your dependency seems strange because you have type pom and scope import. Why?
    – JF Meier
    Nov 9 at 7:42










  • @KérdezösködőIndián tried the latest version 3.6.0 but did not solve my issue.
    – Sam
    Nov 9 at 9:27










  • Exclusions work in all newer Maven versions ... there must be some error in your pom. Could you add more details, and especially answer my question on why you want an exclusion on an import scoped dependency?
    – JF Meier
    Nov 9 at 9:55










  • @JFMeier this project from where i want to exclude a dependency is managed by some other team and we cannot ask them to update the dependency of a specific jar that is coming as a part of existing imports which is done few years back. So i want to exclude that dependency and add my version of dependency .But the problem is as it is managed through <scope>import</scope> , even if we add exclusions, and add our dependency with a correct version ,it overrides the version.Hope i answered your question.this a case of transitive dependency Refer this issues.apache.org/jira/browse/MNG-5600
    – Sam
    Nov 9 at 10:11















Using Maven 3.5.4 the exclusions are working fine. Usually, I set them in dependencyManagement section as you mentioned.
– Kérdezösködő Indián
Nov 9 at 5:51





Using Maven 3.5.4 the exclusions are working fine. Usually, I set them in dependencyManagement section as you mentioned.
– Kérdezösködő Indián
Nov 9 at 5:51













Your dependency seems strange because you have type pom and scope import. Why?
– JF Meier
Nov 9 at 7:42




Your dependency seems strange because you have type pom and scope import. Why?
– JF Meier
Nov 9 at 7:42












@KérdezösködőIndián tried the latest version 3.6.0 but did not solve my issue.
– Sam
Nov 9 at 9:27




@KérdezösködőIndián tried the latest version 3.6.0 but did not solve my issue.
– Sam
Nov 9 at 9:27












Exclusions work in all newer Maven versions ... there must be some error in your pom. Could you add more details, and especially answer my question on why you want an exclusion on an import scoped dependency?
– JF Meier
Nov 9 at 9:55




Exclusions work in all newer Maven versions ... there must be some error in your pom. Could you add more details, and especially answer my question on why you want an exclusion on an import scoped dependency?
– JF Meier
Nov 9 at 9:55












@JFMeier this project from where i want to exclude a dependency is managed by some other team and we cannot ask them to update the dependency of a specific jar that is coming as a part of existing imports which is done few years back. So i want to exclude that dependency and add my version of dependency .But the problem is as it is managed through <scope>import</scope> , even if we add exclusions, and add our dependency with a correct version ,it overrides the version.Hope i answered your question.this a case of transitive dependency Refer this issues.apache.org/jira/browse/MNG-5600
– Sam
Nov 9 at 10:11




@JFMeier this project from where i want to exclude a dependency is managed by some other team and we cannot ask them to update the dependency of a specific jar that is coming as a part of existing imports which is done few years back. So i want to exclude that dependency and add my version of dependency .But the problem is as it is managed through <scope>import</scope> , even if we add exclusions, and add our dependency with a correct version ,it overrides the version.Hope i answered your question.this a case of transitive dependency Refer this issues.apache.org/jira/browse/MNG-5600
– Sam
Nov 9 at 10:11












2 Answers
2






active

oldest

votes


















1














It looks like that version is not released yet, but there is a workaround.



There is an example of dependencies import at Importing Dependencies with following explanation:



<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>Z</artifactId>
<packaging>pom</packaging>
<name>Z</name>
<version>1.0</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>X</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>Y</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>



In the example above Z imports the managed dependencies from both X and Y. However, both X and Y contain dependency a. Here, version 1.1 of a would be used since X is declared first and a is not declared in Z's dependencyManagement.




Given that description, you should be able to override the version and/or scope of offending dependency if you define it BEFORE imports.



Following the same example, the definition below should use version 2.0 of a:



<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>Z</artifactId>
<packaging>pom</packaging>
<name>Z</name>
<version>1.0</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>a</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>X</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>Y</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>


Make sure to check the effective pom!






share|improve this answer






























    1














    Exclusions have been available for a long time in Maven, that's not the problem. Keep you current Maven version, it will do it's job well.



    I think there is a confusion there.
    From the pom excerpt you wrote above, we can see that you import a pom (scope "import") which is often called a BOM (for Bill Of Material).



    A BOM is imported in a <dependencyManagement> section (not showed above) and it's goal can be summed up by: "I define many different libraries, including their versions so that if you import me you can ommit to specify the version of the libraries you define, but you still have to explicitly define your direct dependencies".



    By that, I mean that a BOM does not "force" you to use the libraries it defines: it only hints that in the case that you or your dependencies depends upon a specific library Z, then the version of Z will be forced to the one defined in the BOM".



    So the BOM does not "forces" dependencies upon you so you cannot "exclude" any dependency where the BOM is defined.
    You have to find exactly where the dependency Z you want to exclude is defined in your own project and remove it there. It may also be brought as a transitive dependency in which case you have to use exclude it from the dependency you have specified using the <exclusions> / <exclusion> tags and the groupId / artifactId.



    In conclusion: change your approach, you're not looking in the right place. And also use Maven dependency plugin which is your best friend to understand where your unwanted dependency comes from exactly ( mvn dependency:tree ).



    I hope it helps



    PS: you did not tell but do you have a multimodule project ?






    share|improve this answer




















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220334%2fwhich-version-of-maven-supports-exclusion-from-dependency-management%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      It looks like that version is not released yet, but there is a workaround.



      There is an example of dependencies import at Importing Dependencies with following explanation:



      <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>maven</groupId>
      <artifactId>Z</artifactId>
      <packaging>pom</packaging>
      <name>Z</name>
      <version>1.0</version>
      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>maven</groupId>
      <artifactId>X</artifactId>
      <version>1.0</version>
      <type>pom</type>
      <scope>import</scope>
      </dependency>
      <dependency>
      <groupId>maven</groupId>
      <artifactId>Y</artifactId>
      <version>1.0</version>
      <type>pom</type>
      <scope>import</scope>
      </dependency>
      </dependencies>
      </dependencyManagement>
      </project>



      In the example above Z imports the managed dependencies from both X and Y. However, both X and Y contain dependency a. Here, version 1.1 of a would be used since X is declared first and a is not declared in Z's dependencyManagement.




      Given that description, you should be able to override the version and/or scope of offending dependency if you define it BEFORE imports.



      Following the same example, the definition below should use version 2.0 of a:



      <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>maven</groupId>
      <artifactId>Z</artifactId>
      <packaging>pom</packaging>
      <name>Z</name>
      <version>1.0</version>
      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>test</groupId>
      <artifactId>a</artifactId>
      <version>2.0</version>
      </dependency>
      <dependency>
      <groupId>maven</groupId>
      <artifactId>X</artifactId>
      <version>1.0</version>
      <type>pom</type>
      <scope>import</scope>
      </dependency>
      <dependency>
      <groupId>maven</groupId>
      <artifactId>Y</artifactId>
      <version>1.0</version>
      <type>pom</type>
      <scope>import</scope>
      </dependency>
      </dependencies>
      </dependencyManagement>
      </project>


      Make sure to check the effective pom!






      share|improve this answer



























        1














        It looks like that version is not released yet, but there is a workaround.



        There is an example of dependencies import at Importing Dependencies with following explanation:



        <project>
        <modelVersion>4.0.0</modelVersion>
        <groupId>maven</groupId>
        <artifactId>Z</artifactId>
        <packaging>pom</packaging>
        <name>Z</name>
        <version>1.0</version>
        <dependencyManagement>
        <dependencies>
        <dependency>
        <groupId>maven</groupId>
        <artifactId>X</artifactId>
        <version>1.0</version>
        <type>pom</type>
        <scope>import</scope>
        </dependency>
        <dependency>
        <groupId>maven</groupId>
        <artifactId>Y</artifactId>
        <version>1.0</version>
        <type>pom</type>
        <scope>import</scope>
        </dependency>
        </dependencies>
        </dependencyManagement>
        </project>



        In the example above Z imports the managed dependencies from both X and Y. However, both X and Y contain dependency a. Here, version 1.1 of a would be used since X is declared first and a is not declared in Z's dependencyManagement.




        Given that description, you should be able to override the version and/or scope of offending dependency if you define it BEFORE imports.



        Following the same example, the definition below should use version 2.0 of a:



        <project>
        <modelVersion>4.0.0</modelVersion>
        <groupId>maven</groupId>
        <artifactId>Z</artifactId>
        <packaging>pom</packaging>
        <name>Z</name>
        <version>1.0</version>
        <dependencyManagement>
        <dependencies>
        <dependency>
        <groupId>test</groupId>
        <artifactId>a</artifactId>
        <version>2.0</version>
        </dependency>
        <dependency>
        <groupId>maven</groupId>
        <artifactId>X</artifactId>
        <version>1.0</version>
        <type>pom</type>
        <scope>import</scope>
        </dependency>
        <dependency>
        <groupId>maven</groupId>
        <artifactId>Y</artifactId>
        <version>1.0</version>
        <type>pom</type>
        <scope>import</scope>
        </dependency>
        </dependencies>
        </dependencyManagement>
        </project>


        Make sure to check the effective pom!






        share|improve this answer

























          1












          1








          1






          It looks like that version is not released yet, but there is a workaround.



          There is an example of dependencies import at Importing Dependencies with following explanation:



          <project>
          <modelVersion>4.0.0</modelVersion>
          <groupId>maven</groupId>
          <artifactId>Z</artifactId>
          <packaging>pom</packaging>
          <name>Z</name>
          <version>1.0</version>
          <dependencyManagement>
          <dependencies>
          <dependency>
          <groupId>maven</groupId>
          <artifactId>X</artifactId>
          <version>1.0</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          <dependency>
          <groupId>maven</groupId>
          <artifactId>Y</artifactId>
          <version>1.0</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          </dependencies>
          </dependencyManagement>
          </project>



          In the example above Z imports the managed dependencies from both X and Y. However, both X and Y contain dependency a. Here, version 1.1 of a would be used since X is declared first and a is not declared in Z's dependencyManagement.




          Given that description, you should be able to override the version and/or scope of offending dependency if you define it BEFORE imports.



          Following the same example, the definition below should use version 2.0 of a:



          <project>
          <modelVersion>4.0.0</modelVersion>
          <groupId>maven</groupId>
          <artifactId>Z</artifactId>
          <packaging>pom</packaging>
          <name>Z</name>
          <version>1.0</version>
          <dependencyManagement>
          <dependencies>
          <dependency>
          <groupId>test</groupId>
          <artifactId>a</artifactId>
          <version>2.0</version>
          </dependency>
          <dependency>
          <groupId>maven</groupId>
          <artifactId>X</artifactId>
          <version>1.0</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          <dependency>
          <groupId>maven</groupId>
          <artifactId>Y</artifactId>
          <version>1.0</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          </dependencies>
          </dependencyManagement>
          </project>


          Make sure to check the effective pom!






          share|improve this answer














          It looks like that version is not released yet, but there is a workaround.



          There is an example of dependencies import at Importing Dependencies with following explanation:



          <project>
          <modelVersion>4.0.0</modelVersion>
          <groupId>maven</groupId>
          <artifactId>Z</artifactId>
          <packaging>pom</packaging>
          <name>Z</name>
          <version>1.0</version>
          <dependencyManagement>
          <dependencies>
          <dependency>
          <groupId>maven</groupId>
          <artifactId>X</artifactId>
          <version>1.0</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          <dependency>
          <groupId>maven</groupId>
          <artifactId>Y</artifactId>
          <version>1.0</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          </dependencies>
          </dependencyManagement>
          </project>



          In the example above Z imports the managed dependencies from both X and Y. However, both X and Y contain dependency a. Here, version 1.1 of a would be used since X is declared first and a is not declared in Z's dependencyManagement.




          Given that description, you should be able to override the version and/or scope of offending dependency if you define it BEFORE imports.



          Following the same example, the definition below should use version 2.0 of a:



          <project>
          <modelVersion>4.0.0</modelVersion>
          <groupId>maven</groupId>
          <artifactId>Z</artifactId>
          <packaging>pom</packaging>
          <name>Z</name>
          <version>1.0</version>
          <dependencyManagement>
          <dependencies>
          <dependency>
          <groupId>test</groupId>
          <artifactId>a</artifactId>
          <version>2.0</version>
          </dependency>
          <dependency>
          <groupId>maven</groupId>
          <artifactId>X</artifactId>
          <version>1.0</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          <dependency>
          <groupId>maven</groupId>
          <artifactId>Y</artifactId>
          <version>1.0</version>
          <type>pom</type>
          <scope>import</scope>
          </dependency>
          </dependencies>
          </dependencyManagement>
          </project>


          Make sure to check the effective pom!







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 10 at 22:35

























          answered Nov 10 at 22:08









          Illya Kysil

          703411




          703411























              1














              Exclusions have been available for a long time in Maven, that's not the problem. Keep you current Maven version, it will do it's job well.



              I think there is a confusion there.
              From the pom excerpt you wrote above, we can see that you import a pom (scope "import") which is often called a BOM (for Bill Of Material).



              A BOM is imported in a <dependencyManagement> section (not showed above) and it's goal can be summed up by: "I define many different libraries, including their versions so that if you import me you can ommit to specify the version of the libraries you define, but you still have to explicitly define your direct dependencies".



              By that, I mean that a BOM does not "force" you to use the libraries it defines: it only hints that in the case that you or your dependencies depends upon a specific library Z, then the version of Z will be forced to the one defined in the BOM".



              So the BOM does not "forces" dependencies upon you so you cannot "exclude" any dependency where the BOM is defined.
              You have to find exactly where the dependency Z you want to exclude is defined in your own project and remove it there. It may also be brought as a transitive dependency in which case you have to use exclude it from the dependency you have specified using the <exclusions> / <exclusion> tags and the groupId / artifactId.



              In conclusion: change your approach, you're not looking in the right place. And also use Maven dependency plugin which is your best friend to understand where your unwanted dependency comes from exactly ( mvn dependency:tree ).



              I hope it helps



              PS: you did not tell but do you have a multimodule project ?






              share|improve this answer

























                1














                Exclusions have been available for a long time in Maven, that's not the problem. Keep you current Maven version, it will do it's job well.



                I think there is a confusion there.
                From the pom excerpt you wrote above, we can see that you import a pom (scope "import") which is often called a BOM (for Bill Of Material).



                A BOM is imported in a <dependencyManagement> section (not showed above) and it's goal can be summed up by: "I define many different libraries, including their versions so that if you import me you can ommit to specify the version of the libraries you define, but you still have to explicitly define your direct dependencies".



                By that, I mean that a BOM does not "force" you to use the libraries it defines: it only hints that in the case that you or your dependencies depends upon a specific library Z, then the version of Z will be forced to the one defined in the BOM".



                So the BOM does not "forces" dependencies upon you so you cannot "exclude" any dependency where the BOM is defined.
                You have to find exactly where the dependency Z you want to exclude is defined in your own project and remove it there. It may also be brought as a transitive dependency in which case you have to use exclude it from the dependency you have specified using the <exclusions> / <exclusion> tags and the groupId / artifactId.



                In conclusion: change your approach, you're not looking in the right place. And also use Maven dependency plugin which is your best friend to understand where your unwanted dependency comes from exactly ( mvn dependency:tree ).



                I hope it helps



                PS: you did not tell but do you have a multimodule project ?






                share|improve this answer























                  1












                  1








                  1






                  Exclusions have been available for a long time in Maven, that's not the problem. Keep you current Maven version, it will do it's job well.



                  I think there is a confusion there.
                  From the pom excerpt you wrote above, we can see that you import a pom (scope "import") which is often called a BOM (for Bill Of Material).



                  A BOM is imported in a <dependencyManagement> section (not showed above) and it's goal can be summed up by: "I define many different libraries, including their versions so that if you import me you can ommit to specify the version of the libraries you define, but you still have to explicitly define your direct dependencies".



                  By that, I mean that a BOM does not "force" you to use the libraries it defines: it only hints that in the case that you or your dependencies depends upon a specific library Z, then the version of Z will be forced to the one defined in the BOM".



                  So the BOM does not "forces" dependencies upon you so you cannot "exclude" any dependency where the BOM is defined.
                  You have to find exactly where the dependency Z you want to exclude is defined in your own project and remove it there. It may also be brought as a transitive dependency in which case you have to use exclude it from the dependency you have specified using the <exclusions> / <exclusion> tags and the groupId / artifactId.



                  In conclusion: change your approach, you're not looking in the right place. And also use Maven dependency plugin which is your best friend to understand where your unwanted dependency comes from exactly ( mvn dependency:tree ).



                  I hope it helps



                  PS: you did not tell but do you have a multimodule project ?






                  share|improve this answer












                  Exclusions have been available for a long time in Maven, that's not the problem. Keep you current Maven version, it will do it's job well.



                  I think there is a confusion there.
                  From the pom excerpt you wrote above, we can see that you import a pom (scope "import") which is often called a BOM (for Bill Of Material).



                  A BOM is imported in a <dependencyManagement> section (not showed above) and it's goal can be summed up by: "I define many different libraries, including their versions so that if you import me you can ommit to specify the version of the libraries you define, but you still have to explicitly define your direct dependencies".



                  By that, I mean that a BOM does not "force" you to use the libraries it defines: it only hints that in the case that you or your dependencies depends upon a specific library Z, then the version of Z will be forced to the one defined in the BOM".



                  So the BOM does not "forces" dependencies upon you so you cannot "exclude" any dependency where the BOM is defined.
                  You have to find exactly where the dependency Z you want to exclude is defined in your own project and remove it there. It may also be brought as a transitive dependency in which case you have to use exclude it from the dependency you have specified using the <exclusions> / <exclusion> tags and the groupId / artifactId.



                  In conclusion: change your approach, you're not looking in the right place. And also use Maven dependency plugin which is your best friend to understand where your unwanted dependency comes from exactly ( mvn dependency:tree ).



                  I hope it helps



                  PS: you did not tell but do you have a multimodule project ?







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 10 at 23:36









                  Francois Marot

                  547213




                  547213



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid …


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid …


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220334%2fwhich-version-of-maven-supports-exclusion-from-dependency-management%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Top Tejano songwriter Luis Silva dead of heart attack at 64

                      政党

                      天津地下鉄3号線