我一直在尝试将模块发布为声呐,但是我遇到了这个异常-
[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
我尝试了许多方法和插件设置说明,但除了例外情况以外,其他方面有所不同。
答案 0 :(得分:1)
您可以通过以下方式做到这一点:
$ gpg --version
如果没有,请安装gnupg
。
$ gpg --gen-key
以生成密钥。
设置realm
,设置mail address
,设置passphrase
密钥生成完成
$ gpg --list-keys
检查您将得到这种类型的结果-
pub rsa4096 2018-08-22 [SC]
1234517530FB96F147C6A146A326F592D39AAAAA
uid [ultimate] your name <you@example.com>
sub rsa4096 2018-08-22 [E]
现在使用此命令获取公共密钥块
$ gpg -a --export 1234517530FB96F147C6A146A326F592D39AAAAA
复制整个文本-
----- BEGIN PGP公钥块-----
到
----- END PGP公共密钥块-----
将其提交给pgp密钥服务器,请等待几个小时。
4.1将secring.asc文件导出到计算机的任何位置。 写这个命令
$ gpg -a --export-secret-keys > /home/johnny/secring.asc
4.2复制此文件并将其放置到此位置
〜/ .sbt / gpg / secring.asc
在此〜/ .sbt / 1.0 / plugins / gpg.sbt 文件中,以使其全局启用以用于SBT项目,请添加以下行-(如果gpg.sbt文件不存在,请在此处创建该行)
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
seGpg := true
行。如果存在secring.gpg文件,请在模块的build.sbt文件中添加seGpg := true
。6.1在您的终端上运行此命令以查找计算机中的gpg可执行文件
$ 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将此添加到〜/ .sbt / gpg.sbt 文件
gpgCommand := "/user/bin/gpg"
6.3如果在 /home/$username/.gnugp 文件夹中具有 secring.gpg 文件,则必须将此文件添加到〜/ .sbt中/gpg.sbt 文件的
pgpSecretRing := file("/path/to/my/secring.gpg")
有关更多信息,请访问此link
现在创建此文件〜/ .sbt / 1.0 / sonatype.sbt 只需将此行添加到文件中
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credential")
7.1通过此link
创建JIRA帐户7.2通过创建按钮创建一个问题,用于以sonatype打开存储库
7.3创建github存储库或以问题创建形式使用与模块相关的存储库。
7.4使用问题的 OSSRH-XXXXX 字符串创建另一个存储库,如下所示- githubusername / OSSRH-xxxx 。验证您的存储库
您将需要等待几分钟才能获得批准。如果您的仓库被批准,您将收到一封邮件。
现在创建此文件〜/ .sbt / sonatype_credential ,只需添加此行,并设置pass和用户名-分别设置JIRA密码和用户名。
realm=Sonatype Nexus Repository Manager
host=oss.sonatype.org
user=username
password=password
设置此配置---
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:git@github.com: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
现在运行 publishSigned 在您的sbt项目上。
现在您可以通过此链接检查上传的内容
https://oss.sonatype.org/content/repositories/snapshots/com/github/ $ yourgitUserName / $ repoName
或登录https://oss.sonatype.org/并按您的模块名称搜索