The underwhelming web presence of Nathan Parry

Deploying Maven artifacts with SBT 0.11

I recently wanted to deploy some artifacts to a Maven repository via SSH using SBT 0.11 but couldn’t find a complete answer in one spot. This probably has more to do with my sub-par Googling skills than lack of answers in the world, but for future reference I got it to work by adding the following to build.sbt:

publishMavenStyle := true

publishTo <<= (version) { version: String =>
  val repoInfo = if (version.trim.endsWith("SNAPSHOT"))
      ( "nparry snapshots" -> "/home/nparry/" )
      ( "nparry releases" -> "/home/nparry/" )
  val user = System.getProperty("")
  val keyFile = (Path.userHome / ".ssh" / "id_rsa").asFile
    repoInfo._2) as(user, keyFile) withPermissions("0644"))

With this addition in place, invoking sbt publish uploads the project’s JAR file along with a POM, source and javadoc bundles. Note that I’m using a SSH key for authentication rather than having SBT prompt me for a password.

This isn’t quite as nice a solution as what I found to work with SBT 0.7, as extra tidbits like the maven-metadata.xml files are not generated. However, the maven-sbt plugin I used before seems not to have made the jump beyond SBT 0.7.

You can see the change in context at the Github page for the project in question. I pieced this together from the Publishing and Resolvers pages of the SBT wiki.