"Mad little White" How to publish a Java project to Maven

Source: Internet
Author: User
Tags gpg sonatype

Publish a Java project to Maven

How to publish Maven operations through Sonatype, and be able to search in http://search.maven.org
Key steps:
1. Apply for OSS account
2. Create a key with GPG
3. Perfecting Setting.xml and Pom.xml
4. Release audits

A. Apply for Sonatype account
    1. Registered Address: Https://issues.sonatype.org/secure/Signup!default.jspa

B. Create issue
  1. Create address: Https://issues.sonatype.org/secure/Dashboard.jspa, click Create Issue

  2. Select New Project under Community support-open Source

  3. Fill in the Group Id , Project url , SCM url (SVN or git address ) Information

C. Awaiting approval
    1. When found someone replied to the Configuration have been prepared, now can , stating that the audit passed

    2. There are important things to keep in mind

    • Snapshotrepository

    • Repository

configuration has been prepared, now you can:#  Snapshotrepository: This address will be used in the snapshotrepository urldeploy snapshot  of distributionmanagement in Pom.xml artifacts into repository https://oss.sonatype.org/content/repositories/snapshots#  Repository: This address will be used in the repository Urldeploy release artifacts into of distributionmanagement in Pom.xml  the staging repository https://oss.sonatype.org/service/local/staging/deploy/maven2     Promote staged artifacts into repository  ' releases ' download  snapshot and release artifacts from group https://oss.sonatype.org/content/ Groups/publicdownload snapshot, release and staged artifacts from staging  group https://oss.sonatype.org/content/groups/stagingplease comment on this  Ticket when you promoted your firsT release, thanks 
D. Creating a public key private key
    1. If you need to install Cygwin under Windows, but for one step, download git bash directly, this git bash is cypwin integrated git

    2. It doesn't have to be under Linux, and it 's usually gpg ordered.

# Create a public key, when created, will prompt to fill in the account and mailbox GPG--gen-key# View the existing public key private key GPG--list-keys# find their own private key to create an account pub2048r/public key content 2014-05-28 uidusername<[ Email protected]>sub2048r/private key content 2014-05-28# release public key GPG--keyserver hkp://pool.sks-keyservers.net--send-keys Public key content
E. Modifying settings.xml
  1. settings.xml is a MAVEN configuration file that can be found in these two ways

  2. The global configuration $MAVEN_HOME/conf/settings.xml is found in, where Maven is installed

  3. The user's configuration is found in the user directory ~/.m2/settings.xml , such as C:/Users/用户名/.m2/settings.xml , of course, it is possible that the file does not exist, then you can copy the global configuration here

serversAdd an Account

<servers>...<server><id>oss</id> <username> accounts </username> <password> ; password </password></server></servers>
F. Modifying Pom.xml

for description , licenses , &NBSP; developers &NBSP; , and profiles

<description>Validation Framework for Java Development</description>< licenses><license><name>mit</name><url>http://mit-license.org/</url></ license></licenses><developers><developer><name> name </name><email> Email </ email></developer></developers><scm><connection>scm:[email protected]:41zone/ validation.fo.git</connection><developerconnection>scm:[email protected]:41zone/ validation.fo.git</developerconnection><url>[email protected]:41zone/validation.fo.git</ Url></scm><profiles><profile><id>release</id><distributionmanagement> <!--  After the initial approval, will give you this content, which has been given in the above  --><snapshotRepository><id>oss</id><url> https://oss.sonatype.org/content/repositories/snapshots/</url></snapshotrepository><!--  After the initial audit, will give you this content, in the above has given the  --><repository><id>oss</id><url>https://oss.sonatype.org/service/local/staging/deploy/maven2/ </url></repository></distributionManagement><build><plugins><!-- source  --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId> Maven-source-plugin</artifactid><version>2.2.1</version><executions><execution> <phase>package</phase><goals><goal>jar-no-fork</goal></goals></ execution></executions></plugin><!-- Javadoc --><plugin><groupId> Org.apache.maven.plugins</groupid><artifactid>maven-javadoc-plugin</artifactid><version >2.9.1</version><executions><execution><phase>package</phase><goals> <goal>jar</goal></goals></execution></executions></plugin><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></ Plugins></build></profile></profiles>
G. Publishing to OSS

If execution through eclipse may be problematic, you can do so from the command line

MVN clean deploy-p release-dgpg.passphrease= Public key content
H. Release build
  1. Enter https://oss.sonatype.org/, this load will be slow

  2. Left click Staging repositories

  3. Will find a &NBSP; groupid-xxxx &NBSP; formatted records, such as &NBSP; Code style= "Padding:.2em 0px;margin:0px;font-size:14px;" >ccfozonevalidation-1000 , When selected, select &NBSP; close

  4. Wait a moment for the refresh if the   below; summary &NBSP;     appears &NBSP; Red &NBSP; identification, indicating error, click Next to     to view &NBSP; Red &NBSP; content identified

  5. Follow the steps in the G -step process until the Green flag is successful Activity

  6. At this point, Select the Release above, make the official release

J. Final Audit
    1. After the successful release, enter the issue created before, add comment, said has succeeded, can write My Project has been successfully released.

    2. Once the audit is successful, you can search our framework in http://search.maven.org.

    3. Of course, you can preview and retrieve your components in Oss, https://oss.sonatype.org/content/groups/public

"Mad little White" How to publish a Java project to Maven

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.