Submit jar to MAVEN Central warehouse

Source: Internet
Author: User
Tags gpg maven central sonatype

Always download the jar from the central repository, this time you need to submit the jar to the central repository and use Sonatype OSSRH to submit the jar and other resources to MAVEN's central repository.

Sonatype OSSRH Introduction:

Sonatype OSSRH uses the Nexus to provide warehouse management services for open source projects, the so-called Maven central repository, OSSRH allows us to submit binaries to the MAVEN central repository.

1: Submit (deploy) The development version of the binaries (snapshorts)

2: Staged release

3: Release a release, then sync them to the central warehouse.

Initial stage

1: Register a Jira account: Https://issues.sonatype.org/secure/Signup!default.jspa

2: Create a new project for the single: https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134

The jar package can only be submitted when I resolved the status of this Jira single

Review requirements

1: Provide Javadoc and source

2: Use GPG or PGP to sign a file

3:pom.xml file

4: The correct coordinates: groupid,artifactid,version

   <groupId>com.sequoiadb</groupId>   <artifactId>sequoiadb-driver</artifactId>   <version>1.12</version>

5:projectname,description,url and so on.

   <name>${project.groupId}:${project.artifactId}</name>   <description>sequoiadb Driver Library</description>   <url>https://github.com/SequoiaDB/SequoiaDB</url>

6:license Information

<licenses>     <license>       <name>the Apache license, Version 2.0</name>       <url> http://www.apache.org/licenses/license-2.0.txt</url>     </license>   </licenses>

7: Developer Information

   <developers>    <developer>      <name>linyoubing</name>      <email>[email protected]</email>      <organization>sequoiadb</organization>      <organizationUrl> http://www.sequoiadb.com</organizationurl>    </developer>  </developers>

8:SCM Information

   <scm>      <connection>         scm:git:https://github.com/sequoiadb/sequoiadb.git      </ connection>      <developerConnection>         scm:git:https://github.com/sequoiadb/sequoiadb.git      </developerConnection>      <url>https://github.com/SequoiaDB/SequoiaDB</url>     <tag >v1.12</tag>  </scm>

Deployment

Can be deployed in a variety of ways, which is the way to use Maven

1: Distribution Management and Certification:

I used the MAVEN deployment plugin, so Pom.xml added:

<distributionManagement>  <snapshotRepository>    <id>ossrh</id>    <url> https://oss.sonatype.org/content/repositories/snapshots</url>  </snapshotRepository>  < repository>    <id>ossrh</id>    <url>https://oss.sonatype.org/service/local/staging/ Deploy/maven2/</url>  </repository></distributionManagement>

Need to configure Jira's account and password in Maven_home/conf/settings.xml

<settings>  <servers>    <server>      <id>ossrh</id>      <username >your-jira-id</username>      <password>your-jira-pwd</password>    </server>  </servers></settings>

2: Configure plugins to generate Javadoc and sources packages:

<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>    </plugin>

3:GPG automatically signed plugins:

    <plugin>      <groupId>org.apache.maven.plugins</groupId>      <artifactId> maven-gpg-plugin</artifactid>      <version>1.5</version>      <executions>        < execution>          <id>sign-artifacts</id>          <phase>verify</phase>          <goals>            <goal>sign</goal>          </goals>        </execution>      </executions>    </plugin>

Configuring GPG signatures in Settings.xml: (need to be generated first with GPG)

<settings>  <profiles>    <profile>      <id>ossrh</id>      <activation >        <activeByDefault>true</activeByDefault>      </activation>      <properties>        <gpg.executable>gpg2</gpg.executable>        <gpg.passphrase>the_pass_phrase</ gpg.passphrase>      </properties>    </profile>  </profiles></settings>

4: Using Profile

It should be javadoc and source jar package generation also need to use GPG to sign, so it is a waste of time, and these executions are usually independent of the standard build process, so move them to a profile.

      <profiles> <profile> <id>release</id> <build> <plugins> <plugin> <groupId>org.sonatype.plugins</groupId> <artifactid>nexus- Staging-maven-plugin</artifactid> <version>1.6.3</version> <extensions&gt                 ;true</extensions> <configuration> <serverId>ossrh</serverId> <nexusUrl>https://oss.sonatype.org/</nexusUrl> <autoReleaseAfterClose>true<                 /autoreleaseafterclose> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactid>maven-release-plugi                   N</artifactid> <version>2.5</version> <configuration> <autoversionsubModules>true</autoversionsubmodules> <useReleaseProfile>false</useReleaseProfile> <releaseProfiles>release</releaseProfiles> <goals>deploy</goals&gt                 ; </configuration> </plugin> <plugin> <groupid>org.apache.maven .plugins</groupid> <artifactId>maven-compiler-plugin</artifactId> <vers                    Ion>3.0</version> <configuration> <source>1.6</source>            <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactid>maven                -gpg-plugin</artifactid> <version>1.5</version> <executions> <execution> <id>sign-artifacts</id> &LT;PHASE&GT;VERIFY&LT;/PHASE&G                   T <goals> <goal>sign</goal> </goals> </exec ution> </executions> </plugin> <plugin> <groupi                D>org.apache.maven.plugins</groupid> <artifactId>maven-source-plugin</artifactId>                        <version>2.2.1</version> <executions> <execution> <id>attach-sources</id> <goals> &L                T;goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.apache.mave N.pLugins</groupid> <artifactId>maven-javadoc-plugin</artifactId> <version >2.9</version> <executions> <execution> < Id>attach-javadocs</id> <goals> <goal>jar</goal&                        Gt         </goals> </execution> </executions> </plugin> </plugins> </build> </profile></profiles>

Submit a Snapshot version:

1: Modify version plus a-snapshot, execute MVN clean deploy

Release a release version

1: Modify version do not add-snapshot, can be manually modified, can also be executed

mvn versions:set -DnewVersion=1.2.3

2: Execute mvn clean deploy-p release

Original: Submit jar to MAVEN Central warehouse

Related:

Upload Android or Java library to maven central repository

Publish maven artifacts to a central warehouse

Submit jar to MAVEN Central warehouse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.