Maven cannot resolve dependency for module in same multi-module project












36















When running commands such as



mvn dependency:build-classpath


or



mvn exec:java


Maven is unable to resolve a dependency of one of my modules on another.




[ERROR] Failed to execute goal on project parser-app: Could not resolve dependencies for project project_group:A:jar:0.1-SNAPSHOT: Could not find artifact project_group:B:jar:0.1-SNAPSHOT




The project structure is as follows:



/pom.xml
/A/pom.xml
/B/pom.xml


The parent pom is as follows:



<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project_group</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>0.1-SNAPSHOT</version>
<name>parent</name>

<modules>
<module>A</module>
<module>B</module>
</modules>


The first child module (the one failing to resolve the dependency):



    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>A</artifactId>
<packaging>jar</packaging>
<name>A</name>

<dependencies>
<dependency>
<groupId>parent_group</groupId>
<artifactId>B</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>


The second child module (the dependency):



  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>B</artifactId>
<packaging>jar</packaging>
<name>B</name>









share|improve this question

























  • try interchanging the build structure, I mean rewrite your pom.xml to have <module>B</module> <module>A</module>. classes in module A needs classes from module B, then B has to be built first

    – Saurabh Jhunjhunwala
    Apr 18 '15 at 4:29






  • 1





    no change, as far as I knew the reactor should work out the order from the dependencies

    – Benjamin George Roberts
    Apr 18 '15 at 5:09











  • Correct the reactor should handle the order of building. No manuall handling needed nor should it be done.

    – khmarbaise
    Apr 18 '15 at 12:34











  • Possible duplicate of Maven doesn't recognize sibling modules when running mvn dependency:tree

    – sschuberth
    May 5 '17 at 15:18
















36















When running commands such as



mvn dependency:build-classpath


or



mvn exec:java


Maven is unable to resolve a dependency of one of my modules on another.




[ERROR] Failed to execute goal on project parser-app: Could not resolve dependencies for project project_group:A:jar:0.1-SNAPSHOT: Could not find artifact project_group:B:jar:0.1-SNAPSHOT




The project structure is as follows:



/pom.xml
/A/pom.xml
/B/pom.xml


The parent pom is as follows:



<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project_group</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>0.1-SNAPSHOT</version>
<name>parent</name>

<modules>
<module>A</module>
<module>B</module>
</modules>


The first child module (the one failing to resolve the dependency):



    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>A</artifactId>
<packaging>jar</packaging>
<name>A</name>

<dependencies>
<dependency>
<groupId>parent_group</groupId>
<artifactId>B</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>


The second child module (the dependency):



  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>B</artifactId>
<packaging>jar</packaging>
<name>B</name>









share|improve this question

























  • try interchanging the build structure, I mean rewrite your pom.xml to have <module>B</module> <module>A</module>. classes in module A needs classes from module B, then B has to be built first

    – Saurabh Jhunjhunwala
    Apr 18 '15 at 4:29






  • 1





    no change, as far as I knew the reactor should work out the order from the dependencies

    – Benjamin George Roberts
    Apr 18 '15 at 5:09











  • Correct the reactor should handle the order of building. No manuall handling needed nor should it be done.

    – khmarbaise
    Apr 18 '15 at 12:34











  • Possible duplicate of Maven doesn't recognize sibling modules when running mvn dependency:tree

    – sschuberth
    May 5 '17 at 15:18














36












36








36


7






When running commands such as



mvn dependency:build-classpath


or



mvn exec:java


Maven is unable to resolve a dependency of one of my modules on another.




[ERROR] Failed to execute goal on project parser-app: Could not resolve dependencies for project project_group:A:jar:0.1-SNAPSHOT: Could not find artifact project_group:B:jar:0.1-SNAPSHOT




The project structure is as follows:



/pom.xml
/A/pom.xml
/B/pom.xml


The parent pom is as follows:



<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project_group</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>0.1-SNAPSHOT</version>
<name>parent</name>

<modules>
<module>A</module>
<module>B</module>
</modules>


The first child module (the one failing to resolve the dependency):



    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>A</artifactId>
<packaging>jar</packaging>
<name>A</name>

<dependencies>
<dependency>
<groupId>parent_group</groupId>
<artifactId>B</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>


The second child module (the dependency):



  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>B</artifactId>
<packaging>jar</packaging>
<name>B</name>









share|improve this question
















When running commands such as



mvn dependency:build-classpath


or



mvn exec:java


Maven is unable to resolve a dependency of one of my modules on another.




[ERROR] Failed to execute goal on project parser-app: Could not resolve dependencies for project project_group:A:jar:0.1-SNAPSHOT: Could not find artifact project_group:B:jar:0.1-SNAPSHOT




The project structure is as follows:



/pom.xml
/A/pom.xml
/B/pom.xml


The parent pom is as follows:



<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>project_group</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>0.1-SNAPSHOT</version>
<name>parent</name>

<modules>
<module>A</module>
<module>B</module>
</modules>


The first child module (the one failing to resolve the dependency):



    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>A</artifactId>
<packaging>jar</packaging>
<name>A</name>

<dependencies>
<dependency>
<groupId>parent_group</groupId>
<artifactId>B</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>


The second child module (the dependency):



  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent_group</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>B</artifactId>
<packaging>jar</packaging>
<name>B</name>






java maven jar classpath pom.xml






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 11 '17 at 15:10









Beryllium

10.8k84071




10.8k84071










asked Apr 18 '15 at 4:26









Benjamin George RobertsBenjamin George Roberts

3551311




3551311













  • try interchanging the build structure, I mean rewrite your pom.xml to have <module>B</module> <module>A</module>. classes in module A needs classes from module B, then B has to be built first

    – Saurabh Jhunjhunwala
    Apr 18 '15 at 4:29






  • 1





    no change, as far as I knew the reactor should work out the order from the dependencies

    – Benjamin George Roberts
    Apr 18 '15 at 5:09











  • Correct the reactor should handle the order of building. No manuall handling needed nor should it be done.

    – khmarbaise
    Apr 18 '15 at 12:34











  • Possible duplicate of Maven doesn't recognize sibling modules when running mvn dependency:tree

    – sschuberth
    May 5 '17 at 15:18



















  • try interchanging the build structure, I mean rewrite your pom.xml to have <module>B</module> <module>A</module>. classes in module A needs classes from module B, then B has to be built first

    – Saurabh Jhunjhunwala
    Apr 18 '15 at 4:29






  • 1





    no change, as far as I knew the reactor should work out the order from the dependencies

    – Benjamin George Roberts
    Apr 18 '15 at 5:09











  • Correct the reactor should handle the order of building. No manuall handling needed nor should it be done.

    – khmarbaise
    Apr 18 '15 at 12:34











  • Possible duplicate of Maven doesn't recognize sibling modules when running mvn dependency:tree

    – sschuberth
    May 5 '17 at 15:18

















try interchanging the build structure, I mean rewrite your pom.xml to have <module>B</module> <module>A</module>. classes in module A needs classes from module B, then B has to be built first

– Saurabh Jhunjhunwala
Apr 18 '15 at 4:29





try interchanging the build structure, I mean rewrite your pom.xml to have <module>B</module> <module>A</module>. classes in module A needs classes from module B, then B has to be built first

– Saurabh Jhunjhunwala
Apr 18 '15 at 4:29




1




1





no change, as far as I knew the reactor should work out the order from the dependencies

– Benjamin George Roberts
Apr 18 '15 at 5:09





no change, as far as I knew the reactor should work out the order from the dependencies

– Benjamin George Roberts
Apr 18 '15 at 5:09













Correct the reactor should handle the order of building. No manuall handling needed nor should it be done.

– khmarbaise
Apr 18 '15 at 12:34





Correct the reactor should handle the order of building. No manuall handling needed nor should it be done.

– khmarbaise
Apr 18 '15 at 12:34













Possible duplicate of Maven doesn't recognize sibling modules when running mvn dependency:tree

– sschuberth
May 5 '17 at 15:18





Possible duplicate of Maven doesn't recognize sibling modules when running mvn dependency:tree

– sschuberth
May 5 '17 at 15:18












2 Answers
2






active

oldest

