Warm tip: This article is reproduced from serverfault.com, please click

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

发布于 2021-01-11 12:22:53

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?

Questioner
rbednarska
Viewed
1
J Fabian Meier 2021-01-11 21:38:16

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.