6

I am using IntelliJ IDEA ultimate to import an SBT project that has some plugins in a private Artifactory.

[info] Resolving com.private#XXXX_X.X;X.X.X-SNAPSHOT ...
[error] Unable to find credentials for [Artifactory Realm @ artifactory-private.com].
[error] Unable to find credentials for [Artifactory Realm @ artifactory-private.com].

I did configure the Artifactory credentials in SBT and is working fine if I build the project using sbt shell; however, build is failing in IntelliJ and is not recognizing the credentials. Can anyone help, please?

Update: It appears that this is the only problem when the plugins are SNAPSHOT versions.

Thank you very much in advance!

vkt
  • 1,401
  • 2
  • 20
  • 46
  • Check this solution https://stackoverflow.com/a/40411532/2000323 – Andrey Apr 27 '19 at 08:23
  • Try also Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | sbt | Use sbt shell -> **for builds** option In IDE. – Andrey Apr 27 '19 at 08:25
  • neither of the solutions worked for me, and the problem only seems when using SNAPSHOT version. Opened an issue with JetBrains https://youtrack.jetbrains.com/issue/SCL-15375 – vkt Aug 21 '19 at 14:10

1 Answers1

4

In sbt 1.x, set 3 files:

~/.sbt/repositories

~/.sbt/credentials

~/.sbt/1.0/plugins/credentials.sbt

The first can contain something like this (just an example):

    [repositories]
    local
    maven-local
    my-ivy-proxy-releases1: https://<yourdomain.org>/sbt-scala/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[rev
    ision]/[type]s/[artifact](-[classifier]).[ext]
    my-maven-proxy-releases: https://<yourdomain.org>/maven-release/

The second something like this:

    realm=Artifactory Realm
    host=<yourdomain.org>
    user=<your_user>
    password=<your_pass>

Additionally, you create this file: ~/.sbt/1.0/plugins/credentials.sbt

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

Now, in the console, in your project directory you can do something like this to compile your project using this repositories only.

sbt -Dsbt.override.build.repos
  1. Now, for IntelliJ, you can go to Settings -> Build, Execution, Deployment -> sbt

And in sbt:

VM parameters: "-Dsbt.override.build.repos"

Mark: - Use sbt shell [✓] For imports [✓] For builds

[✓] Allow overriding sbt version [✓] Enable debugging for sbt shell

vejeta
  • 133
  • 11
  • the issue it is not working for snapshot builds. https://youtrack.jetbrains.com/issue/SCL-15375 – vkt Feb 23 '20 at 16:10
  • @vkt Could it be because that SNAPSHOTS jars have not been published to any repository. Additionally, that issue shows an error regarding: "Unable to find credentials" which means that the credentials file is not there or the credentials setting have not been set, either by as explained above or by doing something like: "export SBT_CREDENTIALS="$HOME/.sbt/credentials". Change it according to the real path of your credentials file. The error you mention is not related to the dependencies being snapshots per se. – vejeta Feb 25 '20 at 10:04
  • the SNAPSHOTS jars are published. As I mentioned in the above question that this is the only problem when the plugins are SNAPSHOT versions. – vkt Mar 02 '20 at 05:57