votes


















41














Have you run mvn clean install at least once on the project to install the dependencies within your local repository?






share|improve this answer





















  • 1





    That worked. This means I'd need to run install every time I update the dependant module right? I assumed there was a way for it to use most recently built copy (ie root/B/target/B-0.1-SNAPSHOT.jar)

    – Benjamin George Roberts
    Apr 19 '15 at 3:01











  • I think what you are looking for then is: stackoverflow.com/questions/4367665/… Most of the methods to do this are less well documented however as maven relies on the dependency model whereby your dependencies are installed within the local repository

    – Andrew McKee
    Apr 19 '15 at 10:03








  • 1





    I can mvn package and have the packages build against each other, however I assumed other actions (like generating the classpath or executing) would also use the most recently built packages, not whichever I installed to my local repository last. I'm guessing this might just be a compromise I have to live with?

    – Benjamin George Roberts
    Apr 19 '15 at 10:11






  • 8





    To me, it's ridiculous that maven would need to look in the local repository for submodules! Seriously? What a hack.

    – Chad
    Aug 31 '17 at 20:31






  • 1





    Sad to see if I have to install it to the local repo for depedency:tree! My module is still under development, installing them to local repo might cause some issue.

    – Albert Zhong
    Oct 13 '17 at 9:11



















14














The Maven reactor is weird that way, it keeps modules around only for certain tasks. When running a build target that only does something for one subproject, then even if Maven builds dependencies first, it does not keep them around in the reactor (sometimes).



Installing to the local repository is a workaround, but it is horrible and should be avoided when possible, because you can easily end up with outdated build results.



A slightly less ugly workaround is to combine two build targets, where the second build target does something harmless, but triggers addition to reactor in all subprojects.



As an example you can combine the task you want with the 'compile' or 'package' tasks.



Also see highest voted answer at
Maven doesn't recognize sibling modules when running mvn dependency:tree






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%2f29712865%2fmaven-cannot-resolve-dependency-for-module-in-same-multi-module-project%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









    41














    Have you run mvn clean install at least once on the project to install the dependencies within your local repository?






    share|improve this answer





















    • 1





      That worked. This means I'd need to run install every time I update the dependant module right? I assumed there was a way for it to use most recently built copy (ie root/B/target/B-0.1-SNAPSHOT.jar)

      – Benjamin George Roberts
      Apr 19 '15 at 3:01











    • I think what you are looking for then is: stackoverflow.com/questions/4367665/… Most of the methods to do this are less well documented however as maven relies on the dependency model whereby your dependencies are installed within the local repository

      – Andrew McKee
      Apr 19 '15 at 10:03








    • 1





      I can mvn package and have the packages build against each other, however I assumed other actions (like generating the classpath or executing) would also use the most recently built packages, not whichever I installed to my local repository last. I'm guessing this might just be a compromise I have to live with?

      – Benjamin George Roberts
      Apr 19 '15 at 10:11






    • 8





      To me, it's ridiculous that maven would need to look in the local repository for submodules! Seriously? What a hack.

      – Chad
      Aug 31 '17 at 20:31






    • 1





      Sad to see if I have to install it to the local repo for depedency:tree! My module is still under development, installing them to local repo might cause some issue.

      – Albert Zhong
      Oct 13 '17 at 9:11
















    41














    Have you run mvn clean install at least once on the project to install the dependencies within your local repository?






    share|improve this answer





















    • 1





      That worked. This means I'd need to run install every time I update the dependant module right? I assumed there was a way for it to use most recently built copy (ie root/B/target/B-0.1-SNAPSHOT.jar)

      – Benjamin George Roberts
      Apr 19 '15 at 3:01











    • I think what you are looking for then is: stackoverflow.com/questions/4367665/… Most of the methods to do this are less well documented however as maven relies on the dependency model whereby your dependencies are installed within the local repository

      – Andrew McKee
      Apr 19 '15 at 10:03








    • 1





      I can mvn package and have the packages build against each other, however I assumed other actions (like generating the classpath or executing) would also use the most recently built packages, not whichever I installed to my local repository last. I'm guessing this might just be a compromise I have to live with?

      – Benjamin George Roberts
      Apr 19 '15 at 10:11






    • 8





      To me, it's ridiculous that maven would need to look in the local repository for submodules! Seriously? What a hack.

      – Chad
      Aug 31 '17 at 20:31






    • 1





      Sad to see if I have to install it to the local repo for depedency:tree! My module is still under development, installing them to local repo might cause some issue.

      – Albert Zhong
      Oct 13 '17 at 9:11














    41












    41








    41







    Have you run mvn clean install at least once on the project to install the dependencies within your local repository?






    share|improve this answer















    Have you run mvn clean install at least once on the project to install the dependencies within your local repository?







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 11 '17 at 15:14









    Beryllium

    10.8k84071




    10.8k84071










    answered Apr 18 '15 at 9:16









    Andrew McKeeAndrew McKee

    63464




    63464








    • 1





      That worked. This means I'd need to run install every time I update the dependant module right? I assumed there was a way for it to use most recently built copy (ie root/B/target/B-0.1-SNAPSHOT.jar)

      – Benjamin George Roberts
      Apr 19 '15 at 3:01











    • I think what you are looking for then is: stackoverflow.com/questions/4367665/… Most of the methods to do this are less well documented however as maven relies on the dependency model whereby your dependencies are installed within the local repository

      – Andrew McKee
      Apr 19 '15 at 10:03








    • 1





      I can mvn package and have the packages build against each other, however I assumed other actions (like generating the classpath or executing) would also use the most recently built packages, not whichever I installed to my local repository last. I'm guessing this might just be a compromise I have to live with?

      – Benjamin George Roberts
      Apr 19 '15 at 10:11






    • 8





      To me, it's ridiculous that maven would need to look in the local repository for submodules! Seriously? What a hack.

      – Chad
      Aug 31 '17 at 20:31






    • 1





      Sad to see if I have to install it to the local repo for depedency:tree! My module is still under development, installing them to local repo might cause some issue.

      – Albert Zhong
      Oct 13 '17 at 9:11














    • 1





      That worked. This means I'd need to run install every time I update the dependant module right? I assumed there was a way for it to use most recently built copy (ie root/B/target/B-0.1-SNAPSHOT.jar)

      – Benjamin George Roberts
      Apr 19 '15 at 3:01











    • I think what you are looking for then is: stackoverflow.com/questions/4367665/… Most of the methods to do this are less well documented however as maven relies on the dependency model whereby your dependencies are installed within the local repository

      – Andrew McKee
      Apr 19 '15 at 10:03








    • 1





      I can mvn package and have the packages build against each other, however I assumed other actions (like generating the classpath or executing) would also use the most recently built packages, not whichever I installed to my local repository last. I'm guessing this might just be a compromise I have to live with?

      – Benjamin George Roberts
      Apr 19 '15 at 10:11






    • 8





      To me, it's ridiculous that maven would need to look in the local repository for submodules! Seriously? What a hack.

      – Chad
      Aug 31 '17 at 20:31






    • 1





      Sad to see if I have to install it to the local repo for depedency:tree! My module is still under development, installing them to local repo might cause some issue.

      – Albert Zhong
      Oct 13 '17 at 9:11








    1




    1





    That worked. This means I'd need to run install every time I update the dependant module right? I assumed there was a way for it to use most recently built copy (ie root/B/target/B-0.1-SNAPSHOT.jar)

    – Benjamin George Roberts
    Apr 19 '15 at 3:01





    That worked. This means I'd need to run install every time I update the dependant module right? I assumed there was a way for it to use most recently built copy (ie root/B/target/B-0.1-SNAPSHOT.jar)

    – Benjamin George Roberts
    Apr 19 '15 at 3:01













    I think what you are looking for then is: stackoverflow.com/questions/4367665/… Most of the methods to do this are less well documented however as maven relies on the dependency model whereby your dependencies are installed within the local repository

    – Andrew McKee
    Apr 19 '15 at 10:03







    I think what you are looking for then is: stackoverflow.com/questions/4367665/… Most of the methods to do this are less well documented however as maven relies on the dependency model whereby your dependencies are installed within the local repository

    – Andrew McKee
    Apr 19 '15 at 10:03






    1




    1





    I can mvn package and have the packages build against each other, however I assumed other actions (like generating the classpath or executing) would also use the most recently built packages, not whichever I installed to my local repository last. I'm guessing this might just be a compromise I have to live with?

    – Benjamin George Roberts
    Apr 19 '15 at 10:11





    I can mvn package and have the packages build against each other, however I assumed other actions (like generating the classpath or executing) would also use the most recently built packages, not whichever I installed to my local repository last. I'm guessing this might just be a compromise I have to live with?

    – Benjamin George Roberts
    Apr 19 '15 at 10:11




    8




    8





    To me, it's ridiculous that maven would need to look in the local repository for submodules! Seriously? What a hack.

    – Chad
    Aug 31 '17 at 20:31





    To me, it's ridiculous that maven would need to look in the local repository for submodules! Seriously? What a hack.

    – Chad
    Aug 31 '17 at 20:31




    1




    1





    Sad to see if I have to install it to the local repo for depedency:tree! My module is still under development, installing them to local repo might cause some issue.

    – Albert Zhong
    Oct 13 '17 at 9:11





    Sad to see if I have to install it to the local repo for depedency:tree! My module is still under development, installing them to local repo might cause some issue.

    – Albert Zhong
    Oct 13 '17 at 9:11













    14














    The Maven reactor is weird that way, it keeps modules around only for certain tasks. When running a build target that only does something for one subproject, then even if Maven builds dependencies first, it does not keep them around in the reactor (sometimes).



    Installing to the local repository is a workaround, but it is horrible and should be avoided when possible, because you can easily end up with outdated build results.



    A slightly less ugly workaround is to combine two build targets, where the second build target does something harmless, but triggers addition to reactor in all subprojects.



    As an example you can combine the task you want with the 'compile' or 'package' tasks.



    Also see highest voted answer at
    Maven doesn't recognize sibling modules when running mvn dependency:tree






    share|improve this answer






























      14














      The Maven reactor is weird that way, it keeps modules around only for certain tasks. When running a build target that only does something for one subproject, then even if Maven builds dependencies first, it does not keep them around in the reactor (sometimes).



      Installing to the local repository is a workaround, but it is horrible and should be avoided when possible, because you can easily end up with outdated build results.



      A slightly less ugly workaround is to combine two build targets, where the second build target does something harmless, but triggers addition to reactor in all subprojects.



      As an example you can combine the task you want with the 'compile' or 'package' tasks.



      Also see highest voted answer at
      Maven doesn't recognize sibling modules when running mvn dependency:tree






      share|improve this answer




























        14












        14








        14







        The Maven reactor is weird that way, it keeps modules around only for certain tasks. When running a build target that only does something for one subproject, then even if Maven builds dependencies first, it does not keep them around in the reactor (sometimes).



        Installing to the local repository is a workaround, but it is horrible and should be avoided when possible, because you can easily end up with outdated build results.



        A slightly less ugly workaround is to combine two build targets, where the second build target does something harmless, but triggers addition to reactor in all subprojects.



        As an example you can combine the task you want with the 'compile' or 'package' tasks.



        Also see highest voted answer at
        Maven doesn't recognize sibling modules when running mvn dependency:tree






        share|improve this answer















        The Maven reactor is weird that way, it keeps modules around only for certain tasks. When running a build target that only does something for one subproject, then even if Maven builds dependencies first, it does not keep them around in the reactor (sometimes).



        Installing to the local repository is a workaround, but it is horrible and should be avoided when possible, because you can easily end up with outdated build results.



        A slightly less ugly workaround is to combine two build targets, where the second build target does something harmless, but triggers addition to reactor in all subprojects.



        As an example you can combine the task you want with the 'compile' or 'package' tasks.



        Also see highest voted answer at
        Maven doesn't recognize sibling modules when running mvn dependency:tree







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 13 '18 at 0:56

























        answered Apr 4 '17 at 7:13









        tkrusetkruse

        4,38442947




        4,38442947






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29712865%2fmaven-cannot-resolve-dependency-for-module-in-same-multi-module-project%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

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'