Sbt/Scala - Gitlab dependency - scala

I'm trying to add in my build.sbt file a dependency to a private gitlab repository via SSH. I have found some documentation online to do this using github examples and I translated this to gitlab:
lazy val libOnGitlab = ProjectRef(uri("git#gitlab.com:username/myproject.git"), "RandomNameHere")
lazy val root = (project in file(".")).dependsOn(libOnGitlab).settings(libraryDependencies += ...)
The problem I have is that Gitlab's SSH link is using a # while github doesn't and this gives me an error:
java.net.URISyntaxException: Illegal character in scheme name at index 3: git#gitlab.com:...
I have already tried many many different things (prepending it with some protocol etc) but I'm pretty new to this and can't manage to solve it. Any ideas?

Related

sbt not able to connect to private artifactory repository

I'm trying to fetch some dependencies from my private repo, however it seems like sbt is not able to find the credentials. There's also an error in my terminal whenever I try to fetch the dependencies
[error] Unable to find credentials for [Artifactory Realm # artifactory.mydomain.com].
I read a couple of answers already, but none of them are working for me.
What I did so far:
1) I configured my repo
cat ~/.sbt/repositories
[repositories]
local
my-ivy-proxy-releases: https://artifactory.mydomain.com/my-ivy-release-local/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
my-maven-proxy-releases: https://artifactory.mydomain.com/my-ivy-release-local/
2) I created a .credentials file
cat ~/.sbt/.credentials
realm=Artifactory Realm
host=artifactory.mydomain.com
user=myuser
password=mypassword
3) I exported the env variable SBT_CREDENTIALS
export SBT_CREDENTIALS=/Users/myuser/.sbt/.credentials
4) I created credentials.sbt in ~/.sbt/0.13/credentials as well as in ~/.sbt/0.13/plugins/credentials
cat ~/.sbt/0.13/credentials.sbt
credentials += Credentials(Path.userHome / ".sbt" / ".credentials")
When I try to access the dependency using curl, everything works just fine.
I read about some alleged solutions already, including:
SBT is unable to find credentials when attempting to download from an Artifactory virtual repo
How to access a secured Nexus with sbt?
How can I provide SBT credentials to my private Artifactory server from a Windows workstation?
I copied credentials.sbt to ~/.sbt/1.0 because i found this answer:
Where should the SBT credentials configuration go? and it looks like it does the trick.

Scala library dependencies in internal artifactory pointing outside

We've got an internal artifactory server and one of my colleagues just put on there the get-coursier library I want to use.
But, when I try to install it through sbt in intellij, the dependencies it needs are trying to be pulled from an external repository, which I can't get to as I'm on an internal only network.
I'm pointing at our internal artifactory using a repositories file in my ~.sbt folder.
How would I define new paths for the dependencies so they would point at out internal artifactory server as well?
Any tips, greatly appreciated.
I add it to the build.sbtlike
val yourRepoRealm = "Artifactory Realm"
val yourRepoUrl = "http://yourhost.com/artifactory/libs-release-local"
Important is that you add this to the settings of the module where you need it:
lazy val sharedSettings: Seq[Def.Setting[_]] = Seq(
...
, resolvers ++= Seq(
yourRepoRealm at yourRepoUrl
, "jitpack" at "https://jitpack.io" // add other repos
), credentials += Credentials(new java.io.File(".credentials"))
, ...
)
This expects that you have your credentials in the project_root/.credentials. like
realm=Artifactory Realm
host=yourHost.com
user=username
password=yourPwd

In SBT, how to use addSbtPlugin with a Github URL?

Currently, I used a plugin like this:
addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "0.7.1")
But then, I fork this plugin on github (let's say https://github.com/myname/play-yeoman.git) and make some changes, what would be an easier way to use my forked version of plugin? Do I really have to register this fork on a maven/ivy repository?
Thanks!
Using SBT 0.13.8, I was able to replace the following line in my ./project/plugins.sbt:
addSbtPlugin("net.ground5hark.sbt" %% "sbt-concat" % "0.1.8")
with the following two lines
lazy val root = (project in file(".")).dependsOn(concatPlugin)
lazy val concatPlugin = uri("https://github.com/ground5hark/sbt-concat.git#342acc34195438799b8a278fda94b126238aae17")
No other steps were necessary. Also, note that the git URI has a commit hash on the end. This is very useful for ensuring a known-to-work, specific version of the source is used in the project, rather than whatever the latest unknown state of the source is.
Follow this steps:
Add -SNAPSHOT suffix to the version of the plugin, i.e. version := "1.0.0-SNAPSHOT"
Run sbt publishLocal from the command line.
Reference the snapshot version from your plugins.sbt.

What are the options to set base packaged directory for a package using sbt-native-packager?

I am trying to build a Debian package using sbt-native-packager as described in this build.sbt.
I set appName using
val appName = "megamgateway"
in project/Build.scala.
All works well. It is just that the contents are stored in /usr/share/megamgateway.
I'd like to have the contents under /usr/share/megam/gateway.
The only way I could find is to use
linuxPackageMapping
as shown here.
Before following along, I'd like to know about other approaches.
You could try to add to your project settings
name := "gateway"
defaultLinuxInstallLocation := "/usr/share/megam/"

Sbt project depending on a external & private github repository

this tutorial explains clearly how to have a remote github depency dependence in an sbt project using:
lazy val reponame = RootProject(uri("git://github.com/group/reponame.git"))
lazy val root = Project(id = "MLSS", base = file("."), settings = sharedSettings) dependsOn(reponame)
However if the remote repo is private, it doesn't seem to work and throws a
Repository not found.
Cloning into '/Users/.../b6958781f05b85672849/reponame'...
[error] Nonzero exit code (128): git clone git://github.com/group/reponame.git
it seems to be an auth error but how to specify the key?
thanks
For a private repo, you want to use SSH so authentication uses your keys instead of a username & password. The github provided SSH url git#github.com:group/reponame.git isn't a correctly formed URI, but it's equivalent to ssh://git#github.com/group/reponame.git. I just tried a uri dependency on a private repo URL formatted that way and it worked for me. Reference.
just using the https version worked fine to clone the repo (provided you have the key in your sshconfig) but it doesn't add the modules to the classpath:
lazy val pogistan = RootProject(uri("https://github.com/group/reponame.git"))