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
-
Registered Address: Https://issues.sonatype.org/secure/Signup!default.jspa
B. Create issue
-
Create address: Https://issues.sonatype.org/secure/Dashboard.jspa, click Create Issue
-
Select New Project under Community support-open Source
-
Fill in the Group Id , Project url , SCM url (SVN or git address ) Information
C. Awaiting approval
-
When found someone replied to the Configuration have been prepared, now can , stating that the audit passed
-
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
-
If you need to install Cygwin under Windows, but for one step, download git bash directly, this git bash is cypwin integrated git
-
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
-
settings.xml is a MAVEN configuration file that can be found in these two ways
-
The global configuration $MAVEN_HOME/conf/settings.xml is found in, where Maven is installed
-
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
-
Enter https://oss.sonatype.org/, this load will be slow
-
Left click Staging repositories
-
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
-
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
-
Follow the steps in the G -step process until the Green flag is successful Activity
-
At this point, Select the Release above, make the official release
J. Final Audit
-
After the successful release, enter the issue created before, add comment, said has succeeded, can write My Project has been successfully released.
-
Once the audit is successful, you can search our framework in http://search.maven.org.
-
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