SBT is unable to find credentials when attempting to download from an Artifactory virtual repo

别来无恙 提交于 2019-11-29 02:28:49
Olli Helenius

See this question for details on how to configure global credentials.

To summarise:

If you need to boot SBT from a proxy repository, set the system property sbt.boot.credentials to point to your credentials file. You can do this in your %CSIDL_PROGRAM_FILESX86%/sbt/conf/sbtconfig.txt, for example:

-Dsbt.boot.credentials=/Users/my-user-name/.sbt/credentials

Alternatively you can use the SBT_CREDENTIALS environment variable for the same purpose.

For Artifactory, the realm in the credentials file should be set to:

realm=Artifactory Realm

For authenticating dependency artifact retrieval, create a file like %USERPROFILE%/.sbt/0.13/plugins/my-credentials.sbt with a credentials setting. For example:

credentials += Credentials(Path.userHome / ".sbt" / "credentials")

I think the default location for this file is ${HOME}/.sbt/<sbt-version>/.credentials; while I trust there is published documentation on this, I confirmed this by clicking around in the code.
@salim-fadhley, looks like you are missing the SBT version in the path.

EDIT: You need to add DefaultOptions.addCredentials to your build.sbt; you can then verify what SBT picks up with show credentials.

File location aside, there seems to be confusion between repository names (mean nothing) vs. security realms (mean everything).

The auth-challenge that comes back from the repository server will include the name of the security realm; as a client/developer, you have no control over what it is and my guess is it must match the realm you (client/developer) specify in your .credentials file (wherever that is).

Meanwhile, the repository name (as featured in build.sbt) actually means nothing to anyone outside development of the corresponding project e.g. the repository server admins could not care from one project to the next.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!