如果我被要求提供凭据,我该如何发布 Scala 应用程序? [英] How do I publish a scala app, if I'm asked for credentials?
问题描述
我发出 sbt publish
命令,并得到一个提示,要求我输入用户名和密码.我可以在 build.sbt 或其他地方提供它们,所以我不必手动输入它们吗?
在我的 build.sbt 文件中,我有这个:
publishTo := Some(Resolver.sftp("Server", "url", "port"))
您可以将凭据放在文件中并在 credentials.sbt
中引用,以便 sbt
加载它,并在发布或依赖下载时使用它,>
STEP1:在~/.sbt/1.0/plugins/credentials.sbt
echo 'credentials += Credentials(Path.userHome/".sbt"/".credentials")' >~/.sbt/1.0/plugins/credentials.sbt
注意:echo some-stuff >some-file
将内容重定向到一个文件.echo
是一个 linux 命令
第 2 步:您的 ~/.sbt/.credentials
看起来像,
realm=Artifactory Realm//或 Sonatype Nexus Repository Managerhost=server.com//不要输入 http://或 https://协议user=your.username.for.server.com密码=password.for.server.com
STEP3:在 build.sbt
中设置发布配置,如下所示:
publishTo in ThisBuild := {如果(isSnapshot.value)一些(server.com"上的Artifactory Realm"+/artifactory/libs-snapshot-local")别的一些(server.com"上的Artifactory Realm"+/artifactory/libs-release-local")}
STEP4:您可以验证credentials.sbt
是否被sbt选中,只需运行sbt clean compile
$ sbt 干净编译[信息] 从idea.sbt,credentials.sbt 加载项目全局插件的设置...
相关资源:
官方文档:https://www.scala-sbt.org/1.0/docs/Publishing.html
I issue the sbt publish
command, and get a prompt asking me to enter a username and a password. Can I provide them in build.sbt or some place else, so I don't have to manually enter them?
In my build.sbt file I have this:
publishTo := Some(Resolver.sftp("Server", "url", "port"))
You can put credentials in a file and reference in credentials.sbt
so that sbt
will load it, and use it while publishing or dependency download,
STEP1: setup creds file path in ~/.sbt/1.0/plugins/credentials.sbt
echo 'credentials += Credentials(Path.userHome / ".sbt" / ".credentials")' > ~/.sbt/1.0/plugins/credentials.sbt
note: echo some-stuff > some-file
will redirect contents to a file. echo
is a linux command
STEP2: Your ~/.sbt/.credentials
would look like,
realm=Artifactory Realm // or Sonatype Nexus Repository Manager
host=server.com // don't put in http:// or https:// protocal
user=your.username.for.server.com
password=password.for.server.com
STEP3: setup publish config in build.sbt
something like below:
publishTo in ThisBuild := {
if (isSnapshot.value)
Some("Artifactory Realm" at "server.com" + "/artifactory/libs-snapshot-local")
else
Some("Artifactory Realm" at "server.com" + "/artifactory/libs-release-local")
}
STEP4: you can verify credentials.sbt
is picked up by sbt, just by running sbt clean compile
$ sbt clean compile
[info] Loading settings for project global-plugins from idea.sbt,credentials.sbt ...
Related resources:
Official documentation: https://www.scala-sbt.org/1.0/docs/Publishing.html
How to access a secured Nexus with sbt?
SBT publish to JFrog artifactory
这篇关于如果我被要求提供凭据,我该如何发布 Scala 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!