Maven cannot resolve dependency because parent jar not found










0















I am starting a Maven project with inherited poms.



The parent pom of the project is like:



<artifactId>service-parent</artifactId>
<groupId>group.parent</groupId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>child-of-parent</module> ...
</modules>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
...
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>$junit.version</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>$commons-lang3.version</version>
</dependency>
...
</dependencies>
</dependencyManagement>


So in the child module, if I understand well, the dependencies in part will be inherited automatically, and those in the part will have to be declared in child's pom. And I write this in child's pom:



<parent>
<artifactId>service-parent</artifactId>
<groupId>group.parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>service-child</artifactId>
<groupId>group.child</groupId>
<packaging>pom</packaging>

<modules>
<module>child-of-child</module>
</modules>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>


This child module has its own children modules. The third-level pom is thus as blow:



<parent>
<artifactId>service-child</artifactId>
<groupId>group.child</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>service-child-child</artifactId>

<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
</dependency>
</dependencies>


It's a little wired like this as in the beginning of pom it already has tag which is the same thing as its dependency. That is because if I copy the dependencies in its parent there is a duplicate warning.
And when I run maven clean install, it says




Failed to execute goal on project service-child: Could not resolve dependencies for project service-parent:service-child:jar:1.0-SNAPSHOT:
The following artifacts could not be resolved:
group.child:service-child:jar:1.0-SNAPSHOT,
group.parent:service-parent:jar:1.0-SNAPSHOT: Could not find artifact
group.child:service-child:jar:1.0-SNAPSHOT




I know that it's an aggregation way instead of inheritance but I prefer this way in the future I would like to test and run module by module (I tried btw the inheritance way by removing the modules declaration in parent poms and it did work). Do you have any idea why this happen?










share|improve this question






















  • Please make a github project of it and so one can take a look ...

    – khmarbaise
    Nov 15 '18 at 16:52















0















I am starting a Maven project with inherited poms.



The parent pom of the project is like:



<artifactId>service-parent</artifactId>
<groupId>group.parent</groupId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>child-of-parent</module> ...
</modules>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
...
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>$junit.version</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>$commons-lang3.version</version>
</dependency>
...
</dependencies>
</dependencyManagement>


So in the child module, if I understand well, the dependencies in part will be inherited automatically, and those in the part will have to be declared in child's pom. And I write this in child's pom:



<parent>
<artifactId>service-parent</artifactId>
<groupId>group.parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>service-child</artifactId>
<groupId>group.child</groupId>
<packaging>pom</packaging>

<modules>
<module>child-of-child</module>
</modules>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>


This child module has its own children modules. The third-level pom is thus as blow:



<parent>
<artifactId>service-child</artifactId>
<groupId>group.child</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>service-child-child</artifactId>

<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
</dependency>
</dependencies>


It's a little wired like this as in the beginning of pom it already has tag which is the same thing as its dependency. That is because if I copy the dependencies in its parent there is a duplicate warning.
And when I run maven clean install, it says




Failed to execute goal on project service-child: Could not resolve dependencies for project service-parent:service-child:jar:1.0-SNAPSHOT:
The following artifacts could not be resolved:
group.child:service-child:jar:1.0-SNAPSHOT,
group.parent:service-parent:jar:1.0-SNAPSHOT: Could not find artifact
group.child:service-child:jar:1.0-SNAPSHOT




I know that it's an aggregation way instead of inheritance but I prefer this way in the future I would like to test and run module by module (I tried btw the inheritance way by removing the modules declaration in parent poms and it did work). Do you have any idea why this happen?










share|improve this question






















  • Please make a github project of it and so one can take a look ...

    – khmarbaise
    Nov 15 '18 at 16:52













0












0








0


0






I am starting a Maven project with inherited poms.



The parent pom of the project is like:



<artifactId>service-parent</artifactId>
<groupId>group.parent</groupId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>child-of-parent</module> ...
</modules>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
...
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>$junit.version</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>$commons-lang3.version</version>
</dependency>
...
</dependencies>
</dependencyManagement>


So in the child module, if I understand well, the dependencies in part will be inherited automatically, and those in the part will have to be declared in child's pom. And I write this in child's pom:



<parent>
<artifactId>service-parent</artifactId>
<groupId>group.parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>service-child</artifactId>
<groupId>group.child</groupId>
<packaging>pom</packaging>

<modules>
<module>child-of-child</module>
</modules>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>


This child module has its own children modules. The third-level pom is thus as blow:



<parent>
<artifactId>service-child</artifactId>
<groupId>group.child</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>service-child-child</artifactId>

<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
</dependency>
</dependencies>


It's a little wired like this as in the beginning of pom it already has tag which is the same thing as its dependency. That is because if I copy the dependencies in its parent there is a duplicate warning.
And when I run maven clean install, it says




Failed to execute goal on project service-child: Could not resolve dependencies for project service-parent:service-child:jar:1.0-SNAPSHOT:
The following artifacts could not be resolved:
group.child:service-child:jar:1.0-SNAPSHOT,
group.parent:service-parent:jar:1.0-SNAPSHOT: Could not find artifact
group.child:service-child:jar:1.0-SNAPSHOT




I know that it's an aggregation way instead of inheritance but I prefer this way in the future I would like to test and run module by module (I tried btw the inheritance way by removing the modules declaration in parent poms and it did work). Do you have any idea why this happen?










share|improve this question














I am starting a Maven project with inherited poms.



The parent pom of the project is like:



<artifactId>service-parent</artifactId>
<groupId>group.parent</groupId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>child-of-parent</module> ...
</modules>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
...
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>$junit.version</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>$commons-lang3.version</version>
</dependency>
...
</dependencies>
</dependencyManagement>


So in the child module, if I understand well, the dependencies in part will be inherited automatically, and those in the part will have to be declared in child's pom. And I write this in child's pom:



<parent>
<artifactId>service-parent</artifactId>
<groupId>group.parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>service-child</artifactId>
<groupId>group.child</groupId>
<packaging>pom</packaging>

<modules>
<module>child-of-child</module>
</modules>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>


This child module has its own children modules. The third-level pom is thus as blow:



<parent>
<artifactId>service-child</artifactId>
<groupId>group.child</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>service-child-child</artifactId>

<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
</dependency>
</dependencies>


It's a little wired like this as in the beginning of pom it already has tag which is the same thing as its dependency. That is because if I copy the dependencies in its parent there is a duplicate warning.
And when I run maven clean install, it says




Failed to execute goal on project service-child: Could not resolve dependencies for project service-parent:service-child:jar:1.0-SNAPSHOT:
The following artifacts could not be resolved:
group.child:service-child:jar:1.0-SNAPSHOT,
group.parent:service-parent:jar:1.0-SNAPSHOT: Could not find artifact
group.child:service-child:jar:1.0-SNAPSHOT




I know that it's an aggregation way instead of inheritance but I prefer this way in the future I would like to test and run module by module (I tried btw the inheritance way by removing the modules declaration in parent poms and it did work). Do you have any idea why this happen?







maven pom.xml dependency-management






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 23:07









TiTingTiTing

279




279












  • Please make a github project of it and so one can take a look ...

    – khmarbaise
    Nov 15 '18 at 16:52

















  • Please make a github project of it and so one can take a look ...

    – khmarbaise
    Nov 15 '18 at 16:52
















Please make a github project of it and so one can take a look ...

– khmarbaise
Nov 15 '18 at 16:52





Please make a github project of it and so one can take a look ...

– khmarbaise
Nov 15 '18 at 16:52












1 Answer
1






active

oldest

votes


















0














That's because the type (packaging) of service-child is pom and not jar.



It is not possible to have a project with jar packaging with submodules.



If you still need to declare that dependency, use the following declaration - note type element with pom value:



<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
<type>pom</type>
</dependency>
</dependencies>


That declaration does not bring any new dependencies since service-child-child inherits all dependencies from it's parent service-child already.



Check out Introduction to the POM - Project Inheritance for more information on inheritance and aggregation in Maven.






share|improve this answer

























  • jar would not work with the aggregation structure. I tried though and got this message The project group.parent:service-parent:1.0-SNAPSHOT has 1 error [ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

    – TiTing
    Nov 20 '18 at 17:11











  • Yes, that's correct. As I said in my answer "It is not possible to have a project with jar packaging with submodules." You should keep modules with jar packaging separate from modules with pom packaging.

    – Illya Kysil
    Nov 20 '18 at 17:23











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%2f53310087%2fmaven-cannot-resolve-dependency-because-parent-jar-not-found%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














That's because the type (packaging) of service-child is pom and not jar.



It is not possible to have a project with jar packaging with submodules.



If you still need to declare that dependency, use the following declaration - note type element with pom value:



<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
<type>pom</type>
</dependency>
</dependencies>


That declaration does not bring any new dependencies since service-child-child inherits all dependencies from it's parent service-child already.



Check out Introduction to the POM - Project Inheritance for more information on inheritance and aggregation in Maven.






share|improve this answer

























  • jar would not work with the aggregation structure. I tried though and got this message The project group.parent:service-parent:1.0-SNAPSHOT has 1 error [ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

    – TiTing
    Nov 20 '18 at 17:11











  • Yes, that's correct. As I said in my answer "It is not possible to have a project with jar packaging with submodules." You should keep modules with jar packaging separate from modules with pom packaging.

    – Illya Kysil
    Nov 20 '18 at 17:23
















0














That's because the type (packaging) of service-child is pom and not jar.



It is not possible to have a project with jar packaging with submodules.



If you still need to declare that dependency, use the following declaration - note type element with pom value:



<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
<type>pom</type>
</dependency>
</dependencies>


That declaration does not bring any new dependencies since service-child-child inherits all dependencies from it's parent service-child already.



Check out Introduction to the POM - Project Inheritance for more information on inheritance and aggregation in Maven.






share|improve this answer

























  • jar would not work with the aggregation structure. I tried though and got this message The project group.parent:service-parent:1.0-SNAPSHOT has 1 error [ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

    – TiTing
    Nov 20 '18 at 17:11











  • Yes, that's correct. As I said in my answer "It is not possible to have a project with jar packaging with submodules." You should keep modules with jar packaging separate from modules with pom packaging.

    – Illya Kysil
    Nov 20 '18 at 17:23














0












0








0







That's because the type (packaging) of service-child is pom and not jar.



It is not possible to have a project with jar packaging with submodules.



If you still need to declare that dependency, use the following declaration - note type element with pom value:



<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
<type>pom</type>
</dependency>
</dependencies>


That declaration does not bring any new dependencies since service-child-child inherits all dependencies from it's parent service-child already.



Check out Introduction to the POM - Project Inheritance for more information on inheritance and aggregation in Maven.






share|improve this answer















That's because the type (packaging) of service-child is pom and not jar.



It is not possible to have a project with jar packaging with submodules.



If you still need to declare that dependency, use the following declaration - note type element with pom value:



<dependencies>
<dependency>
<groupId>$project.groupId</groupId>
<artifactId>service-child</artifactId>
<version>$project.version</version>
<type>pom</type>
</dependency>
</dependencies>


That declaration does not bring any new dependencies since service-child-child inherits all dependencies from it's parent service-child already.



Check out Introduction to the POM - Project Inheritance for more information on inheritance and aggregation in Maven.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 23:45

























answered Nov 15 '18 at 23:35









Illya KysilIllya Kysil

713411




713411












  • jar would not work with the aggregation structure. I tried though and got this message The project group.parent:service-parent:1.0-SNAPSHOT has 1 error [ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

    – TiTing
    Nov 20 '18 at 17:11











  • Yes, that's correct. As I said in my answer "It is not possible to have a project with jar packaging with submodules." You should keep modules with jar packaging separate from modules with pom packaging.

    – Illya Kysil
    Nov 20 '18 at 17:23


















  • jar would not work with the aggregation structure. I tried though and got this message The project group.parent:service-parent:1.0-SNAPSHOT has 1 error [ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

    – TiTing
    Nov 20 '18 at 17:11











  • Yes, that's correct. As I said in my answer "It is not possible to have a project with jar packaging with submodules." You should keep modules with jar packaging separate from modules with pom packaging.

    – Illya Kysil
    Nov 20 '18 at 17:23

















jar would not work with the aggregation structure. I tried though and got this message The project group.parent:service-parent:1.0-SNAPSHOT has 1 error [ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

– TiTing
Nov 20 '18 at 17:11





jar would not work with the aggregation structure. I tried though and got this message The project group.parent:service-parent:1.0-SNAPSHOT has 1 error [ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

– TiTing
Nov 20 '18 at 17:11













Yes, that's correct. As I said in my answer "It is not possible to have a project with jar packaging with submodules." You should keep modules with jar packaging separate from modules with pom packaging.

– Illya Kysil
Nov 20 '18 at 17:23






Yes, that's correct. As I said in my answer "It is not possible to have a project with jar packaging with submodules." You should keep modules with jar packaging separate from modules with pom packaging.

– Illya Kysil
Nov 20 '18 at 17:23




















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%2f53310087%2fmaven-cannot-resolve-dependency-because-parent-jar-not-found%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

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo