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

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.

Related

What to add to my sbt to support Docker image creation for non-play project?

I have a regular project (not play) and I want to create docker image for this project....how can I do it?
I tried something like this:
dockerRepository := Some("docker-docker-local.artifactoryonline.com")
dockerUpdateLatest := true
dockerEntrypoint := Seq("bin/%s" format executableScriptName.value, "-J-Xms1024M", "-J-Xmx2048m", "-J-server")
but dockerRepository,dockerUpdateLatest and dockerEntrypoint are not familiare in my proj, I need to import something but I dont know what.
I also have a jfrog account to save my artifactory (this is why I added the url).
What is the best way to do it?
thanksss!#
You'll need to add an sbt plugin that supports Docker image creation to your build. Check out sbt-native-packager. To use it, add it to your project/plugins.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6")
Then in your build.sbt, enable Docker support
enablePlugins(DockerPlugin)
After that, your settings should be recognized, and you have the following tasks available:
docker:publishLocal
Build a Docker image
docker:publish
Build image and publish to configured repository
See the full documentation at http://www.scala-sbt.org/sbt-native-packager/ and http://www.scala-sbt.org/sbt-native-packager/formats/docker.html
There's also a mailing list: https://groups.google.com/forum/?hl=en#!forum/sbt-native-packager

Publishing into two repositories

I want to be able to publish to 2 repositories.
One remote repository that I can publish to using sbt publish:
publishTo := Some("Remote repository" at "htpp://...")
One local repository (custom directory within project's root) that I can publish to using sbt publish-local. I couldn't find a way to override the default ${ivy.home}/local. I tried:
externalResolvers += Resolver.file("local", file("mydir"))
But that didn't work. I'm guessing that's because I append at the end of the sequence, so I'm not overriding the default one.
Any suggestions?
EDIT: I have a list of proxy repositories in ~/.sbt/repositories. So I want to keep them too.
To overwrite instead of appending to externalResolvers you could use
val remoteRepo = "my-public" at "http://my-nexus-server/content/groups/public/"
val localRepo = Resolver.file("local", file("mydir"))
externalResolvers := Seq(remoteResolver, localRepo)

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 task to increment project version

Is there an SBT task to increment a project's version?
Given an initial configuration of something like the following build.sbt
name := 'My Project'
organization := 'org.example'
version := '0.1.0'
and a versioning nomenclature of major.minor.patch, I was hoping for an SBT task like
> incrementVersionPatch
that would result in a version of 0.1.1.
(Ideally also the corresponding incrementVersionMinor and incrementVersionMajor.)
I feel like this must already exist but cannot find a way to do it.
I think what you need is sbt-release plugin that "provides a customizable release process that you can add to your project." with "the setting release-version-file, which is set to file("version.sbt") by default and points to $PROJECT_ROOT/version.sbt".

How to add some local maven repo url to global sbt, and make them be tried first?

I want to add some fast local maven repository url to sbt, say:
http://maven.example.com/public
I want to add it to "global", so that I don't need to add them to each of sbt project. And also want to be tried first when sbt downloading some jars.
But I can't find useful information to do this, how to do it?
(My sbt version is 0.13.1)
With the help of a friend, finally I found the solution:
create a new file ~/.sbt/repositories
add content like this:
[repositories]
local
my-maven-repo: http://example.org/repo
my-ivy-repo: http://example.org/ivy-repo/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]
See official doc: http://www.scala-sbt.org/0.13.2/docs/Detailed-Topics/Library-Management.html#override-all-resolvers-for-all-builds
Modify your global configuration file, which is normally located in ~/.sbt/0.13/global.sbt, if it's not there you can create it.
In the file add following line:
externalResolvers := { ("Fast Repo" at "http://maven.example.com/public") +: externalResolvers.value }
You can confirm it's working by executing show externalResolvers in any project to see the list of resolvers. Your newly added resolver should be first.