'How to correctly deploy artifact to nexus when it has parent pom?

I have a problem with deployment my artifact to nexus. I am using maven and nexus-staging-maven-plugin from sonatype. My project structure is: parent A with 2 child modules B and C. In pom.xml of B I have declared plugin like below (and of course repository etc):

   <plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>1.5.1</version>
    <executions>
      <execution>
        <id>default-deploy</id>
        <phase>deploy</phase>
        <goals>
          <goal>deploy</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <nexusUrl>http://nexus.intranet:8081/repository/myrepo/</nexusUrl>
      <serverId>nexus</serverId>
      <skipStaging>true</skipStaging>
    </configuration>
  </plugin>

My artifact is deploying to nexus correctly to folder com/myorg/B/1.1.5/ and there is jar present and B's pom.xml and sha files. Problem is that when I am adding to another project dependency B than this project is trying to find in nexus A (parent pom of B). Should I deploy the parent pom.xml to my nexus too? How should I configure my plugin in B pom.xml to do it correctly?



Solution 1:[1]

You must always deploy all parent POMs as well because without a parent POM, the POMs cannot be read by Maven.

So in a multi-module-project you should deploy all the modules including the parent to the same place.

Solution 2:[2]

I already solved my problem. The answer is yes - if you want to use child module as dependency somewhere you need to have it's parent pom in repository too. I solved problem by adding to my parent pom staging plugin from sonatype to make possible deploying parent pom to nexus too. Than build was successful and now I can use my child artifact (named B in my question) as dependency in another project.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 J Fabian Meier
Solution 2 rbednarska