Publishing project in the Maven Central Repository (for those who work with sbt)
Step 1:
Go to https://issues.sonatype.org/secure/Signup!default.jspa
To register the Jira user of the Sonatype team.
Step 2:
Go to https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134
To open a new issue with the Sonatype team.
Step 3:
Contents for new Issue.
Summary => Open Source Project
Description => Name of the projects to include in this Group-Id
Group Id => org.marvin-ai (This is the home page of your project in inverted order, in which case ours is marvin-ai.org
If you do not have a home page and use github, the group-id would be com.github.marvin-ai)
Project Url => https://github.com/marvin-ai/marvin-engine-executor
SCM Url => https://github.com/marvin-ai/marvin-engine-executor.git
Username (s) => Your team members
Already Synced to Central => No
Step 4:
Create POM.xml file containing metadatas of your project.
Example - https://github.com/simpligility/ossrh-demo/blob/master/pom.xml
For those who use SBT, the Pom file is generated automatically, but it is necessary to create a sonatype.sbt file in your project root, containing information such as:
import xerial.sbt.Sonatype._
publishMavenStyle: = true
sonatypeProfileName: = "com.github.marvin-ai"
sonatypeProjectHosting: = Some (GitHubHosting ("marvin-ai", "[email protected]", "marvin-engine-executor"))
licenses: = Seq ("APL2" -> url ("http://www.apache.org/licenses/LICENSE-2.0.txt"))
Step 5:
Signing GPG, file submitted for sonatype is obligatory to have gpg sign.
Installing GPG: $ sudo apt-get install gnupg2
Generate the key: $ gpg2 --gen-key
View cahves: $ gpg2 --list-keys
Distribute your public key: $ gpg2 --keyserver hkp: //pool.sks-keyservers.net --send-keys "your key"
Sign the file: $ gpg2 -ab file.jar
SBT user does not need to manually sign the file, the procedure is automated as POM file generation.
Reference - http://central.sonatype.org/pages/working-with-pgp-signatures.html
Step 6:
Add at the end of your build.sbt:
publishTo: = {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some ("snapshots" at nexus + "content / repositories / snapshots")
else
Some ("releases" at nexus + "service / local / staging / deploy / maven2")
}
publishArtifact in Test: = false
useGpg: = true
Step 7:
Plugin for sbt.
Add at the end of your file project/plugins.sbt:
addSbtPlugin ("org.xerial.sbt"% "sbt-sonatype"% "2.3)
addSbtPlugin ("com.jsuereth"% "sbt-pgp"% "1.1.0")
Step 8:
Sonatype Credentials.
Add your sonatype account information to the file (create if you do not have it) $ HOME / .sbt / (sbt-version 0.13 or 1.0) /sonatype.sbt:
credentials + = Credentials ("Sonatype Nexus Repository Manager",
"oss.sonatype.org",
"(Sonatype user name)",
"(Sonatype password)")
Step 9:
Publish your artifacts.
Use the command $ sbt publishSigned
It is possible that it requires the gpg password in the middle of the procedure (if you created it in gpg key creation).
It is recommended to add "-SNAPSHOT" at the end of the version in your build.sbt, so that the artifacts goes first to https://oss.sonatype.org/content/repositories/snapshots
If there is no error at the time of publishing the SNAPSHOT version, delete "-SNAPSHOT" from your version and publish it again, and this time your artifacts goes to sonatype staging server.
Step 10:
Synchronization with the central repository.
Access https://oss.sonatype.org using your sonatype account, locate your publication in the Staging Repositories list (probably the last one on the list)
Select your repository and click the "Close" button and then the "Refresh" button, in the "Activity" tab of your repository will show the validation information of your artifacts.
Correct your errors according to the validation information, use the "Drop" button to erase your repository with error and republish the corrected version again.
When you receive the "Repository Closed" message, press the "Release" button to synchronize with the central maven repository.
Reference: https://www.youtube.com/watch?v=dXR4pJ_zS-0&feature=youtu.be
Tutorial reference, containing step-by-step videos (For those who work with java and maven): http://central.sonatype.org/pages/producers.html