I have been trying publish module to sonatype but I am getting this exception--
[error] java.io.FileNotFoundException: /home/johnny/.sbt/gpg/secring.asc (No such file or directory)
[error] at java.io.FileInputStream.open0(Native Method)
[error] at java.io.FileInputStream.open(FileInputStream.java:195)
[error] at java.io.FileInputStream.<init>(FileInputStream.java:138)
[error] at com.jsuereth.pgp.StreamingLoadable.loadFromFile(StreamingLoadable.scala:11)
[error] at com.jsuereth.pgp.StreamingLoadable.loadFromFile$(StreamingLoadable.scala:11)
[error] at com.jsuereth.pgp.SecretKeyRing$.loadFromFile(SecretKeyRing.scala:45)
[error] at com.jsuereth.pgp.PGP$.loadSecretKeyRing(package.scala:31)
[error] at com.jsuereth.pgp.cli.PgpStaticContext.secretKeyRing(context.scala:27)
[error] at com.jsuereth.pgp.cli.PgpStaticContext.secretKeyRing$(context.scala:27)
[error] at com.typesafe.sbt.pgp.SbtPgpStaticContext.secretKeyRing(SbtPgpCommandContext.scala:9)
[error] at com.jsuereth.pgp.cli.DelegatingPgpStaticContext.secretKeyRing(context.scala:34)
[error] at com.jsuereth.pgp.cli.DelegatingPgpStaticContext.secretKeyRing$(context.scala:34)
[error] at com.typesafe.sbt.pgp.SbtPgpCommandContext.secretKeyRing(SbtPgpCommandContext.scala:14)
[error] at com.typesafe.sbt.pgp.BouncyCastlePgpSigner.$anonfun$keyId$1(PgpSigner.scala:37)
[error] at scala.runtime.java8.JFunction0$mcJ$sp.apply(JFunction0$mcJ$sp.java:12)
[error] at scala.Option.getOrElse(Option.scala:121)
[error] at com.typesafe.sbt.pgp.BouncyCastlePgpSigner.<init>(PgpSigner.scala:37)
[error] at com.typesafe.sbt.pgp.PgpSettings$.$anonfun$bcPgpSigner$1(PgpSettings.scala:111)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error] at sbt.std.Transform$$anon$4.work(System.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] at sbt.Execute.work(Execute.scala:278)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (Global / pgpSigner) java.io.FileNotFoundException: /home/johnny/.sbt/gpg/secring.asc (No such file or directory)
[error] Total time: 1 s, completed Jul 17, 2019 2:46:54 PM
I have tried many ways and and plugin setup instructions but getting different short of exceptions.
You can do this by this way:
$ gpg --version
If do not have, install gnupg
.
$ gpg --gen-key
to generate key.
set realm
, set mail address
, set the passphrase
Key generation completed
$ gpg --list-keys
you will get this type result-
pub rsa4096 2018-08-22 [SC]
1234517530FB96F147C6A146A326F592D39AAAAA
uid [ultimate] your name <[email protected]>
sub rsa4096 2018-08-22 [E]
Now use this command to get public key block
$ gpg -a --export 1234517530FB96F147C6A146A326F592D39AAAAA
Copy the whole text-
-----BEGIN PGP PUBLIC KEY BLOCK-----
to
-----END PGP PUBLIC KEY BLOCK-----
Submit it pgp key servers, Wait some hours.
4.1 export secring.asc file to any location of your computer. write this command
$ gpg -a --export-secret-keys > /home/johnny/secring.asc
4.2 Copy this file and place it to this location
~/.sbt/gpg/secring.asc
To this ~/.sbt/1.0/plugins/gpg.sbt file to enable it globally for SBT projects add this line- (if the gpg.sbt file does not exist create this there)
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
useGpg := true
line in your module's build.sbt file. If secring.gpg file exists add useGpg := true
in your module's build.sbt file.6.1 run this command on your terminal to find out the gpg executable file in your machine
$ dpkg --listfiles gpg
/.
/usr
/usr/bin
/usr/bin/gpg
/usr/share
/usr/share/doc
/usr/share/doc/gpg
/usr/share/doc/gpg/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/gpg.1.gz
/usr/share/doc/gpg/NEWS.Debian.gz
/usr/share/doc/gpg/changelog.Debian.gz
6.2 add this to ~/.sbt/gpg.sbt file
gpgCommand := "/user/bin/gpg"
6.3 If in your /home/$username/.gnugp folder you have secring.gpg file you will have to add this to ~/.sbt/gpg.sbt file by
pgpSecretRing := file("/path/to/my/secring.gpg")
For more information visit this link
Now create this file ~/.sbt/1.0/sonatype.sbt just add this line to the file
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credential")
7.1 Create JIRA account by this link
7.2 By create button create an issue for opening your repository in sonatype
7.3 Create github repository or use your module related repository in issue creation form.
you will get idea about your form from this pic
7.4 Create a another repository with your issue's OSSRH-XXXXX string like this- githubusername/OSSRH-xxxx . To verify your repository
You will have to wait some minutes to be approved. If your repo is approved you will get a mail.
Now create this file ~/.sbt/sonatype_credential, just add this line and in pass and username - set your JIRA password and username respectively.
realm=Sonatype Nexus Repository Manager
host=oss.sonatype.org
user=username
password=password
in your module's build.sbt file set this configuration---
ThisBuild / organization := "com.example.project2"
ThisBuild / organizationName := "example"
ThisBuild / organizationHomepage := Some(url("http://example.com/"))
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/your-account/your-project"),
"scm:[email protected]:your-account/your-project.git"
)
)
ThisBuild / developers := List(
Developer(
id = "Your identifier",
name = "Your Name",
email = "your@email",
url = url("http://your.url")
)
)
ThisBuild / description := "Some descripiton about your project."
ThisBuild / licenses := List("Apache 2" -> new URL("http://www.apache.org /licenses/LICENSE-2.0.txt"))
ThisBuild / homepage := Some(url("https://github.com/example/project"))
// Remove all additional repository other than Maven Central from POM
ThisBuild / pomIncludeRepository := { _ => false }
ThisBuild / 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")
}
ThisBuild / publishMavenStyle := true
Now run publishSigned on your sbt project.
Now you can check your upload by this link
https://oss.sonatype.org/content/repositories/snapshots/com/github/$yourgitUserName/$repoName
or login https://oss.sonatype.org/ and search by your module name