How to deploy artifacts to Maven Central


Deploy via Build Server

The 52°North Build Server has been configured in a way that deployment works pretty easy. The whole sync process is done via Sonatype's Open Source Software Repository Hosting (OSSRH). The main parts are already configured, but you have to add some configuration to your pom.xml so that will work.

Build Server setup

pom.xml adjustments

  • remove the 52-North parent project as it is not deployed on a public repository (so you have to configure needed information by hand!)
  • declare entries (see example here)
    • OSSRH distributionManagement
    • description
    • issueManagement
    • organization
    • scm
    • url
    • licenses
    • developer
  • declare plugins in profile:
          <profile>
             <id>deploy-to-central</id>
             <build>
                <plugins>
                   <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-source-plugin</artifactId>
                     <version>2.2.1</version>
                     <executions>
                      <execution>
                        <id>attach-sources</id>
                        <goals>
                         <goal>jar-no-fork</goal>
                        </goals>
                      </execution>
                     </executions>
                   </plugin>
             
                   <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-javadoc-plugin</artifactId>
                     <version>2.9.1</version>
                     <executions>
                      <execution>
                        <id>attach-javadocs</id>
                        <goals>
                         <goal>jar</goal>
                        </goals>
                      </execution>
                     </executions>
                     <configuration>
                      <additionalJOption>-J-Xmx1024m</additionalJOption>
                     </configuration>
                   </plugin>
                            
                   <plugin>
                     <groupId>org.sonatype.plugins</groupId>
                     <artifactId>nexus-staging-maven-plugin</artifactId>
                     <version>1.6.2</version>
                     <extensions>true</extensions>
                     <configuration>
                       <serverId>ossrh</serverId>
                       <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                       <autoReleaseAfterClose>true</autoReleaseAfterClose>
                     </configuration>
                   </plugin>
                </plugins>
             </build>
             
          </profile>
    
  • please note that the guidelines say to include Javadoc. However, the commons-xml projects is a special case as it provides just compiled classes generated from xsd schemas. The generation of JavaDoc needs too much memory especially for big projects like gml or aixm (a gml profile). Even 1024m extra memory was not enough. If you run in the same memory problems you should first think of restructure your projects rather than exclude JavaDoc generation.
Topic revision: r2 - 31 Jul 2014, DanielNuest
Legal Notice | Privacy Statement


This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback