Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
856 views
in Technique[技术] by (71.8m points)

maven - 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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...