Should you include those dependencies in your pom that are already the dependencies of some of your...











up vote
3
down vote

favorite
1












Say there are two dependencies you need: A and B. And at the same time A is already a dependency of B. So do you still want/need to add A along with B as dependencies in your pom?



I believe this may be needed when A and B are external libraries where the version of A needed may be different than the version of A that B is depending on.



But how about when both your module and A and B are modules in the same project? i.e. knowing their versions are all going to be in sync.










share|improve this question


























    up vote
    3
    down vote

    favorite
    1












    Say there are two dependencies you need: A and B. And at the same time A is already a dependency of B. So do you still want/need to add A along with B as dependencies in your pom?



    I believe this may be needed when A and B are external libraries where the version of A needed may be different than the version of A that B is depending on.



    But how about when both your module and A and B are modules in the same project? i.e. knowing their versions are all going to be in sync.










    share|improve this question
























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      Say there are two dependencies you need: A and B. And at the same time A is already a dependency of B. So do you still want/need to add A along with B as dependencies in your pom?



      I believe this may be needed when A and B are external libraries where the version of A needed may be different than the version of A that B is depending on.



      But how about when both your module and A and B are modules in the same project? i.e. knowing their versions are all going to be in sync.










      share|improve this question













      Say there are two dependencies you need: A and B. And at the same time A is already a dependency of B. So do you still want/need to add A along with B as dependencies in your pom?



      I believe this may be needed when A and B are external libraries where the version of A needed may be different than the version of A that B is depending on.



      But how about when both your module and A and B are modules in the same project? i.e. knowing their versions are all going to be in sync.







      maven pom.xml maven-dependency






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 13 hours ago









      user1589188

      1,54082664




      1,54082664
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote













          If your module uses APIs from B it's best practice to add it explicitly to your pom, even though it's not strictly necessary. If you upgrade A, it could well be that it doesn't use B anymore and then you'll get a build failure without any changes to your module code.



          Regarding versions, you should manage those with dependencyManagement in a parent pom. You can then skip the version for the managed dependencies in the child poms. The version in the dependencyManagement overrides the version in transitive dependencies, ensuring you use the same version everywhere.



          If all modules are in the same project, they should also share the same project version. Typically, this will be a snapshot version, e.g. 1-SNAPSHOT



          Each module will use something like:



          <project>
          <artifactId>A</artifactId>
          <version>1-SNAPSHOT</version>


          And refer to A and B like this in other modules:



          <dependency>
          <groupId>com.yourcompany</groupId>
          <artifactId>A</artifactId>
          <version>${project.version}</version>
          </dependency>


          To set a non-SNAPSHOT version before you build a release, you can for example use the maven-dependency-plugin's versions:set goal.






          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',
            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%2f53200029%2fshould-you-include-those-dependencies-in-your-pom-that-are-already-the-dependenc%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            If your module uses APIs from B it's best practice to add it explicitly to your pom, even though it's not strictly necessary. If you upgrade A, it could well be that it doesn't use B anymore and then you'll get a build failure without any changes to your module code.



            Regarding versions, you should manage those with dependencyManagement in a parent pom. You can then skip the version for the managed dependencies in the child poms. The version in the dependencyManagement overrides the version in transitive dependencies, ensuring you use the same version everywhere.



            If all modules are in the same project, they should also share the same project version. Typically, this will be a snapshot version, e.g. 1-SNAPSHOT



            Each module will use something like:



            <project>
            <artifactId>A</artifactId>
            <version>1-SNAPSHOT</version>


            And refer to A and B like this in other modules:



            <dependency>
            <groupId>com.yourcompany</groupId>
            <artifactId>A</artifactId>
            <version>${project.version}</version>
            </dependency>


            To set a non-SNAPSHOT version before you build a release, you can for example use the maven-dependency-plugin's versions:set goal.






            share|improve this answer

























              up vote
              3
              down vote













              If your module uses APIs from B it's best practice to add it explicitly to your pom, even though it's not strictly necessary. If you upgrade A, it could well be that it doesn't use B anymore and then you'll get a build failure without any changes to your module code.



              Regarding versions, you should manage those with dependencyManagement in a parent pom. You can then skip the version for the managed dependencies in the child poms. The version in the dependencyManagement overrides the version in transitive dependencies, ensuring you use the same version everywhere.



              If all modules are in the same project, they should also share the same project version. Typically, this will be a snapshot version, e.g. 1-SNAPSHOT



              Each module will use something like:



              <project>
              <artifactId>A</artifactId>
              <version>1-SNAPSHOT</version>


              And refer to A and B like this in other modules:



              <dependency>
              <groupId>com.yourcompany</groupId>
              <artifactId>A</artifactId>
              <version>${project.version}</version>
              </dependency>


              To set a non-SNAPSHOT version before you build a release, you can for example use the maven-dependency-plugin's versions:set goal.






              share|improve this answer























                up vote
                3
                down vote










                up vote
                3
                down vote









                If your module uses APIs from B it's best practice to add it explicitly to your pom, even though it's not strictly necessary. If you upgrade A, it could well be that it doesn't use B anymore and then you'll get a build failure without any changes to your module code.



                Regarding versions, you should manage those with dependencyManagement in a parent pom. You can then skip the version for the managed dependencies in the child poms. The version in the dependencyManagement overrides the version in transitive dependencies, ensuring you use the same version everywhere.



                If all modules are in the same project, they should also share the same project version. Typically, this will be a snapshot version, e.g. 1-SNAPSHOT



                Each module will use something like:



                <project>
                <artifactId>A</artifactId>
                <version>1-SNAPSHOT</version>


                And refer to A and B like this in other modules:



                <dependency>
                <groupId>com.yourcompany</groupId>
                <artifactId>A</artifactId>
                <version>${project.version}</version>
                </dependency>


                To set a non-SNAPSHOT version before you build a release, you can for example use the maven-dependency-plugin's versions:set goal.






                share|improve this answer












                If your module uses APIs from B it's best practice to add it explicitly to your pom, even though it's not strictly necessary. If you upgrade A, it could well be that it doesn't use B anymore and then you'll get a build failure without any changes to your module code.



                Regarding versions, you should manage those with dependencyManagement in a parent pom. You can then skip the version for the managed dependencies in the child poms. The version in the dependencyManagement overrides the version in transitive dependencies, ensuring you use the same version everywhere.



                If all modules are in the same project, they should also share the same project version. Typically, this will be a snapshot version, e.g. 1-SNAPSHOT



                Each module will use something like:



                <project>
                <artifactId>A</artifactId>
                <version>1-SNAPSHOT</version>


                And refer to A and B like this in other modules:



                <dependency>
                <groupId>com.yourcompany</groupId>
                <artifactId>A</artifactId>
                <version>${project.version}</version>
                </dependency>


                To set a non-SNAPSHOT version before you build a release, you can for example use the maven-dependency-plugin's versions:set goal.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 6 hours ago









                gjoranv

                1,2041518




                1,2041518






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53200029%2fshould-you-include-those-dependencies-in-your-pom-that-are-already-the-dependenc%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    Popular posts from this blog

                    Schultheiß

                    Liste der Kulturdenkmale in Wilsdruff

                    Android Play Services Check